Menu Image - Version 2.9.5

Version Description

Download this release

Release Info

Developer takanakui
Plugin Icon 128x128 Menu Image
Version 2.9.5
Comparing to
See all releases

Code changes from version 2.9.4 to 2.9.5

Files changed (3) hide show
  1. includes/css/menu-image.css +19 -15
  2. menu-image.php +14 -23
  3. readme.txt +5 -1
includes/css/menu-image.css CHANGED
@@ -1,43 +1,47 @@
1
- .menu-item a img, img.menu-image-title-after, img.menu-image-title-before, img.menu-image-title-above, img.menu-image-title-below {
2
  border: none;
3
  box-shadow: none;
4
  vertical-align: middle;
5
  width: auto;
6
  display: inline;
7
  }
8
- a.menu-image-hovered img.hovered-image,
9
- a.menu-image-hovered:hover img.menu-image {
10
  opacity: 0;
11
  transition: opacity 0.25s ease-in-out 0s;
12
  }
13
- a.menu-image-hovered:hover img.hovered-image {
14
  opacity: 1;
15
  }
16
- a.menu-image-title-after.menu-image-not-hovered img,
17
- a.menu-image-hovered.menu-image-title-after .menu-image-hover-wrapper {
18
  padding-right: 10px;
19
  }
20
- a.menu-image-title-before.menu-image-not-hovered img,
21
- a.menu-image-hovered.menu-image-title-before .menu-image-hover-wrapper {
22
  padding-left: 10px;
23
  }
24
- a.menu-image-title-above,
25
- a.menu-image-title-below {
26
  text-align: center;
27
  display: block;
28
  }
29
- a.menu-image-title-above.menu-image-not-hovered img,
30
- a.menu-image-hovered.menu-image-title-above .menu-image-hover-wrapper {
31
  display: block;
32
  padding-top: 10px;
33
  margin: 0 auto !important;
34
  }
35
- a.menu-image-title-below.menu-image-not-hovered img,
36
- a.menu-image-hovered.menu-image-title-below .menu-image-hover-wrapper {
37
  display: block;
38
  padding-bottom: 10px;
39
  margin: 0 auto !important;
40
  }
41
- a.menu-image-title-hide .menu-image-title {
42
  display: none;
43
  }
 
 
 
 
1
+ .menu-item a img, img.menu-image-title-after, img.menu-image-title-before, img.menu-image-title-above, img.menu-image-title-below , .menu-image-hover-wrapper .menu-image-title-above {
2
  border: none;
3
  box-shadow: none;
4
  vertical-align: middle;
5
  width: auto;
6
  display: inline;
7
  }
8
+ .menu-image-hover-wrapper img.hovered-image,
9
+ .menu-item:hover .menu-image-hover-wrapper img.menu-image {
10
  opacity: 0;
11
  transition: opacity 0.25s ease-in-out 0s;
12
  }
13
+ .menu-item:hover img.hovered-image {
14
  opacity: 1;
15
  }
16
+ .menu-image-title-after.menu-image-not-hovered img,
17
+ .menu-image-hovered.menu-image-title-after .menu-image-hover-wrapper, .menu-image-title-before.menu-image-title {
18
  padding-right: 10px;
19
  }
20
+ .menu-image-title-before.menu-image-not-hovered img,
21
+ .menu-image-hovered.menu-image-title-before .menu-image-hover-wrapper, .menu-image-title-after.menu-image-title {
22
  padding-left: 10px;
23
  }
24
+
25
+ .menu-image-title.menu-image-title-above, .menu-image-title.menu-image-title-below {
26
  text-align: center;
27
  display: block;
28
  }
29
+ .menu-image-title-above.menu-image-not-hovered > img,
30
+ .menu-image-hovered.menu-image-title-above .menu-image-hover-wrapper, .menu-image-title-above .menu-image-hover-wrapper {
31
  display: block;
32
  padding-top: 10px;
33
  margin: 0 auto !important;
34
  }
35
+ .menu-image-title-below.menu-image-not-hovered > img,
36
+ .menu-image-hovered.menu-image-title-below .menu-image-hover-wrapper, .menu-image-title-below .menu-image-hover-wrapper {
37
  display: block;
38
  padding-bottom: 10px;
39
  margin: 0 auto !important;
40
  }
41
+ .menu-image-title-hide .menu-image-title, .menu-image-title-hide.menu-image-title {
42
  display: none;
43
  }
44
+ /* Alignment of the Menu items. Divi, Twenty 17*/
45
+ #et-top-navigation .nav li.menu-item, .navigation-top .main-navigation li {
46
+ display: inline-flex;
47
+ }
menu-image.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package Menu_Image
4
- * @version 2.9.4
5
  * @licence GPLv2
6
  */
7
 
@@ -10,7 +10,7 @@ Plugin Name: Menu Image
10
  Plugin URI: https://www.jedipress.com
11
  Description: Improve your navigation menu items with images, logos, icons, buttons.
12
  Author: Rui Guerreiro
13
- Version: 2.9.4
14
  Author URI: https://www.jedipress.com
15
  */
16
 
@@ -113,6 +113,7 @@ class Menu_Image_Plugin {
113
  add_filter( 'nav_menu_link_attributes', array( $this, 'menu_image_nav_menu_link_attributes_filter' ), 10, 4 );
114
  add_filter( 'manage_nav-menus_columns', array( $this, 'menu_image_nav_menu_manage_columns' ), 11 );
115
  add_filter( 'nav_menu_item_title', array( $this, 'menu_image_nav_menu_item_title_filter' ), 10, 4 );
 
116
 
117
  // Add support for additional image types.
118
  add_filter( 'file_is_displayable_image', array( $this, 'file_is_displayable_image' ), 10, 2 );
@@ -314,7 +315,7 @@ class Menu_Image_Plugin {
314
  * Initialization action.
315
  *
316
  * Adding image sizes for most popular menu icon sizes. Adding thumbnail
317
- * support to menu post type.
318
  */
319
  public function menu_image_init() {
320
  add_post_type_support( 'nav_menu_item', array( 'thumbnail' ) );
@@ -327,18 +328,6 @@ class Menu_Image_Plugin {
327
  }
328
  load_plugin_textdomain( 'menu-image', false, basename( dirname( __FILE__ ) ) . '/languages' );
329
 
330
- if ( ! is_admin() ) {
331
-
332
- global $wp_filter;
333
-
334
- $menu_filters_count = ( is_array($wp_filter['wp_nav_menu_args'] ) ? count( $wp_filter['wp_nav_menu_args'] ) : 0 );
335
-
336
- if ( isset( $wp_filter['wp_nav_menu_args'] ) && 0 === $menu_filters_count ) {
337
- add_filter( 'walker_nav_menu_start_el', array( $this, 'menu_image_nav_menu_item_filter' ), 10, 4 );
338
- } else {
339
- add_filter( 'the_title', array( $this, 'menu_image_nav_menu_item_title_filter' ), 10, 4 );
340
- }
341
- }
342
  }
343
 
344
  /**
@@ -518,7 +507,7 @@ class Menu_Image_Plugin {
518
  */
519
  public function menu_image_nav_menu_item_title_filter( $title, $item = null, $depth = null, $args = null ) {
520
 
521
- if ( ! is_nav_menu_item( $item ) || ! isset( $item ) || strpos( $title, 'menu-image' ) > 0 ) {
522
  return $title;
523
  }
524
 
@@ -532,6 +521,7 @@ class Menu_Image_Plugin {
532
 
533
  // Process only if there is an menu image associated with the menu item.
534
  if ( '' !== $item->thumbnail_id ) {
 
535
  $image_size = $item->image_size ? $item->image_size : apply_filters( 'menu_image_default_size', 'menu-36x36' );
536
  $position = $item->title_position ? $item->title_position : apply_filters( 'menu_image_default_title_position', 'after' );
537
  $class = "menu-image-title-{$position}";
@@ -553,28 +543,29 @@ class Menu_Image_Plugin {
553
  } elseif ( $item->thumbnail_id ) {
554
  $image = wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
555
  }
556
- $none = ''; // Sugar.
557
  $image = apply_filters( 'menu_image_img_html', $image );
 
558
 
559
  switch ( $position ) {
560
  case 'hide':
561
  case 'before':
562
  case 'above':
563
- $item_args = array( $none, $title, $image );
564
  break;
565
  case 'after':
566
  default:
567
- $item_args = array( $image, $title, $none );
568
  break;
569
  }
570
- $title = vsprintf( '%s<span class="menu-image-title">%s</span>%s', $item_args );
 
571
 
572
  }
573
 
574
  return $title;
575
  }
576
 
577
-
578
  /**
579
  * Replacement default menu item output.
580
  *
@@ -665,7 +656,7 @@ class Menu_Image_Plugin {
665
  * Loading custom stylesheet to fix images positioning in match themes
666
  */
667
  public function menu_image_add_inline_style_action() {
668
- wp_register_style( 'menu-image', plugins_url( '', __FILE__ ) . '/includes/css/menu-image.css', array(), '2.9.4' );
669
  wp_enqueue_style( 'menu-image' );
670
  }
671
 
@@ -675,7 +666,7 @@ class Menu_Image_Plugin {
675
  * @since 2.0
676
  */
677
  public function menu_image_admin_head_nav_menus_action() {
678
- wp_enqueue_script( 'menu-image-admin', plugins_url( '/includes/js/menu-image-admin.js', __FILE__ ), array( 'jquery' ), '2.9.4' );
679
  wp_localize_script(
680
  'menu-image-admin', 'menuImage', array(
681
  'l10n' => array(
1
  <?php
2
  /**
3
  * @package Menu_Image
4
+ * @version 2.9.5
5
  * @licence GPLv2
6
  */
7
 
10
  Plugin URI: https://www.jedipress.com
11
  Description: Improve your navigation menu items with images, logos, icons, buttons.
12
  Author: Rui Guerreiro
13
+ Version: 2.9.5
14
  Author URI: https://www.jedipress.com
15
  */
16
 
113
  add_filter( 'nav_menu_link_attributes', array( $this, 'menu_image_nav_menu_link_attributes_filter' ), 10, 4 );
114
  add_filter( 'manage_nav-menus_columns', array( $this, 'menu_image_nav_menu_manage_columns' ), 11 );
115
  add_filter( 'nav_menu_item_title', array( $this, 'menu_image_nav_menu_item_title_filter' ), 10, 4 );
116
+ add_filter( 'the_title', array( $this, 'menu_image_nav_menu_item_title_filter' ), 10, 4 );
117
 
118
  // Add support for additional image types.
119
  add_filter( 'file_is_displayable_image', array( $this, 'file_is_displayable_image' ), 10, 2 );
315
  * Initialization action.
316
  *
317
  * Adding image sizes for most popular menu icon sizes. Adding thumbnail
318
+ * support to menu post type.
319
  */
320
  public function menu_image_init() {
321
  add_post_type_support( 'nav_menu_item', array( 'thumbnail' ) );
328
  }
329
  load_plugin_textdomain( 'menu-image', false, basename( dirname( __FILE__ ) ) . '/languages' );
330
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
 
333
  /**
507
  */
508
  public function menu_image_nav_menu_item_title_filter( $title, $item = null, $depth = null, $args = null ) {
509
 
510
+ if ( strpos( $title, 'menu-image' ) > 0 || ! is_nav_menu_item( $item ) || ! isset( $item ) ) {
511
  return $title;
512
  }
513
 
521
 
522
  // Process only if there is an menu image associated with the menu item.
523
  if ( '' !== $item->thumbnail_id ) {
524
+
525
  $image_size = $item->image_size ? $item->image_size : apply_filters( 'menu_image_default_size', 'menu-36x36' );
526
  $position = $item->title_position ? $item->title_position : apply_filters( 'menu_image_default_title_position', 'after' );
527
  $class = "menu-image-title-{$position}";
543
  } elseif ( $item->thumbnail_id ) {
544
  $image = wp_get_attachment_image( $item->thumbnail_id, $image_size, false, "class=menu-image {$class}" );
545
  }
546
+ $none = ''; // Sugar.
547
  $image = apply_filters( 'menu_image_img_html', $image );
548
+ $class .= ' menu-image-title';
549
 
550
  switch ( $position ) {
551
  case 'hide':
552
  case 'before':
553
  case 'above':
554
+ $item_args = array( $none, $class, $title, $image );
555
  break;
556
  case 'after':
557
  default:
558
+ $item_args = array( $image, $class, $title, $none );
559
  break;
560
  }
561
+
562
+ $title = vsprintf( '%s<span class="%s">%s</span>%s', $item_args );
563
 
564
  }
565
 
566
  return $title;
567
  }
568
 
 
569
  /**
570
  * Replacement default menu item output.
571
  *
656
  * Loading custom stylesheet to fix images positioning in match themes
657
  */
658
  public function menu_image_add_inline_style_action() {
659
+ wp_register_style( 'menu-image', plugins_url( '', __FILE__ ) . '/includes/css/menu-image.css', array(), '2.9.5' );
660
  wp_enqueue_style( 'menu-image' );
661
  }
662
 
666
  * @since 2.0
667
  */
668
  public function menu_image_admin_head_nav_menus_action() {
669
+ wp_enqueue_script( 'menu-image-admin', plugins_url( '/includes/js/menu-image-admin.js', __FILE__ ), array( 'jquery' ), '2.9.5' );
670
  wp_localize_script(
671
  'menu-image-admin', 'menuImage', array(
672
  'l10n' => array(
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: menu, navigation, image, icons, nav menu
4
  Donate link: https://www.buymeacoffee.com/ruiguerreiro
5
  Requires at least: 4.4.0
6
  Tested up to: 5.2
7
- Stable tag: 2.9.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -109,6 +109,10 @@ add_filter( 'wp_calculate_image_srcset', '__return_false' );
109
 
110
  == Changelog ==
111
 
 
 
 
 
112
  ### 2.9.4 ###
113
  * Fix - Bug of the duplicated images.
114
 
4
  Donate link: https://www.buymeacoffee.com/ruiguerreiro
5
  Requires at least: 4.4.0
6
  Tested up to: 5.2
7
+ Stable tag: 2.9.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
109
 
110
  == Changelog ==
111
 
112
+ ### 2.9.5 ###
113
+ * Fix - Remove unnecessary filter.
114
+ * Fix - Adjust the CSS for title below.
115
+
116
  ### 2.9.4 ###
117
  * Fix - Bug of the duplicated images.
118