Nav Menu Images - Version 3.4

Version Description

  • Released on 11th September 2016
  • Removed 'srcset' and 'sizes' attributes.
  • Fixed PHP notice that could happen in some cases.
Download this release

Release Info

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

Code changes from version 3.3 to 3.4

Files changed (3) hide show
  1. inc/admin.php +5 -0
  2. nav-menu-images.php +25 -1
  3. readme.txt +7 -2
inc/admin.php CHANGED
@@ -258,6 +258,11 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
258
  * @return object $post The post object data of attachment.
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'] );
258
  * @return object $post The post object data of attachment.
259
  */
260
  function attachment_fields_to_save( $post, $attachment ) {
261
+ // Check that there is a full post object
262
+ if ( ! isset( $post['post_parent'] ) ) {
263
+ return $post;
264
+ }
265
+
266
  // Save "hover" checkbox
267
  if ( isset( $attachment['nmihover'] ) && 'on' == $attachment['nmihover'] )
268
  update_post_meta( $post['post_parent'], '_nmi_hover', $post['ID'] );
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: 3.3
19
  * Text Domain: nav-menu-images
20
  * Domain Path: /languages/
21
  * License: GPL
@@ -247,6 +247,28 @@ class Nav_Menu_Images {
247
  return $attr;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  /**
251
  * Register menu item content filter.
252
  *
@@ -270,6 +292,7 @@ class Nav_Menu_Images {
270
  add_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
271
  add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
272
  add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
 
273
 
274
  // Mark current item status
275
  if ( in_array( 'current-menu-item', $item_classes ) )
@@ -300,6 +323,7 @@ class Nav_Menu_Images {
300
  remove_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
301
  remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
302
  remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
 
303
 
304
  return $item_output;
305
  }
15
  * Description: Display image as a menu content.
16
  * Author: Milan Dinić
17
  * Author URI: http://blog.milandinic.com/
18
+ * Version: 3.4
19
  * Text Domain: nav-menu-images
20
  * Domain Path: /languages/
21
  * License: GPL
247
  return $attr;
248
  }
249
 
250
+ /**
251
+ * Remove 'srcset' and 'sizes' attributes.
252
+ *
253
+ * @since 3.4
254
+ * @access public
255
+ *
256
+ * @param array $attr Image's attributes.
257
+ * @param object $attachment Image's post object data.
258
+ * @return array $attr New image's attributes.
259
+ */
260
+ public function remove_responsive( $attr, $attachment ) {
261
+ if ( isset( $attr['srcset'] ) ) {
262
+ unset( $attr['srcset'] );
263
+ }
264
+
265
+ if ( isset( $attr['sizes'] ) ) {
266
+ unset( $attr['sizes'] );
267
+ }
268
+
269
+ return $attr;
270
+ }
271
+
272
  /**
273
  * Register menu item content filter.
274
  *
292
  add_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
293
  add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
294
  add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
295
+ add_filter( 'wp_get_attachment_image_attributes', array( $this, 'remove_responsive' ), 15, 2 );
296
 
297
  // Mark current item status
298
  if ( in_array( 'current-menu-item', $item_classes ) )
323
  remove_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
324
  remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
325
  remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
326
+ remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'remove_responsive' ), 15, 2 );
327
 
328
  return $item_output;
329
  }
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: 4.5
7
- Stable tag: 3.3
8
 
9
  Display image as a menu item content.
10
 
@@ -41,6 +41,11 @@ There are no configuration options in this plugin.
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()`
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.6.1
7
+ Stable tag: 3.4
8
 
9
  Display image as a menu item content.
10
 
41
 
42
  == Changelog ==
43
 
44
+ = 3.4 =
45
+ * Released on 11th September 2016
46
+ * Removed 'srcset' and 'sizes' attributes.
47
+ * Fixed PHP notice that could happen in some cases.
48
+
49
  = 3.3 =
50
  * Released on 15th April 2016
51
  * Fixed PHP notice in `Nav_Menu_Images_Admin::attachment_fields_to_save()`