updated plugin Menu Icons version 0.13.0

This commit is contained in:
2022-09-02 15:19:58 +00:00
committed by Gitium
parent 1ecbe8cf47
commit 1cd4e9a6d0
47 changed files with 413 additions and 9632 deletions

View File

@ -88,7 +88,7 @@ final class Menu_Icons_Front_End {
*/
self::$default_style = apply_filters( 'menu_icons_default_style', self::$default_style );
add_action( 'wp_enqueue_scripts', array( __CLASS__, '_enqueue_styles' ), 7 );
add_action( 'wp_enqueue_scripts', array( __CLASS__, '_enqueue_styles' ), 4 );
add_filter( 'wp_nav_menu_args', array( __CLASS__, '_add_menu_item_title_filter' ) );
add_filter( 'wp_nav_menu', array( __CLASS__, '_remove_menu_item_title_filter' ) );
}
@ -147,6 +147,7 @@ final class Menu_Icons_Front_End {
$registered = $wp_styles->registered['font-awesome'];
if ( strpos( $registered->src, Menu_Icons::get( 'url' ) ) !== false ) {
$wp_styles->remove( 'font-awesome' );
$registered->ver = Menu_Icons_Font_Awesome::$version;
$wp_styles->add( 'menu-icon-' . $registered->handle, $registered->src, $registered->deps, $registered->ver, $registered->args );
}
}
@ -400,7 +401,7 @@ final class Menu_Icons_Front_End {
$type = $meta['type'];
$icon = $meta['icon'];
$font_awesome5 = font_awesome5_backward_compatible();
$font_awesome5 = font_awesome_backward_compatible();
if ( ! empty( $type ) && 'fa' === $type ) {
$icon = explode( ' ', $icon );
$type = reset( $icon );

View File

@ -6,15 +6,15 @@
*/
// phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned
if ( ! function_exists( 'font_awesome5_backward_compatible' ) ) {
if ( ! function_exists( 'font_awesome_backward_compatible' ) ) {
/**
* Font awesome 5 backward compatible.
*
* @return array
*/
function font_awesome5_backward_compatible() {
$font_awesome5_icon = array(
function font_awesome_backward_compatible() {
$font_awesome_icon = array(
'fa-fa-500px' => 'fab fa-500px',
'fa-fa-address-book-o' => 'far fa-address-book',
'fa-fa-address-card-o' => 'far fa-address-card',
@ -477,8 +477,8 @@ if ( ! function_exists( 'font_awesome5_backward_compatible' ) ) {
'fa-fa-youtube' => 'fab fa-youtube',
'fa-fa-fa' => 'fab fa-font-awesome',
);
$font_awesome5_icon = apply_filters( 'menu_icons_backward_compatibility_icons', $font_awesome5_icon );
$font_awesome_icon = apply_filters( 'menu_icons_backward_compatibility_icons', $font_awesome_icon );
return $font_awesome5_icon;
return $font_awesome_icon;
}
}

View File

@ -6,6 +6,14 @@
*/
final class Menu_Icons_Font_Awesome {
/**
* Font Awesome version
*
* @access static
* @var string
*/
public static $version = '5.15.4';
/**
* Init hooks.
*/
@ -55,11 +63,11 @@ final class Menu_Icons_Font_Awesome {
$icons = array_values( $icons );
}
$font_awesome5 = font_awesome5_backward_compatible();
$font_awesome = font_awesome_backward_compatible();
foreach ( $icons as $key => $icon ) {
$old_fa_icon = sprintf( 'fa-%s', $icons[ $key ]['id'] );
if ( array_key_exists( $old_fa_icon, $font_awesome5 ) ) {
$icons[ $key ]['id'] = trim( $font_awesome5[ $old_fa_icon ] );
if ( array_key_exists( $old_fa_icon, $font_awesome ) ) {
$icons[ $key ]['id'] = trim( $font_awesome[ $old_fa_icon ] );
} else {
$icons[ $key ]['id'] = sprintf( 'fa %s', trim( $icons[ $key ]['id'] ) );
}

View File

@ -75,7 +75,7 @@ final class Menu_Icons_Meta {
}
}
$font_awesome5 = font_awesome5_backward_compatible();
$font_awesome5 = font_awesome_backward_compatible();
$icon = ! empty( $value['icon'] ) ? $value['icon'] : '';
$icon = explode( ' ', $icon );
$icon = sprintf( '%s-%s', reset( $icon ), end( $icon ) );

View File

@ -57,7 +57,7 @@ final class Menu_Icons_Picker {
*/
protected static function _get_menu_item_fields( $meta ) {
$fa_icon = sprintf( '%s-%s', $meta['type'], $meta['icon'] );
$font_awesome5 = font_awesome5_backward_compatible();
$font_awesome5 = font_awesome_backward_compatible();
if ( array_key_exists( $fa_icon, $font_awesome5 ) ) {
$fa5_icon = $font_awesome5[ $fa_icon ];

View File

@ -467,7 +467,7 @@ final class Menu_Icons_Settings {
array(
'id' => 'fa5_extra_icons',
'type' => 'textarea',
'label' => __( 'FA5 Custom Icon Classes', 'menu-icons' ),
'label' => __( 'FA Custom Icon Classes', 'menu-icons' ),
'value' => self::get( 'global', 'fa5_extra_icons' ),
'help_text' => '( comma separated icons )',
),