Nav Menu Images - Version 2.0

Version Description

  • Use new media views for WordPress 3.5+
  • Add more hooks for developers
Download this release

Release Info

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

Code changes from version 1.0 to 2.0

inc/admin.php CHANGED
@@ -24,14 +24,17 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
24
  * @access public
25
  *
26
  * @uses add_filter() To hook filters.
27
- * @uses add_action() To hook function.
28
  */
29
  public function __construct() {
 
 
 
30
  // Register walker replacement
31
- add_filter( 'wp_edit_nav_menu_walker', array( &$this, 'filter_walker' ) );
32
 
33
  // Register enqueuing of scripts
34
- add_action( 'admin_menu', array( &$this, 'register_enqueuing' ) );
35
  }
36
 
37
  /**
@@ -52,22 +55,37 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
52
  * @since 1.0
53
  * @access public
54
  *
 
55
  * @uses Nav_Menu_Images::load_textdomain() To load translations.
56
- * @uses wp_enqueue_script() To enqueue script.
57
  * @uses plugins_url() To get URL of the file.
58
  * @uses wp_localize_script() To add script's variables.
59
- * @uses wp_enqueue_style() To enqueue style.
 
 
 
60
  */
61
  public function enqueue_scripts() {
 
 
62
  // Load translations
63
  $this->load_textdomain();
64
 
 
65
  wp_enqueue_script( 'nmi-scripts', plugins_url( 'nmi.js', __FILE__ ), array( 'media-upload', 'thickbox' ), '1', true );
66
  wp_localize_script( 'nmi-scripts', 'nmi_vars', array(
67
  'alert' => __( 'You need to set an image as a featured image to be able to use it as an menu item image', 'nmi' )
68
  )
69
  );
70
- wp_enqueue_style( 'thickbox' );
 
 
 
 
 
 
 
 
71
  }
72
 
73
  /**
@@ -87,4 +105,76 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
87
  require_once dirname( __FILE__ ) . '/walker.php';
88
  return 'NMI_Walker_Nav_Menu_Edit';
89
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
24
  * @access public
25
  *
26
  * @uses add_filter() To hook filters.
27
+ * @uses add_action() To hook functions.
28
  */
29
  public function __construct() {
30
+ // Register new AJAX thumbnail response
31
+ add_filter( 'admin_post_thumbnail_html', array( &$this, '_wp_post_thumbnail_html' ), 10, 2 );
32
+
33
  // Register walker replacement
34
+ add_filter( 'wp_edit_nav_menu_walker', array( &$this, 'filter_walker' ) );
35
 
36
  // Register enqueuing of scripts
37
+ add_action( 'admin_menu', array( &$this, 'register_enqueuing' ) );
38
  }
39
 
40
  /**
55
  * @since 1.0
56
  * @access public
57
  *
58
+ * @global $wp_version.
59
  * @uses Nav_Menu_Images::load_textdomain() To load translations.
60
+ * @uses wp_enqueue_script() To enqueue scripts.
61
  * @uses plugins_url() To get URL of the file.
62
  * @uses wp_localize_script() To add script's variables.
63
+ * @uses add_thickbox() To enqueue Thickbox style & script.
64
+ * @uses version_compare() To compare WordPress versions.
65
+ * @uses wp_enqueue_media() To load media view templates, scripts & styles.
66
+ * @uses do_action() Calls 'nmi_enqueue_scripts'.
67
  */
68
  public function enqueue_scripts() {
69
+ global $wp_version;
70
+
71
  // Load translations
72
  $this->load_textdomain();
73
 
74
+ // Enqueue old script
75
  wp_enqueue_script( 'nmi-scripts', plugins_url( 'nmi.js', __FILE__ ), array( 'media-upload', 'thickbox' ), '1', true );
76
  wp_localize_script( 'nmi-scripts', 'nmi_vars', array(
77
  'alert' => __( 'You need to set an image as a featured image to be able to use it as an menu item image', 'nmi' )
78
  )
79
  );
80
+ add_thickbox();
81
+
82
+ // For WP 3.5+, enqueue new script & dependicies
83
+ if ( version_compare( $wp_version, '3.5', '>=' ) ) {
84
+ wp_enqueue_media();
85
+ wp_enqueue_script( 'nmi-media-view', plugins_url( 'media-view.js', __FILE__ ), array( 'jquery', 'media-editor', 'media-views', 'post' ), '1.0', true );
86
+ }
87
+
88
+ do_action( 'nmi_enqueue_scripts' );
89
  }
90
 
91
  /**
105
  require_once dirname( __FILE__ ) . '/walker.php';
106
  return 'NMI_Walker_Nav_Menu_Edit';
107
  }
108
+
109
+ /**
110
+ * Output HTML for the post thumbnail meta-box.
111
+ *
112
+ * @since 2.0
113
+ * @access public
114
+ *
115
+ * @uses get_post() TO get post's object.
116
+ * @uses Nav_Menu_Images::load_textdomain() To load translations.
117
+ * @uses admin_url() To get URL of uploader.
118
+ * @uses esc_url() To escape URL.
119
+ * @uses add_query_arg() To append variables to URL.
120
+ * @uses has_post_thumbnail() To check if item has thumb.
121
+ * @uses get_the_post_thumbnail() To get item's thumb.
122
+ * @uses wp_create_nonce() To create item's nonce.
123
+ * @uses esc_html__() To translate & escape string.
124
+ * @uses apply_filters() Calls 'nmi_admin_post_thumbnail_html' to
125
+ * overwrite returned output.
126
+ *
127
+ * @param string $content Original HTML output of the thubnail.
128
+ * @param int $post_id The post ID associated with the thumbnail.
129
+ * @return string New HTML output.
130
+ */
131
+ public function _wp_post_thumbnail_html( $content, $post_id ) {
132
+ // Check if request from this plugin
133
+ if ( ! isset( $_REQUEST['nmi_request'] ) )
134
+ return $content;
135
+
136
+ // Get post object
137
+ $post = get_post( $post_id );
138
+
139
+ // Check if post exists and is nav menu item
140
+ if ( ! $post || 'nav_menu_item' != $post->post_type )
141
+ return $content;
142
+
143
+ // Load translations
144
+ $this->load_textdomain();
145
+
146
+ // Form upload link
147
+ $upload_url = admin_url( 'media-upload.php' );
148
+ $query_args = array(
149
+ 'post_id' => $post->ID,
150
+ 'tab' => 'gallery',
151
+ 'TB_iframe' => '1',
152
+ 'width' => '640',
153
+ 'height' => '425'
154
+ );
155
+ $upload_url = esc_url( add_query_arg( $query_args, $upload_url ) );
156
+
157
+ // Item's featured image or plain link
158
+ if ( has_post_thumbnail( $post->ID ) )
159
+ $link = get_the_post_thumbnail( $post->ID, 'thumb' );
160
+ else
161
+ $link = __( 'Upload menu item image', 'nmi' );
162
+
163
+ // Full link
164
+ $content = '<a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link . '</a>';
165
+
166
+ // If item didn't have image, prepend actions links
167
+ if ( isset( $_REQUEST['thumb_was'] ) && -1 == $_REQUEST['thumb_was'] ) {
168
+ $link_text = __( 'Change menu item image', 'nmi' );
169
+ $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
170
+ $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>';
171
+
172
+ $actions = '<a href="' . $upload_url . '" data-id="' . $post->ID . '" class="thickbox add_media">' . $link_text . '</a>' . $remove_link;
173
+
174
+ $content = $actions . $content;
175
+ }
176
+
177
+ // Filter returned HTML output
178
+ return apply_filters( 'nmi_admin_post_thumbnail_html', $content, $post->ID );
179
+ }
180
  }
inc/media-view.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Nav Menu Images Media View.
3
+ *
4
+ * @since 2.0
5
+ *
6
+ * @package Nav Menu Images
7
+ * @subpackage Media View
8
+ */
9
+ jQuery(document).ready(function($){
10
+ // Prepare the variable that holds our custom media manager.
11
+ // Based on wp.media.featuredImage
12
+ wp.media.nmi = {
13
+ get: function() {
14
+ return wp.media.view.settings.post.featuredImageId;
15
+ },
16
+
17
+ set: function( id ) {
18
+ var settings = wp.media.view.settings;
19
+
20
+ settings.post.featuredImageId = id;
21
+
22
+ wp.media.post( 'set-post-thumbnail', {
23
+ json: true,
24
+ post_id: settings.post.id,
25
+ thumbnail_id: settings.post.featuredImageId,
26
+ _wpnonce: settings.post.nonce,
27
+ thumb_was: settings.post.featuredExisted,
28
+ nmi_request: true
29
+ }).done( function( html ) {
30
+ if ( 1 == settings.post.featuredExisted )
31
+ $( '.nmi-upload-link', "li#menu-item-"+settings.post.id ).show();
32
+ else
33
+ $( '.nmi-upload-link', "li#menu-item-"+settings.post.id ).hide();
34
+ $( '.nmi-current-image', "li#menu-item-"+settings.post.id ).html( html );
35
+ });
36
+ },
37
+
38
+ frame: function() {
39
+ if ( this._frame )
40
+ return this._frame;
41
+
42
+ this._frame = wp.media({
43
+ state: 'featured-image',
44
+ states: [ new wp.media.controller.FeaturedImage() ]
45
+ });
46
+
47
+ this._frame.on( 'toolbar:create:featured-image', function( toolbar ) {
48
+ this.createSelectToolbar( toolbar, {
49
+ text: wp.media.view.l10n.setFeaturedImage
50
+ });
51
+ }, this._frame );
52
+
53
+ this._frame.state('featured-image').on( 'select', this.select );
54
+ return this._frame;
55
+ },
56
+
57
+ select: function() {
58
+ var settings = wp.media.view.settings,
59
+ selection = this.get('selection').single();
60
+
61
+ if ( ! settings.post.featuredImageId )
62
+ return;
63
+
64
+ wp.media.nmi.set( selection ? selection.id : -1 );
65
+ },
66
+
67
+ init: function() {
68
+ // Open the content media manager to the 'featured image' tab when
69
+ // the post thumbnail is clicked.
70
+ $('.nmi-div').on( 'click', '.add_media', function( event ) {
71
+ event.preventDefault();
72
+ // Stop propagation to prevent thickbox from activating.
73
+ event.stopPropagation();
74
+
75
+ var nmi_clicked_item_id = $(this).data('id');
76
+ wp.media.view.settings = nmi_settings[nmi_clicked_item_id];
77
+
78
+ wp.media.nmi.frame().open();
79
+ // Update the featured image id when the 'remove' link is clicked.
80
+ }).on( 'click', '.nmi_remove', function() {
81
+ var nmi_clicked_item_id = $(this).data('id');
82
+ nmi_settings[nmi_clicked_item_id].post.featuredImageId = -1;
83
+ });
84
+ }
85
+ };
86
+
87
+ $( wp.media.nmi.init );
88
+
89
+ // Based on WPRemoveThumbnail
90
+ NMIRemoveThumbnail = function(nonce,post_id){
91
+ $.post(ajaxurl, {
92
+ action:"set-post-thumbnail", post_id: post_id, thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie), nmi_request: true
93
+ }, function(str){
94
+ if ( str == '0' ) {
95
+ alert( setPostThumbnailL10n.error );
96
+ } else {
97
+ $( '.nmi-upload-link', "li#menu-item-"+post_id ).hide();
98
+ $( '.nmi-current-image', "li#menu-item-"+post_id ).html( str );
99
+ }
100
+ }
101
+ );
102
+ };
103
+
104
+ });
inc/walker.php CHANGED
@@ -22,6 +22,7 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
22
  * @since 1.0
23
  * @access public
24
  *
 
25
  * @uses Walker_Nav_Menu_Edit::start_el()
26
  * @uses admin_url() To get URL of uploader.
27
  * @uses esc_url() To escape URL.
@@ -29,7 +30,15 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
29
  * @uses esc_attr() To escape string.
30
  * @uses has_post_thumbnail() To check if item has thumb.
31
  * @uses get_the_post_thumbnail() To get item's thumb.
 
 
 
32
  * @uses esc_html() To escape string.
 
 
 
 
 
33
  *
34
  * @param string $output Passed by reference. Used to append additional content.
35
  * @param object $item Menu item data object.
@@ -37,6 +46,8 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
37
  * @param object $args
38
  */
39
  public function start_el( &$output, $item, $depth, $args ) {
 
 
40
  // First, make item with standard class
41
  parent::start_el( $output, $item, $depth, $args );
42
 
@@ -60,14 +71,128 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
60
  // Generate menu item image & link's text string
61
  if ( has_post_thumbnail( $item_id ) ) {
62
  $post_thumbnail = get_the_post_thumbnail( $item_id, 'thumb' );
63
- $output .= '<div class="nmi-current-image" style="display: none;"><a href="' . $upload_url . '" class="thickbox add_media">' . $post_thumbnail . '</a></div>';
64
  $link_text = __( 'Change menu item image', 'nmi' );
 
 
 
 
 
 
65
  } else {
66
- $output .= '<div class="nmi-current-image" style="display: none;"></div>';
67
  $link_text = __( 'Upload menu item image', 'nmi' );
68
  }
69
 
70
- // Generate menu item upload link
71
- $output .= '<div class="nmi-upload-link" style="display: none;"><a href="' . $upload_url . '" class="thickbox add_media">' . esc_html( $link_text ) . '</a></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  }
22
  * @since 1.0
23
  * @access public
24
  *
25
+ * @global $wp_version
26
  * @uses Walker_Nav_Menu_Edit::start_el()
27
  * @uses admin_url() To get URL of uploader.
28
  * @uses esc_url() To escape URL.
30
  * @uses esc_attr() To escape string.
31
  * @uses has_post_thumbnail() To check if item has thumb.
32
  * @uses get_the_post_thumbnail() To get item's thumb.
33
+ * @uses version_compare() To compare WordPress versions.
34
+ * @uses wp_create_nonce() To create item's nonce.
35
+ * @uses esc_html__() To translate & escape string.
36
  * @uses esc_html() To escape string.
37
+ * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_output' with the output.
38
+ * post object, depth and arguments to overwrite item's output.
39
+ * @uses NMI_Walker_Nav_Menu_Edit::get_settings() To get JSONed item's data.
40
+ * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_end' with the output.
41
+ * post object, depth and arguments to overwrite item's output.
42
  *
43
  * @param string $output Passed by reference. Used to append additional content.
44
  * @param object $item Menu item data object.
46
  * @param object $args
47
  */
48
  public function start_el( &$output, $item, $depth, $args ) {
49
+ global $wp_version;
50
+
51
  // First, make item with standard class
52
  parent::start_el( $output, $item, $depth, $args );
53
 
71
  // Generate menu item image & link's text string
72
  if ( has_post_thumbnail( $item_id ) ) {
73
  $post_thumbnail = get_the_post_thumbnail( $item_id, 'thumb' );
74
+ $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>';
75
  $link_text = __( 'Change menu item image', 'nmi' );
76
+
77
+ // For WP 3.5+, add 'remove' action link
78
+ if ( version_compare( $wp_version, '3.5', '>=' ) ) {
79
+ $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $item_id );
80
+ $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>';
81
+ }
82
  } else {
83
+ $output .= '<div class="nmi-current-image nmi-div" style="display: none;"></div>';
84
  $link_text = __( 'Upload menu item image', 'nmi' );
85
  }
86
 
87
+ // Append menu item upload link
88
+ $output .= '<div class="nmi-upload-link nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . esc_html( $link_text ) . '</a>';
89
+
90
+ // Append menu item 'remove' link
91
+ if ( isset( $remove_link ) )
92
+ $output .= $remove_link;
93
+
94
+ // Close menu item
95
+ $output .= '</div>';
96
+
97
+ // Filter output
98
+ do_action_ref_array( 'nmi_menu_item_walker_output', array( &$output, $item, $depth, $args ) );
99
+
100
+ // Add JSONed meta data
101
+ $output .= $this->get_settings( $item_id );
102
+
103
+ do_action_ref_array( 'nmi_menu_item_walker_end', array( &$output, $item, $depth, $args ) );
104
+ }
105
+
106
+ /**
107
+ * Get JSONed item's data.
108
+ *
109
+ * Heavily based on wp_enqueue_media() and
110
+ * WP_Scripts::localize()
111
+ *
112
+ * @see wp_enqueue_media()
113
+ * @see WP_Scripts::localize()
114
+ *
115
+ * @since 2.0
116
+ * @access public
117
+ *
118
+ * @uses version_compare() To compare WordPress versions.
119
+ * @uses wp_create_nonce() To create item's nonce.
120
+ * @uses get_post() To get post's object.
121
+ * @uses get_post_meta() To get post's meta data.
122
+ * @uses apply_filters() Calls 'media_view_settings' with the settings
123
+ * and post object to overwrite item's settings.
124
+ * @uses did_action() To check if action was done.
125
+ * @uses do_action() Calls 'nmi_setup_settings_var' with the item ID.
126
+ *
127
+ * @param int $post_id The item's post ID.
128
+ * @return string New HTML output.
129
+ */
130
+ public function get_settings( $post_id ) {
131
+ global $wp_version;
132
+
133
+ // Only works for WP 3.5+
134
+ if ( ! version_compare( $wp_version, '3.5', '>=' ) )
135
+ return;
136
+
137
+ // Prepare general settings
138
+ $settings = array(
139
+ 'nonce' => array(
140
+ 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ),
141
+ ),
142
+ 'post' => array(
143
+ 'id' => 0,
144
+ ),
145
+ 'defaultProps' => array(
146
+ 'link' => get_option( 'image_default_link_type' ), // db default is 'file'
147
+ 'align' => get_option( 'image_default_align' ), // empty default
148
+ 'size' => get_option( 'image_default_size' ), // empty default
149
+ )
150
+ );
151
+
152
+ // Prepare post specific settings
153
+ $post = null;
154
+ if ( isset( $post_id ) ) {
155
+ $post = get_post( $post_id );
156
+ $settings['post'] = array(
157
+ 'id' => $post->ID,
158
+ 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
159
+ );
160
+
161
+ $featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
162
+ $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
163
+ $settings['post']['featuredExisted'] = $featured_image_id ? 1 : -1;
164
+ }
165
+
166
+ // Filter item's settins
167
+ $settings = apply_filters( 'media_view_settings', $settings, $post );
168
+
169
+ // Prepare Javascript varible name
170
+ $object_name = 'nmi_settings[' . $post->ID . ']';
171
+
172
+ // Loop through each setting and prepare it for JSON
173
+ foreach ( (array) $settings as $key => $value ) {
174
+ if ( ! is_scalar( $value ) )
175
+ continue;
176
+
177
+ $settings[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
178
+ }
179
+
180
+ // Encode settings to JSON
181
+ $script = "$object_name = " . json_encode( $settings ) . ';';
182
+
183
+ // If this is first item, register variable
184
+ if ( ! did_action( 'nmi_setup_settings_var' ) ) {
185
+ $script = "var nmi_settings = [];\n" . $script;
186
+ do_action( 'nmi_setup_settings_var', $post->ID );
187
+ }
188
+
189
+ // Wrap everythig
190
+ $output = "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
191
+ $output .= "/* <![CDATA[ */\n";
192
+ $output .= "$script\n";
193
+ $output .= "/* ]]> */\n";
194
+ $output .= "</script>\n";
195
+
196
+ return $output;
197
  }
198
  }
languages/nmi-sr_RS.mo CHANGED
Binary file
languages/nmi-sr_RS.po CHANGED
@@ -4,8 +4,8 @@ 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: 2012-10-04 19:54:38+00:00\n"
8
- "PO-Revision-Date: 2012-10-08 21:16+0100\n"
9
  "Last-Translator: Milan Dinić <milan@srpski.biz>\n"
10
  "Language-Team: \n"
11
  "MIME-Version: 1.0\n"
@@ -13,9 +13,9 @@ msgstr ""
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.3\n"
17
 
18
- #: inc/admin.php:46
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"
@@ -23,15 +23,19 @@ msgstr ""
23
  "Потребно је да поставите слику као одабрану да бисте могли да је користите "
24
  "као слику ставке изборника"
25
 
26
- #: inc/walker.php:50
 
 
 
 
27
  msgid "Change menu item image"
28
  msgstr "Промени слику ставке изборника"
29
 
30
- #: inc/walker.php:53
31
- msgid "Upload menu item image"
32
- msgstr "Отпреми слику ставке изборника"
33
 
34
- #: nav-menu-images.php:165
35
  msgid "Donate"
36
  msgstr "Донирај"
37
 
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-02-10 14:31:46+00:00\n"
8
+ "PO-Revision-Date: 2013-02-10 15:32+0100\n"
9
  "Last-Translator: Milan Dinić <milan@srpski.biz>\n"
10
  "Language-Team: \n"
11
  "MIME-Version: 1.0\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:77
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"
23
  "Потребно је да поставите слику као одабрану да бисте могли да је користите "
24
  "као слику ставке изборника"
25
 
26
+ #: inc/admin.php:161 inc/walker.php:84
27
+ msgid "Upload menu item image"
28
+ msgstr "Отпреми слику ставке изборника"
29
+
30
+ #: inc/admin.php:168 inc/walker.php:75
31
  msgid "Change menu item image"
32
  msgstr "Промени слику ставке изборника"
33
 
34
+ #: inc/admin.php:170 inc/walker.php:80
35
+ msgid "Remove menu item image"
36
+ msgstr "Уклони слику ставке изборника"
37
 
38
+ #: nav-menu-images.php:238
39
  msgid "Donate"
40
  msgstr "Донирај"
41
 
languages/nmi.pot CHANGED
@@ -1,35 +1,36 @@
1
- # Copyright (C) 2012 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 1.0\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/nav-menu-images\n"
7
- "POT-Creation-Date: 2012-10-04 19:54:38+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: 2012-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:46
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/walker.php:50
22
  msgid "Change menu item image"
23
  msgstr ""
24
 
25
- #: inc/walker.php:53
26
- msgid "Upload menu item image"
27
  msgstr ""
28
 
29
- #: nav-menu-images.php:165
30
  msgid "Donate"
31
  msgstr ""
32
-
33
  #. Plugin Name of the plugin/theme
34
  msgid "Nav Menu Images"
35
  msgstr ""
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 2.0-beta-1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/nav-menu-images\n"
7
+ "POT-Creation-Date: 2013-02-10 14:31:46+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:77
16
+ msgid "You need to set an image as a featured image to be able to use it as an menu item image"
17
+ msgstr ""
18
+
19
+ #: inc/admin.php:161 inc/walker.php:84
20
+ msgid "Upload menu item image"
21
  msgstr ""
22
 
23
+ #: inc/admin.php:168 inc/walker.php:75
24
  msgid "Change menu item image"
25
  msgstr ""
26
 
27
+ #: inc/admin.php:170 inc/walker.php:80
28
+ msgid "Remove menu item image"
29
  msgstr ""
30
 
31
+ #: nav-menu-images.php:238
32
  msgid "Donate"
33
  msgstr ""
 
34
  #. Plugin Name of the plugin/theme
35
  msgid "Nav Menu Images"
36
  msgstr ""
nav-menu-images.php CHANGED
@@ -15,7 +15,7 @@
15
  * Description: Display image as a menu content.
16
  * Author: Milan Dinić
17
  * Author URI: http://blog.milandinic.com/
18
- * Version: 1.0
19
  * Text Domain: nmi
20
  * Domain Path: /languages/
21
  * License: GPL
@@ -69,6 +69,7 @@ class Nav_Menu_Images {
69
  * @uses apply_filters() Calls 'nmi_filter_menu_item_content' to
70
  * overwrite menu item filter.
71
  * @uses add_filter() To hook filters.
 
72
  */
73
  public function init() {
74
  // Add thumbnail support to menus
@@ -92,6 +93,8 @@ class Nav_Menu_Images {
92
  // Register plugins action links filter
93
  add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
94
  add_filter( 'network_admin_plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
 
 
95
  }
96
 
97
  /**
@@ -151,7 +154,7 @@ class Nav_Menu_Images {
151
  $post_thumbnail = get_the_post_thumbnail( $post_id, 'thumb' );
152
 
153
  // Full HTML
154
- $return_html = '<a href="' . $upload_url . '" class="thickbox add_media">' . $post_thumbnail . '</a>';
155
 
156
  die( $return_html );
157
  }
@@ -250,4 +253,4 @@ class Nav_Menu_Images {
250
  function nmi_instantiate() {
251
  new Nav_Menu_Images();
252
  }
253
- add_action( 'plugins_loaded', 'nmi_instantiate', 15 );
15
  * Description: Display image as a menu content.
16
  * Author: Milan Dinić
17
  * Author URI: http://blog.milandinic.com/
18
+ * Version: 2.0
19
  * Text Domain: nmi
20
  * Domain Path: /languages/
21
  * License: GPL
69
  * @uses apply_filters() Calls 'nmi_filter_menu_item_content' to
70
  * overwrite menu item filter.
71
  * @uses add_filter() To hook filters.
72
+ * @uses do_action() Calls 'nmi_init'.
73
  */
74
  public function init() {
75
  // Add thumbnail support to menus
93
  // Register plugins action links filter
94
  add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
95
  add_filter( 'network_admin_plugin_action_links_' . $this->plugin_basename, array( $this, 'action_links' ) );
96
+
97
+ do_action( 'nmi_init' );
98
  }
99
 
100
  /**
154
  $post_thumbnail = get_the_post_thumbnail( $post_id, 'thumb' );
155
 
156
  // Full HTML
157
+ $return_html = '<a href="' . $upload_url . '" data-id="' . $post_id . '" class="thickbox add_media">' . $post_thumbnail . '</a>';
158
 
159
  die( $return_html );
160
  }
253
  function nmi_instantiate() {
254
  new Nav_Menu_Images();
255
  }
256
+ add_action( 'plugins_loaded', 'nmi_instantiate', 15 );
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.5
7
- Stable tag: 1.0
8
 
9
  Display image as a menu item content.
10
 
@@ -34,3 +34,13 @@ There are no configuration options in this plugin.
34
 
35
  1. Link to upload form on nav menu item's edit screen
36
  2. Uploaded image on nav menu item's edit screen
 
 
 
 
 
 
 
 
 
 
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.5.1
7
+ Stable tag: 2.0
8
 
9
  Display image as a menu item content.
10
 
34
 
35
  1. Link to upload form on nav menu item's edit screen
36
  2. Uploaded image on nav menu item's edit screen
37
+
38
+ == Changelog ==
39
+
40
+ = 2.0 =
41
+ * Use new media views for WordPress 3.5+
42
+ * Add more hooks for developers
43
+
44
+ = 1.0 =
45
+ * Released on 22nd October 2012
46
+ * Initial release