updated plugin Menu Icons version 0.12.8

This commit is contained in:
2021-07-25 23:25:06 +00:00
committed by Gitium
parent 3ef36355e9
commit a2480e23b7
63 changed files with 1153 additions and 1499 deletions

View File

@ -420,10 +420,45 @@ final class Menu_Icons_Front_End {
$classes = sprintf( '%s _svg', self::get_icon_classes( $meta ) );
$style = self::get_icon_style( $meta, array( 'svg_width', 'vertical_align' ) );
$svg_icon = esc_url( wp_get_attachment_url( $meta['icon'] ) );
$width = '';
$height = '';
if ( 'image/svg+xml' === get_post_mime_type( $meta['icon'] ) ) {
// Check `WP_Filesystem` function exists OR not.
require_once ABSPATH . '/wp-admin/includes/file.php';
\WP_Filesystem();
global $wp_filesystem;
$svg_icon = get_attached_file( $meta['icon'] );
$svg_icon_content = $wp_filesystem->get_contents( $svg_icon );
if ( $svg_icon_content ) {
$xmlget = simplexml_load_string( $svg_icon_content );
$xmlattributes = $xmlget->attributes();
$width = (string) $xmlattributes->width;
$width = (int) filter_var( $xmlattributes->width, FILTER_SANITIZE_NUMBER_INT );
$height = (string) $xmlattributes->height;
$height = (int) filter_var( $xmlattributes->height, FILTER_SANITIZE_NUMBER_INT );
}
} else {
$attachment_meta = wp_get_attachment_metadata( $meta['icon'] );
if ( $attachment_meta ) {
$width = isset( $attachment_meta['width'] ) ? $attachment_meta['width'] : $width;
$height = isset( $attachment_meta['height'] ) ? $attachment_meta['height'] : $height;
}
}
if ( ! empty( $width ) ) {
$width = sprintf( ' width="%dpx"', $width );
}
if ( ! empty( $height ) ) {
$height = sprintf( ' height="%dpx"', $height );
}
return sprintf(
'<img src="%s" class="%s" aria-hidden="true"%s />',
'<img src="%s" class="%s" aria-hidden="true"%s%s%s/>',
esc_url( wp_get_attachment_url( $meta['icon'] ) ),
esc_attr( $classes ),
$width,
$height,
$style
);
}

View File

@ -186,9 +186,9 @@ final class Menu_Icons_Picker {
return;
}
if( ! function_exists( 'get_current_screen' ) ) {
return;
}
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$screen = get_current_screen();
if ( ! $screen instanceof WP_Screen || 'nav-menus' !== $screen->id ) {