Nav Menu Images - Version 3.3

Version Description

  • Released on 15th April 2016
  • Fixed PHP notice in Nav_Menu_Images_Admin::attachment_fields_to_save()
  • Wrap image in AJAX response in <div> tag
  • Change translations text domain
  • Removed languages folder
Download this release

Release Info

Developer dimadin
Plugin Icon wp plugin Nav Menu Images
Version 3.3
Comparing to
See all releases

Code changes from version 3.2 to 3.3

inc/admin.php CHANGED
@@ -80,7 +80,7 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
80
  // Enqueue old script
81
  wp_enqueue_script( 'nmi-scripts', plugins_url( 'nmi.js', __FILE__ ), array( 'media-upload', 'thickbox' ), '1', true );
82
  wp_localize_script( 'nmi-scripts', 'nmi_vars', array(
83
- 'alert' => __( 'You need to set an image as a featured image to be able to use it as an menu item image', 'nmi' )
84
  )
85
  );
86
  add_thickbox();
@@ -164,16 +164,16 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
164
  if ( has_post_thumbnail( $post->ID ) )
165
  $link = get_the_post_thumbnail( $post->ID, 'thumb' );
166
  else
167
- $link = __( 'Upload menu item image', 'nmi' );
168
 
169
  // Full link
170
- $content = '<a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link . '</a>';
171
 
172
  // If item didn't have image, prepend actions links
173
  if ( isset( $_REQUEST['thumb_was'] ) && -1 == $_REQUEST['thumb_was'] ) {
174
- $link_text = __( 'Change menu item image', 'nmi' );
175
  $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
176
- $remove_link = ' | <a href="#" data-id="' . $post->ID . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $post->ID . ');return false;">' . esc_html__( 'Remove menu item image', 'nmi' ) . '</a>';
177
 
178
  $actions = '<a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link_text . '</a>' . $remove_link;
179
 
@@ -218,11 +218,11 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
218
  $is_hover_checked = checked( $is_hover, true, false );
219
 
220
  $form_fields['nmihover'] = array(
221
- 'label' => __( 'Used on hover?', 'nmi' ),
222
  'input' => 'html',
223
  'html' => "<input type='checkbox' class='nmi-hover-checkbox' {$is_hover_checked} name='attachments[{$post->ID}][nmihover]' id='attachments[{$post->ID}][nmihover]' data-parent='{$post->post_parent}' data-checked='{$is_hover}' />",
224
  'value' => $is_hover,
225
- 'helps' => __( 'Should this image be used on hover', 'nmi' ),
226
  'show_in_edit' => false
227
  );
228
 
@@ -232,11 +232,11 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
232
  $is_active_checked = checked( $is_active, true, false );
233
 
234
  $form_fields['nmiactive'] = array(
235
- 'label' => __( 'Used when active?', 'nmi' ),
236
  'input' => 'html',
237
  'html' => "<input type='checkbox' class='nmi-active-checkbox' {$is_active_checked} name='attachments[{$post->ID}][nmiactive]' id='attachments[{$post->ID}][nmiactive]' data-parent='{$post->post_parent}' data-checked='{$is_active}' />",
238
  'value' => $is_active,
239
- 'helps' => __( 'Should this image be used when menu item is active', 'nmi' ),
240
  'show_in_edit' => false
241
  );
242
 
@@ -259,13 +259,13 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
259
  */
260
  function attachment_fields_to_save( $post, $attachment ) {
261
  // Save "hover" checkbox
262
- if ( 'on' == $attachment['nmihover'] )
263
  update_post_meta( $post['post_parent'], '_nmi_hover', $post['ID'] );
264
  else
265
  delete_post_meta( $post['post_parent'], '_nmi_hover', $post['ID'] );
266
 
267
  // Save "active" checkbox
268
- if ( 'on' == $attachment['nmiactive'] )
269
  update_post_meta( $post['post_parent'], '_nmi_active', $post['ID'] );
270
  else
271
  delete_post_meta( $post['post_parent'], '_nmi_active', $post['ID'] );
80
  // Enqueue old script
81
  wp_enqueue_script( 'nmi-scripts', plugins_url( 'nmi.js', __FILE__ ), array( 'media-upload', 'thickbox' ), '1', true );
82
  wp_localize_script( 'nmi-scripts', 'nmi_vars', array(
83
+ 'alert' => __( 'You need to set an image as a featured image to be able to use it as an menu item image', 'nav-menu-images' )
84
  )
85
  );
86
  add_thickbox();
164
  if ( has_post_thumbnail( $post->ID ) )
165
  $link = get_the_post_thumbnail( $post->ID, 'thumb' );
166
  else
167
+ $link = __( 'Upload menu item image', 'nav-menu-images' );
168
 
169
  // Full link
170
+ $content = '<div><a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link . '</a></div>';
171
 
172
  // If item didn't have image, prepend actions links
173
  if ( isset( $_REQUEST['thumb_was'] ) && -1 == $_REQUEST['thumb_was'] ) {
174
+ $link_text = __( 'Change menu item image', 'nav-menu-images' );
175
  $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
176
+ $remove_link = ' | <a href="#" data-id="' . $post->ID . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $post->ID . ');return false;">' . esc_html__( 'Remove menu item image', 'nav-menu-images' ) . '</a>';
177
 
178
  $actions = '<a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link_text . '</a>' . $remove_link;
179
 
218
  $is_hover_checked = checked( $is_hover, true, false );
219
 
220
  $form_fields['nmihover'] = array(
221
+ 'label' => __( 'Used on hover?', 'nav-menu-images' ),
222
  'input' => 'html',
223
  'html' => "<input type='checkbox' class='nmi-hover-checkbox' {$is_hover_checked} name='attachments[{$post->ID}][nmihover]' id='attachments[{$post->ID}][nmihover]' data-parent='{$post->post_parent}' data-checked='{$is_hover}' />",
224
  'value' => $is_hover,
225
+ 'helps' => __( 'Should this image be used on hover', 'nav-menu-images' ),
226
  'show_in_edit' => false
227
  );
228
 
232
  $is_active_checked = checked( $is_active, true, false );
233
 
234
  $form_fields['nmiactive'] = array(
235
+ 'label' => __( 'Used when active?', 'nav-menu-images' ),
236
  'input' => 'html',
237
  'html' => "<input type='checkbox' class='nmi-active-checkbox' {$is_active_checked} name='attachments[{$post->ID}][nmiactive]' id='attachments[{$post->ID}][nmiactive]' data-parent='{$post->post_parent}' data-checked='{$is_active}' />",
238
  'value' => $is_active,
239
+ 'helps' => __( 'Should this image be used when menu item is active', 'nav-menu-images' ),
240
  'show_in_edit' => false
241
  );
242
 
259
  */
260
  function attachment_fields_to_save( $post, $attachment ) {
261
  // Save "hover" checkbox
262
+ if ( isset( $attachment['nmihover'] ) && 'on' == $attachment['nmihover'] )
263
  update_post_meta( $post['post_parent'], '_nmi_hover', $post['ID'] );
264
  else
265
  delete_post_meta( $post['post_parent'], '_nmi_hover', $post['ID'] );
266
 
267
  // Save "active" checkbox
268
+ if ( isset( $attachment['nmiactive'] ) && 'on' == $attachment['nmiactive'] )
269
  update_post_meta( $post['post_parent'], '_nmi_active', $post['ID'] );
270
  else
271
  delete_post_meta( $post['post_parent'], '_nmi_active', $post['ID'] );
inc/walker.php CHANGED
@@ -73,16 +73,16 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
73
  if ( has_post_thumbnail( $item_id ) ) {
74
  $post_thumbnail = get_the_post_thumbnail( $item_id, 'thumb' );
75
  $output .= '<div class="nmi-current-image nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . $post_thumbnail . '</a></div>';
76
- $link_text = __( 'Change menu item image', 'nmi' );
77
 
78
  // For WP 3.5+, add 'remove' action link
79
  if ( version_compare( $wp_version, '3.5', '>=' ) ) {
80
  $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $item_id );
81
- $remove_link = ' | <a href="#" data-id="' . $item_id . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $item_id . ');return false;">' . esc_html__( 'Remove menu item image', 'nmi' ) . '</a>';
82
  }
83
  } else {
84
  $output .= '<div class="nmi-current-image nmi-div" style="display: none;"></div>';
85
- $link_text = __( 'Upload menu item image', 'nmi' );
86
  }
87
 
88
  // Append menu item upload link
73
  if ( has_post_thumbnail( $item_id ) ) {
74
  $post_thumbnail = get_the_post_thumbnail( $item_id, 'thumb' );
75
  $output .= '<div class="nmi-current-image nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . $post_thumbnail . '</a></div>';
76
+ $link_text = __( 'Change menu item image', 'nav-menu-images' );
77
 
78
  // For WP 3.5+, add 'remove' action link
79
  if ( version_compare( $wp_version, '3.5', '>=' ) ) {
80
  $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $item_id );
81
+ $remove_link = ' | <a href="#" data-id="' . $item_id . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $item_id . ');return false;">' . esc_html__( 'Remove menu item image', 'nav-menu-images' ) . '</a>';
82
  }
83
  } else {
84
  $output .= '<div class="nmi-current-image nmi-div" style="display: none;"></div>';
85
+ $link_text = __( 'Upload menu item image', 'nav-menu-images' );
86
  }
87
 
88
  // Append menu item upload link
languages/nmi-sr_RS.mo DELETED
Binary file
languages/nmi-sr_RS.po DELETED
@@ -1,77 +0,0 @@
1
- # Translation of Nav Menu Images in Serbian
2
- # This file is distributed under the same license as the Nav Menu Images package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Nav Menu Images\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/nav-menu-images\n"
7
- "POT-Creation-Date: 2013-03-26 16:01:26+00:00\n"
8
- "PO-Revision-Date: 2013-03-26 17:04+0100\n"
9
- "Last-Translator: Milan Dinić <milan@srpski.biz>\n"
10
- "Language-Team: \n"
11
- "MIME-Version: 1.0\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
- "Content-Transfer-Encoding: 8bit\n"
14
- "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
15
- "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
16
- "X-Generator: Poedit 1.5.5\n"
17
-
18
- #: inc/admin.php:83
19
- msgid ""
20
- "You need to set an image as a featured image to be able to use it as an menu "
21
- "item image"
22
- msgstr ""
23
- "Потребно је да поставите слику као одабрану да бисте могли да је користите "
24
- "као слику ставке изборника"
25
-
26
- #: inc/admin.php:167 inc/walker.php:84
27
- msgid "Upload menu item image"
28
- msgstr "Отпреми слику ставке изборника"
29
-
30
- #: inc/admin.php:174 inc/walker.php:75
31
- msgid "Change menu item image"
32
- msgstr "Промени слику ставке изборника"
33
-
34
- #: inc/admin.php:176 inc/walker.php:80
35
- msgid "Remove menu item image"
36
- msgstr "Уклони слику ставке изборника"
37
-
38
- #: inc/admin.php:221
39
- msgid "Used on hover?"
40
- msgstr "Користи се приликом преласка?"
41
-
42
- #: inc/admin.php:225
43
- msgid "Should this image be used on hover"
44
- msgstr "Да ли би ова слика требало да се користи приликом преласка"
45
-
46
- #: inc/admin.php:235
47
- msgid "Used when active?"
48
- msgstr "Користи је када је активна?"
49
-
50
- #: inc/admin.php:239
51
- msgid "Should this image be used when menu item is active"
52
- msgstr ""
53
- "Да ли би ова слика требало да се користи када је ставка изборника активна"
54
-
55
- #: nav-menu-images.php:320
56
- msgid "Donate"
57
- msgstr "Донирај"
58
-
59
- #. Plugin Name of the plugin/theme
60
- msgid "Nav Menu Images"
61
- msgstr "Слике у изборнику кретања"
62
-
63
- #. Plugin URI of the plugin/theme
64
- msgid "http://blog.milandinic.com/wordpress/plugins/nav-menu-images/"
65
- msgstr "http://blog.milandinic.com/wordpress/plugins/nav-menu-images/"
66
-
67
- #. Description of the plugin/theme
68
- msgid "Display image as a menu content."
69
- msgstr "Прикажите слику као садржај ставке изборника."
70
-
71
- #. Author of the plugin/theme
72
- msgid "Milan Dinić"
73
- msgstr "Милан Динић"
74
-
75
- #. Author URI of the plugin/theme
76
- msgid "http://blog.milandinic.com/"
77
- msgstr "http://www.milandinic.com/"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/nmi.pot DELETED
@@ -1,71 +0,0 @@
1
- # Copyright (C) 2013 Nav Menu Images
2
- # This file is distributed under the same license as the Nav Menu Images package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Nav Menu Images 3.0\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/nav-menu-images\n"
7
- "POT-Creation-Date: 2013-03-26 16:01:26+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
-
15
- #: inc/admin.php:83
16
- msgid ""
17
- "You need to set an image as a featured image to be able to use it as an menu "
18
- "item image"
19
- msgstr ""
20
-
21
- #: inc/admin.php:167 inc/walker.php:84
22
- msgid "Upload menu item image"
23
- msgstr ""
24
-
25
- #: inc/admin.php:174 inc/walker.php:75
26
- msgid "Change menu item image"
27
- msgstr ""
28
-
29
- #: inc/admin.php:176 inc/walker.php:80
30
- msgid "Remove menu item image"
31
- msgstr ""
32
-
33
- #: inc/admin.php:221
34
- msgid "Used on hover?"
35
- msgstr ""
36
-
37
- #: inc/admin.php:225
38
- msgid "Should this image be used on hover"
39
- msgstr ""
40
-
41
- #: inc/admin.php:235
42
- msgid "Used when active?"
43
- msgstr ""
44
-
45
- #: inc/admin.php:239
46
- msgid "Should this image be used when menu item is active"
47
- msgstr ""
48
-
49
- #: nav-menu-images.php:320
50
- msgid "Donate"
51
- msgstr ""
52
-
53
- #. Plugin Name of the plugin/theme
54
- msgid "Nav Menu Images"
55
- msgstr ""
56
-
57
- #. Plugin URI of the plugin/theme
58
- msgid "http://blog.milandinic.com/wordpress/plugins/nav-menu-images/"
59
- msgstr ""
60
-
61
- #. Description of the plugin/theme
62
- msgid "Display image as a menu content."
63
- msgstr ""
64
-
65
- #. Author of the plugin/theme
66
- msgid "Milan Dinić"
67
- msgstr ""
68
-
69
- #. Author URI of the plugin/theme
70
- msgid "http://blog.milandinic.com/"
71
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
nav-menu-images.php CHANGED
@@ -15,8 +15,8 @@
15
  * Description: Display image as a menu content.
16
  * Author: Milan Dinić
17
  * Author URI: http://blog.milandinic.com/
18
- * Version: 3.2
19
- * Text Domain: nmi
20
  * Domain Path: /languages/
21
  * License: GPL
22
  */
@@ -100,8 +100,8 @@ class Nav_Menu_Images {
100
  }
101
 
102
  // Register plugins action links filter
103
- add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
104
- add_filter( 'network_admin_plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
105
 
106
  do_action( 'nmi_init' );
107
  }
@@ -114,12 +114,11 @@ class Nav_Menu_Images {
114
  *
115
  * @uses is_textdomain_loaded() To check if translation is loaded.
116
  * @uses load_plugin_textdomain() To load translation file.
117
- * @uses plugin_basename() To get plugin's file name.
118
  */
119
  public function load_textdomain() {
120
  /* If translation isn't loaded, load it */
121
- if ( ! is_textdomain_loaded( 'nmi' ) )
122
- load_plugin_textdomain( 'nmi', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
123
  }
124
 
125
  /**
@@ -309,18 +308,27 @@ class Nav_Menu_Images {
309
  * Add action links to plugins page.
310
  *
311
  * @since 1.0
 
312
  * @access public
313
  *
314
  * @uses Nav_Menu_Images::load_textdomain() To load translations.
315
  *
316
- * @param array $link Plugin's action links.
317
- * @return array $link Plugin's action links.
 
318
  */
319
- public function action_links( $links ) {
 
 
 
 
 
320
  // Load translations
321
  $this->load_textdomain();
322
 
323
- $links['donate'] = '<a href="http://blog.milandinic.com/donate/">' . __( 'Donate', 'nmi' ) . '</a>';
 
 
324
  return $links;
325
  }
326
  }
15
  * Description: Display image as a menu content.
16
  * Author: Milan Dinić
17
  * Author URI: http://blog.milandinic.com/
18
+ * Version: 3.3
19
+ * Text Domain: nav-menu-images
20
  * Domain Path: /languages/
21
  * License: GPL
22
  */
100
  }
101
 
102
  // Register plugins action links filter
103
+ add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
104
+ add_filter( 'network_admin_plugin_action_links', array( $this, 'action_links' ), 10, 2 );
105
 
106
  do_action( 'nmi_init' );
107
  }
114
  *
115
  * @uses is_textdomain_loaded() To check if translation is loaded.
116
  * @uses load_plugin_textdomain() To load translation file.
 
117
  */
118
  public function load_textdomain() {
119
  /* If translation isn't loaded, load it */
120
+ if ( ! is_textdomain_loaded( 'nav-menu-images' ) )
121
+ load_plugin_textdomain( 'nav-menu-images', false, dirname( $this->plugin_basename ) . '/languages' );
122
  }
123
 
124
  /**
308
  * Add action links to plugins page.
309
  *
310
  * @since 1.0
311
+ * @since 3.3 Added second parameter.
312
  * @access public
313
  *
314
  * @uses Nav_Menu_Images::load_textdomain() To load translations.
315
  *
316
+ * @param array $links Existing plugin's action links.
317
+ * @param string $plugin_file Path to the plugin file.
318
+ * @return array $links New plugin's action links.
319
  */
320
+ public function action_links( $links, $plugin_file ) {
321
+ // Check if it is for this plugin
322
+ if ( $this->plugin_basename != $plugin_file ) {
323
+ return $links;
324
+ }
325
+
326
  // Load translations
327
  $this->load_textdomain();
328
 
329
+ $links['donate'] = '<a href="http://blog.milandinic.com/donate/">' . __( 'Donate', 'nav-menu-images' ) . '</a>';
330
+ $links['wpdev'] = '<a href="http://blog.milandinic.com/wordpress/custom-development/">' . __( 'WordPress Developer', 'nav-menu-images' ) . '</a>';
331
+
332
  return $links;
333
  }
334
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dimadin
3
  Donate link: http://blog.milandinic.com/donate/
4
  Tags: nav menu, menu, media, image
5
  Requires at least: 3.1
6
- Tested up to: 3.8
7
- Stable tag: 3.2
8
 
9
  Display image as a menu item content.
10
 
@@ -41,6 +41,13 @@ There are no configuration options in this plugin.
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
 
 
44
  = 3.2 =
45
  * Released on 14 January 2014
46
  * Fixed PHP notice in NMI_Walker_Nav_Menu_Edit::start_el()
3
  Donate link: http://blog.milandinic.com/donate/
4
  Tags: nav menu, menu, media, image
5
  Requires at least: 3.1
6
+ Tested up to: 4.5
7
+ Stable tag: 3.3
8
 
9
  Display image as a menu item content.
10
 
41
 
42
  == Changelog ==
43
 
44
+ = 3.3 =
45
+ * Released on 15th April 2016
46
+ * Fixed PHP notice in `Nav_Menu_Images_Admin::attachment_fields_to_save()`
47
+ * Wrap image in AJAX response in `<div>` tag
48
+ * Change translations text domain
49
+ * Removed `languages` folder
50
+
51
  = 3.2 =
52
  * Released on 14 January 2014
53
  * Fixed PHP notice in NMI_Walker_Nav_Menu_Edit::start_el()