Version Description
- WPML menus sync support. Thanx @pabois for feature request
Download this release
Release Info
Developer | zviryatko |
Plugin | Menu Image |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.3
- README.md +13 -4
- menu-image.php +68 -4
- readme.txt +13 -4
README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
# Menu Image #
|
2 |
**Contributors:** zviryatko
|
3 |
-
**Tags:** menu, image, field, hover
|
4 |
**Donate link:** http://makeyoulivebetter.org.ua/buy-beer
|
5 |
**Requires at least:** 3.5.1
|
6 |
**Tested up to:** 3.9.1
|
7 |
-
**Stable tag:** 2.
|
8 |
**License:** GPLv2 or later
|
9 |
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Adds a field to load the image in a menu item and displays the image inside the link in the menu before the text.
|
|
|
12 |
|
13 |
## Description ##
|
14 |
|
@@ -16,6 +17,7 @@ Adds a field to load the image in a menu item and displays the image inside the
|
|
16 |
Now you can upload the second image and set to the mouse over/out effect.
|
17 |
And also change position of title or hide title if need.
|
18 |
And... load images via media uploader!
|
|
|
19 |
|
20 |
## Installation ##
|
21 |
|
@@ -24,6 +26,7 @@ And... load images via media uploader!
|
|
24 |
3. Go to `/wp-admin/nav-menus.php`
|
25 |
4. Edit exist menu item or add new menu item and just upload image than click `Save Menu`
|
26 |
5. See your menu on site
|
|
|
27 |
|
28 |
## Frequently Asked Questions ##
|
29 |
|
@@ -36,7 +39,7 @@ It makes css markup easier.
|
|
36 |
|
37 |
To add a new size (or remove an old one) add a function to the `menu_image_default_sizes` filter. For example
|
38 |
|
39 |
-
|
40 |
<?php
|
41 |
add_filter( 'menu_image_default_sizes', function($sizes){
|
42 |
|
@@ -51,7 +54,7 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
51 |
|
52 |
});
|
53 |
?>
|
54 |
-
|
55 |
|
56 |
## Screenshots ##
|
57 |
|
@@ -64,6 +67,9 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
64 |
|
65 |
## Changelog ##
|
66 |
|
|
|
|
|
|
|
67 |
### 2.2 ###
|
68 |
* Added grunt-wp-readme-to-markdown npm package for converting readme to markdown for github users.
|
69 |
|
@@ -89,6 +95,9 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
89 |
|
90 |
## Upgrade Notice ##
|
91 |
|
|
|
|
|
|
|
92 |
### 2.0 ###
|
93 |
WARNING! You need to re-select the images! Now, with media uploader support, it's easy peasy.
|
94 |
Media uploader support. Upload once, use many times!
|
1 |
# Menu Image #
|
2 |
**Contributors:** zviryatko
|
3 |
+
**Tags:** menu, image, field, hover, wpml
|
4 |
**Donate link:** http://makeyoulivebetter.org.ua/buy-beer
|
5 |
**Requires at least:** 3.5.1
|
6 |
**Tested up to:** 3.9.1
|
7 |
+
**Stable tag:** 2.3
|
8 |
**License:** GPLv2 or later
|
9 |
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Adds a field to load the image in a menu item and displays the image inside the link in the menu before the text.
|
12 |
+
Now WPML compliant.
|
13 |
|
14 |
## Description ##
|
15 |
|
17 |
Now you can upload the second image and set to the mouse over/out effect.
|
18 |
And also change position of title or hide title if need.
|
19 |
And... load images via media uploader!
|
20 |
+
Now WPML compliant!
|
21 |
|
22 |
## Installation ##
|
23 |
|
26 |
3. Go to `/wp-admin/nav-menus.php`
|
27 |
4. Edit exist menu item or add new menu item and just upload image than click `Save Menu`
|
28 |
5. See your menu on site
|
29 |
+
6. (WMPL users only) Goto WPML > WP Menus Sync and click to `Sync`
|
30 |
|
31 |
## Frequently Asked Questions ##
|
32 |
|
39 |
|
40 |
To add a new size (or remove an old one) add a function to the `menu_image_default_sizes` filter. For example
|
41 |
|
42 |
+
`
|
43 |
<?php
|
44 |
add_filter( 'menu_image_default_sizes', function($sizes){
|
45 |
|
54 |
|
55 |
});
|
56 |
?>
|
57 |
+
`
|
58 |
|
59 |
## Screenshots ##
|
60 |
|
67 |
|
68 |
## Changelog ##
|
69 |
|
70 |
+
### 2.3 ###
|
71 |
+
* WPML menus sync support. Thanx @pabois for [feature request](http://wordpress.org/support/topic/very-good-wpml-compliant)
|
72 |
+
|
73 |
### 2.2 ###
|
74 |
* Added grunt-wp-readme-to-markdown npm package for converting readme to markdown for github users.
|
75 |
|
95 |
|
96 |
## Upgrade Notice ##
|
97 |
|
98 |
+
### 2.3 ###
|
99 |
+
If your are using WPML plugin, now when you sync menus, images will synced too.
|
100 |
+
|
101 |
### 2.0 ###
|
102 |
WARNING! You need to re-select the images! Now, with media uploader support, it's easy peasy.
|
103 |
Media uploader support. Upload once, use many times!
|
menu-image.php
CHANGED
@@ -10,7 +10,7 @@ Plugin Name: Menu Image
|
|
10 |
Plugin URI: http://html-and-cms.com/plugins/menu-image/
|
11 |
Description: Provide uploading images to menu item
|
12 |
Author: Alex Davyskiba aka Zviryatko
|
13 |
-
Version: 2.
|
14 |
Author URI: http://makeyoulivebetter.org.ua/
|
15 |
*/
|
16 |
|
@@ -49,7 +49,7 @@ class Menu_Image_Plugin {
|
|
49 |
public function __construct() {
|
50 |
add_action( 'init', array( $this, 'menu_image_init' ) );
|
51 |
add_filter( 'manage_nav-menus_columns', array( $this, 'menu_image_nav_menu_manage_columns' ), 11 );
|
52 |
-
add_action( '
|
53 |
add_action( 'admin_head-nav-menus.php', array( $this, 'menu_image_admin_head_nav_menus_action' ) );
|
54 |
add_filter( 'wp_edit_nav_menu_walker', array( $this, 'menu_image_edit_nav_menu_walker_filter' ) );
|
55 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'menu_image_wp_setup_nav_menu_item' ) );
|
@@ -58,7 +58,9 @@ class Menu_Image_Plugin {
|
|
58 |
add_action( 'admin_action_delete-menu-item-image', array( $this, 'menu_image_delete_menu_item_image_action' ) );
|
59 |
add_action( 'wp_ajax_set-menu-item-thumbnail', array( $this, 'wp_ajax_set_menu_item_thumbnail' ) );
|
60 |
// Add support for additional image types
|
61 |
-
add_filter('file_is_displayable_image', array($this, 'file_is_displayable_image'), 10, 2);
|
|
|
|
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -117,7 +119,69 @@ class Menu_Image_Plugin {
|
|
117 |
);
|
118 |
foreach ( $menu_image_settings as $setting_name ) {
|
119 |
if ( isset( $_POST[$setting_name][$post_id] ) && !empty( $_POST[$setting_name][$post_id] ) ) {
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
}
|
123 |
}
|
10 |
Plugin URI: http://html-and-cms.com/plugins/menu-image/
|
11 |
Description: Provide uploading images to menu item
|
12 |
Author: Alex Davyskiba aka Zviryatko
|
13 |
+
Version: 2.3
|
14 |
Author URI: http://makeyoulivebetter.org.ua/
|
15 |
*/
|
16 |
|
49 |
public function __construct() {
|
50 |
add_action( 'init', array( $this, 'menu_image_init' ) );
|
51 |
add_filter( 'manage_nav-menus_columns', array( $this, 'menu_image_nav_menu_manage_columns' ), 11 );
|
52 |
+
add_action( 'save_post_nav_menu_item', array( $this, 'menu_image_save_post_action' ), 10, 3 );
|
53 |
add_action( 'admin_head-nav-menus.php', array( $this, 'menu_image_admin_head_nav_menus_action' ) );
|
54 |
add_filter( 'wp_edit_nav_menu_walker', array( $this, 'menu_image_edit_nav_menu_walker_filter' ) );
|
55 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'menu_image_wp_setup_nav_menu_item' ) );
|
58 |
add_action( 'admin_action_delete-menu-item-image', array( $this, 'menu_image_delete_menu_item_image_action' ) );
|
59 |
add_action( 'wp_ajax_set-menu-item-thumbnail', array( $this, 'wp_ajax_set_menu_item_thumbnail' ) );
|
60 |
// Add support for additional image types
|
61 |
+
add_filter( 'file_is_displayable_image', array( $this, 'file_is_displayable_image' ), 10, 2 );
|
62 |
+
// Add support of WPML menus sync
|
63 |
+
add_action( 'wp_update_nav_menu_item', array( $this, 'wp_update_nav_menu_item_action' ), 10, 2 );
|
64 |
}
|
65 |
|
66 |
/**
|
119 |
);
|
120 |
foreach ( $menu_image_settings as $setting_name ) {
|
121 |
if ( isset( $_POST[$setting_name][$post_id] ) && !empty( $_POST[$setting_name][$post_id] ) ) {
|
122 |
+
if ($post->{"_$setting_name"} != $_POST[$setting_name][$post_id]) {
|
123 |
+
update_post_meta( $post_id, "_$setting_name", esc_sql( $_POST[$setting_name][$post_id] ) );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Save item settings while WPML sync menus.
|
131 |
+
*
|
132 |
+
* @param $item_menu_id
|
133 |
+
* @param $menu_item_db_id
|
134 |
+
*/
|
135 |
+
public function wp_update_nav_menu_item_action( $item_menu_id, $menu_item_db_id ) {
|
136 |
+
global $sitepress, $icl_menus_sync;
|
137 |
+
if ( class_exists( 'SitePress' ) && $sitepress instanceof SitePress && class_exists( 'ICLMenusSync' ) && $icl_menus_sync instanceof ICLMenusSync ) {
|
138 |
+
static $run_times = array();
|
139 |
+
$menu_image_settings = array(
|
140 |
+
'menu_item_image_size',
|
141 |
+
'menu_item_image_title_position',
|
142 |
+
'thumbnail_id',
|
143 |
+
'thumbnail_hover_id',
|
144 |
+
);
|
145 |
+
|
146 |
+
// iterate synchronized menus
|
147 |
+
foreach ( $icl_menus_sync->menus as $menu_id => $menu_data ) {
|
148 |
+
if ( !isset( $_POST['sync']['add'][$menu_id] ) ) {
|
149 |
+
continue;
|
150 |
+
}
|
151 |
+
|
152 |
+
// remove cache and get language current item menu
|
153 |
+
$cache_key = md5( serialize( array( $item_menu_id, 'tax_nav_menu' ) ) );
|
154 |
+
$cache_group = 'get_language_for_element';
|
155 |
+
wp_cache_delete( $cache_key, $cache_group );
|
156 |
+
$lang = $sitepress->get_language_for_element( $item_menu_id, 'tax_nav_menu' );
|
157 |
+
|
158 |
+
if ( !isset( $run_times[$menu_id][$lang] ) ) {
|
159 |
+
$run_times[$menu_id][$lang] = 0;
|
160 |
+
}
|
161 |
+
|
162 |
+
// Count static var for each menu id and saved item language
|
163 |
+
// and get original item id from counted position of synchronized
|
164 |
+
// items from POST data. That's all magic.
|
165 |
+
$post_item_ids = array();
|
166 |
+
foreach ($_POST['sync']['add'][$menu_id] as $id => $lang_array) {
|
167 |
+
if (array_key_exists($lang, $lang_array)) {
|
168 |
+
$post_item_ids[] = $id;
|
169 |
+
}
|
170 |
+
}
|
171 |
+
if ( !array_key_exists( $run_times[$menu_id][$lang], $post_item_ids ) ) {
|
172 |
+
continue;
|
173 |
+
}
|
174 |
+
$orig_item_id = $post_item_ids[$run_times[$menu_id][$lang]];
|
175 |
+
|
176 |
+
// iterate all item settings and save it for new item
|
177 |
+
$orig_item_meta = get_metadata( 'post', $orig_item_id );
|
178 |
+
foreach ( $menu_image_settings as $meta ) {
|
179 |
+
if ( isset( $orig_item_meta["_$meta"] ) && isset( $orig_item_meta["_$meta"][0] ) ) {
|
180 |
+
update_post_meta( $menu_item_db_id, "_$meta", $orig_item_meta["_$meta"][0] );
|
181 |
+
}
|
182 |
+
}
|
183 |
+
$run_times[$menu_id][$lang]++;
|
184 |
+
break;
|
185 |
}
|
186 |
}
|
187 |
}
|
readme.txt
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
=== Menu Image ===
|
2 |
Contributors: zviryatko
|
3 |
-
Tags: menu, image, field, hover
|
4 |
Donate link: http://makeyoulivebetter.org.ua/buy-beer
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 3.9.1
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Adds a field to load the image in a menu item and displays the image inside the link in the menu before the text.
|
|
|
12 |
|
13 |
== Description ==
|
14 |
|
@@ -16,6 +17,7 @@ Adds a field to load the image in a menu item and displays the image inside the
|
|
16 |
Now you can upload the second image and set to the mouse over/out effect.
|
17 |
And also change position of title or hide title if need.
|
18 |
And... load images via media uploader!
|
|
|
19 |
|
20 |
== Installation ==
|
21 |
|
@@ -24,6 +26,7 @@ And... load images via media uploader!
|
|
24 |
3. Go to `/wp-admin/nav-menus.php`
|
25 |
4. Edit exist menu item or add new menu item and just upload image than click `Save Menu`
|
26 |
5. See your menu on site
|
|
|
27 |
|
28 |
== Frequently Asked Questions ==
|
29 |
|
@@ -36,7 +39,7 @@ It makes css markup easier.
|
|
36 |
|
37 |
To add a new size (or remove an old one) add a function to the `menu_image_default_sizes` filter. For example
|
38 |
|
39 |
-
|
40 |
<?php
|
41 |
add_filter( 'menu_image_default_sizes', function($sizes){
|
42 |
|
@@ -51,7 +54,7 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
51 |
|
52 |
});
|
53 |
?>
|
54 |
-
|
55 |
|
56 |
== Screenshots ==
|
57 |
|
@@ -60,6 +63,9 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
|
|
|
|
|
|
63 |
= 2.2 =
|
64 |
* Added grunt-wp-readme-to-markdown npm package for converting readme to markdown for github users.
|
65 |
|
@@ -85,6 +91,9 @@ add_filter( 'menu_image_default_sizes', function($sizes){
|
|
85 |
|
86 |
== Upgrade Notice ==
|
87 |
|
|
|
|
|
|
|
88 |
= 2.0 =
|
89 |
WARNING! You need to re-select the images! Now, with media uploader support, it's easy peasy.
|
90 |
Media uploader support. Upload once, use many times!
|
1 |
=== Menu Image ===
|
2 |
Contributors: zviryatko
|
3 |
+
Tags: menu, image, field, hover, wpml
|
4 |
Donate link: http://makeyoulivebetter.org.ua/buy-beer
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 3.9.1
|
7 |
+
Stable tag: 2.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
Adds a field to load the image in a menu item and displays the image inside the link in the menu before the text.
|
12 |
+
Now WPML compliant.
|
13 |
|
14 |
== Description ==
|
15 |
|
17 |
Now you can upload the second image and set to the mouse over/out effect.
|
18 |
And also change position of title or hide title if need.
|
19 |
And... load images via media uploader!
|
20 |
+
Now WPML compliant!
|
21 |
|
22 |
== Installation ==
|
23 |
|
26 |
3. Go to `/wp-admin/nav-menus.php`
|
27 |
4. Edit exist menu item or add new menu item and just upload image than click `Save Menu`
|
28 |
5. See your menu on site
|
29 |
+
6. (WMPL users only) Goto WPML > WP Menus Sync and click to `Sync`
|
30 |
|
31 |
== Frequently Asked Questions ==
|
32 |
|
39 |
|
40 |
To add a new size (or remove an old one) add a function to the `menu_image_default_sizes` filter. For example
|
41 |
|
42 |
+
`
|
43 |
<?php
|
44 |
add_filter( 'menu_image_default_sizes', function($sizes){
|
45 |
|
54 |
|
55 |
});
|
56 |
?>
|
57 |
+
`
|
58 |
|
59 |
== Screenshots ==
|
60 |
|
63 |
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= 2.3 =
|
67 |
+
* WPML menus sync support. Thanx @pabois for [feature request](http://wordpress.org/support/topic/very-good-wpml-compliant)
|
68 |
+
|
69 |
= 2.2 =
|
70 |
* Added grunt-wp-readme-to-markdown npm package for converting readme to markdown for github users.
|
71 |
|
91 |
|
92 |
== Upgrade Notice ==
|
93 |
|
94 |
+
= 2.3 =
|
95 |
+
If your are using WPML plugin, now when you sync menus, images will synced too.
|
96 |
+
|
97 |
= 2.0 =
|
98 |
WARNING! You need to re-select the images! Now, with media uploader support, it's easy peasy.
|
99 |
Media uploader support. Upload once, use many times!
|