Version Description
- Released on 14 January 2014
- Fixed PHP notice in NMI_Walker_Nav_Menu_Edit::start_el()
- Don't pass class object by reference
- Maybe fixed issues with "Missing argument 3 for Nav_Menu_Images::register_menu_item_filter()" errors
- Add 'has-image' class to the menu item that has image
Download this release
Release Info
Developer | dimadin |
Plugin | Nav Menu Images |
Version | 3.2 |
Comparing to | |
See all releases |
Code changes from version 3.1 to 3.2
- inc/admin.php +6 -6
- inc/walker.php +4 -3
- nav-menu-images.php +15 -12
- readme.txt +9 -2
inc/admin.php
CHANGED
@@ -28,19 +28,19 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
|
|
28 |
*/
|
29 |
public function __construct() {
|
30 |
// Register new AJAX thumbnail response
|
31 |
-
add_filter( 'admin_post_thumbnail_html', array(
|
32 |
|
33 |
// Register walker replacement
|
34 |
-
add_filter( 'wp_edit_nav_menu_walker', array(
|
35 |
|
36 |
// Register enqueuing of scripts
|
37 |
-
add_action( 'admin_menu', array(
|
38 |
|
39 |
// Register attachment fields display
|
40 |
-
add_filter( 'attachment_fields_to_edit', array(
|
41 |
|
42 |
// Register attachment fields handling
|
43 |
-
add_filter( 'attachment_fields_to_save', array(
|
44 |
}
|
45 |
|
46 |
/**
|
@@ -52,7 +52,7 @@ class Nav_Menu_Images_Admin extends Nav_Menu_Images {
|
|
52 |
* @uses add_action() To hook function.
|
53 |
*/
|
54 |
public function register_enqueuing() {
|
55 |
-
add_action( 'admin_print_scripts-nav-menus.php', array(
|
56 |
}
|
57 |
|
58 |
/**
|
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 |
// Register attachment fields display
|
40 |
+
add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 );
|
41 |
|
42 |
// Register attachment fields handling
|
43 |
+
add_filter( 'attachment_fields_to_save', array( $this, 'attachment_fields_to_save' ), 10, 2 );
|
44 |
}
|
45 |
|
46 |
/**
|
52 |
* @uses add_action() To hook function.
|
53 |
*/
|
54 |
public function register_enqueuing() {
|
55 |
+
add_action( 'admin_print_scripts-nav-menus.php', array( $this, 'enqueue_scripts' ) );
|
56 |
}
|
57 |
|
58 |
/**
|
inc/walker.php
CHANGED
@@ -43,13 +43,14 @@ class NMI_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
|
|
43 |
* @param string $output Passed by reference. Used to append additional content.
|
44 |
* @param object $item Menu item data object.
|
45 |
* @param int $depth Depth of menu item. Used for padding.
|
46 |
-
* @param
|
|
|
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 |
|
54 |
// Now add additional content
|
55 |
$item_id = $item->ID;
|
43 |
* @param string $output Passed by reference. Used to append additional content.
|
44 |
* @param object $item Menu item data object.
|
45 |
* @param int $depth Depth of menu item. Used for padding.
|
46 |
+
* @param array $args Not used.
|
47 |
+
* @param int $id Not used.
|
48 |
*/
|
49 |
+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
50 |
global $wp_version;
|
51 |
|
52 |
// First, make item with standard class
|
53 |
+
parent::start_el( $output, $item, $depth, $args, $id );
|
54 |
|
55 |
// Now add additional content
|
56 |
$item_id = $item->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.
|
19 |
* Text Domain: nmi
|
20 |
* Domain Path: /languages/
|
21 |
* License: GPL
|
@@ -59,7 +59,7 @@ class Nav_Menu_Images {
|
|
59 |
*/
|
60 |
public function __construct() {
|
61 |
// Register init
|
62 |
-
add_action( 'init', array(
|
63 |
|
64 |
// Get a basename
|
65 |
$this->plugin_basename = plugin_basename( __FILE__ );
|
@@ -91,12 +91,12 @@ class Nav_Menu_Images {
|
|
91 |
}
|
92 |
|
93 |
// Register AJAX handler
|
94 |
-
add_action( 'wp_ajax_nmi_added_thumbnail', array(
|
95 |
|
96 |
// Register menu item content filter if needed
|
97 |
if ( apply_filters( 'nmi_filter_menu_item_content', true ) ) {
|
98 |
-
add_filter( 'nav_menu_css_class', array(
|
99 |
-
add_filter( 'walker_nav_menu_start_el', array(
|
100 |
}
|
101 |
|
102 |
// Register plugins action links filter
|
@@ -265,18 +265,21 @@ class Nav_Menu_Images {
|
|
265 |
* @param object $args Item's arguments.
|
266 |
* @return array $item_classes Item's classes.
|
267 |
*/
|
268 |
-
public function register_menu_item_filter( $item_classes, $item, $args ) {
|
269 |
if ( has_post_thumbnail( $item->ID ) ) {
|
270 |
// Register filters
|
271 |
-
add_filter( 'the_title', array(
|
272 |
-
add_filter( 'wp_get_attachment_image_attributes', array(
|
273 |
-
add_filter( 'wp_get_attachment_image_attributes', array(
|
274 |
|
275 |
// Mark current item status
|
276 |
if ( in_array( 'current-menu-item', $item_classes ) )
|
277 |
$this->is_current_item = true;
|
278 |
else
|
279 |
$this->is_current_item = false;
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
return $item_classes;
|
@@ -295,9 +298,9 @@ class Nav_Menu_Images {
|
|
295 |
* @return string $item_output Item's content
|
296 |
*/
|
297 |
public function deregister_menu_item_filter( $item_output, $item ) {
|
298 |
-
remove_filter( 'the_title', array(
|
299 |
-
remove_filter( 'wp_get_attachment_image_attributes', array(
|
300 |
-
remove_filter( 'wp_get_attachment_image_attributes', array(
|
301 |
|
302 |
return $item_output;
|
303 |
}
|
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
|
59 |
*/
|
60 |
public function __construct() {
|
61 |
// Register init
|
62 |
+
add_action( 'init', array( $this, 'init' ) );
|
63 |
|
64 |
// Get a basename
|
65 |
$this->plugin_basename = plugin_basename( __FILE__ );
|
91 |
}
|
92 |
|
93 |
// Register AJAX handler
|
94 |
+
add_action( 'wp_ajax_nmi_added_thumbnail', array( $this, 'ajax_added_thumbnail' ) );
|
95 |
|
96 |
// Register menu item content filter if needed
|
97 |
if ( apply_filters( 'nmi_filter_menu_item_content', true ) ) {
|
98 |
+
add_filter( 'nav_menu_css_class', array( $this, 'register_menu_item_filter' ), 15, 3 );
|
99 |
+
add_filter( 'walker_nav_menu_start_el', array( $this, 'deregister_menu_item_filter' ), 15, 2 );
|
100 |
}
|
101 |
|
102 |
// Register plugins action links filter
|
265 |
* @param object $args Item's arguments.
|
266 |
* @return array $item_classes Item's classes.
|
267 |
*/
|
268 |
+
public function register_menu_item_filter( $item_classes, $item, $args = array() ) {
|
269 |
if ( has_post_thumbnail( $item->ID ) ) {
|
270 |
// Register filters
|
271 |
+
add_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
|
272 |
+
add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
|
273 |
+
add_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
|
274 |
|
275 |
// Mark current item status
|
276 |
if ( in_array( 'current-menu-item', $item_classes ) )
|
277 |
$this->is_current_item = true;
|
278 |
else
|
279 |
$this->is_current_item = false;
|
280 |
+
|
281 |
+
// Add 'has-image' class to the menu item
|
282 |
+
$item_classes[] = 'has-image';
|
283 |
}
|
284 |
|
285 |
return $item_classes;
|
298 |
* @return string $item_output Item's content
|
299 |
*/
|
300 |
public function deregister_menu_item_filter( $item_output, $item ) {
|
301 |
+
remove_filter( 'the_title', array( $this, 'menu_item_content' ), 15, 2 );
|
302 |
+
remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_hover' ), 15, 2 );
|
303 |
+
remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'menu_item_active' ), 15, 2 );
|
304 |
|
305 |
return $item_output;
|
306 |
}
|
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.
|
7 |
-
Stable tag: 3.
|
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.1 =
|
45 |
* Released on 12th August 2013
|
46 |
* Don't cache media frame and instead load new each time
|
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 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 3.2 =
|
45 |
+
* Released on 14 January 2014
|
46 |
+
* Fixed PHP notice in NMI_Walker_Nav_Menu_Edit::start_el()
|
47 |
+
* Don't pass class object by reference
|
48 |
+
* Maybe fixed issues with "Missing argument 3 for Nav_Menu_Images::register_menu_item_filter()" errors
|
49 |
+
* Add 'has-image' class to the menu item that has image
|
50 |
+
|
51 |
= 3.1 =
|
52 |
* Released on 12th August 2013
|
53 |
* Don't cache media frame and instead load new each time
|