updated plugin Menu Icons
version 0.12.12
This commit is contained in:
@ -141,9 +141,23 @@ final class Menu_Icons_Front_End {
|
||||
* @link http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
|
||||
*/
|
||||
public static function _enqueue_styles() {
|
||||
// Deregister icon picker plugin font-awesome style and re-register with the new handler to avoid other plugin/theme style handler conflict.
|
||||
$wp_styles = wp_styles();
|
||||
if ( $wp_styles && isset( $wp_styles->registered['font-awesome'] ) ) {
|
||||
$registered = $wp_styles->registered['font-awesome'];
|
||||
if ( strpos( $registered->src, Menu_Icons::get( 'url' ) ) !== false ) {
|
||||
$wp_styles->remove( 'font-awesome' );
|
||||
$wp_styles->add( 'menu-icon-' . $registered->handle, $registered->src, $registered->deps, $registered->ver, $registered->args );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( self::$icon_types as $type ) {
|
||||
if ( wp_style_is( $type->stylesheet_id, 'registered' ) ) {
|
||||
wp_enqueue_style( $type->stylesheet_id );
|
||||
$stylesheet_id = $type->stylesheet_id;
|
||||
if ( 'font-awesome' === $stylesheet_id ) {
|
||||
$stylesheet_id = 'menu-icon-' . $stylesheet_id;
|
||||
}
|
||||
if ( wp_style_is( $stylesheet_id, 'registered' ) ) {
|
||||
wp_enqueue_style( $stylesheet_id );
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,6 +195,8 @@ final class Menu_Icons_Front_End {
|
||||
*/
|
||||
public static function _add_menu_item_title_filter( $args ) {
|
||||
add_filter( 'the_title', array( __CLASS__, '_add_icon' ), 999, 2 );
|
||||
add_filter( 'megamenu_the_title', array( __CLASS__, '_add_icon' ), 999, 2 );
|
||||
add_filter( 'megamenu_nav_menu_css_class', array( __CLASS__, '_add_menu_item_class' ), 10, 3 );
|
||||
|
||||
return $args;
|
||||
}
|
||||
@ -199,7 +215,8 @@ final class Menu_Icons_Front_End {
|
||||
*/
|
||||
public static function _remove_menu_item_title_filter( $nav_menu ) {
|
||||
remove_filter( 'the_title', array( __CLASS__, '_add_icon' ), 999, 2 );
|
||||
|
||||
remove_filter( 'megamenu_the_title', array( __CLASS__, '_add_icon' ), 999, 2 );
|
||||
remove_filter( 'megamenu_nav_menu_css_class', array( __CLASS__, '_add_menu_item_class' ), 10, 3 );
|
||||
return $nav_menu;
|
||||
}
|
||||
|
||||
@ -480,4 +497,17 @@ final class Menu_Icons_Front_End {
|
||||
$style
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item class in `Max Mega Menu` item.
|
||||
*
|
||||
* @param array $classes Item classes.
|
||||
* @param array $item WP menu item.
|
||||
* @param object $args Menu object.
|
||||
* @return array
|
||||
*/
|
||||
public static function _add_menu_item_class( $classes, $item, $args ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
|
||||
$classes[] = 'menu-item';
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user