Max Mega Menu - Version 3.0

Version Description

  • New feature: Add Gutenberg Block. Restores the Appearance > Menus page for FSE (Full Site Editing) themes and adds a new Max Mega Menu block to display a menu location.
  • New feature: Add Reusable Block widget. Allows block content to be saved as a Reusable Block and displayed within sub menus.
Download this release

Release Info

Developer megamenu
Plugin Icon 128x128 Max Mega Menu
Version 3.0
Comparing to
See all releases

Code changes from version 2.9.9 to 3.0

classes/admin-notices.class.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Credit to PolyLang (https://polylang.pro)
4
+ * https://plugins.trac.wordpress.org/browser/polylang/trunk/admin/admin-notices.php
5
+ */
6
+
7
+ /**
8
+ * A class to manage admin notices
9
+ * displayed only to admin, based on 'manage_options' capability
10
+ * and only on dashboard, plugins and Max Mega Menu admin pages
11
+ *
12
+ */
13
+ class Mega_Menu_Admin_Notices {
14
+ /**
15
+ * Stores the plugin options.
16
+ *
17
+ * @var array
18
+ */
19
+ protected $options;
20
+
21
+ /**
22
+ * Stores custom notices.
23
+ *
24
+ * @var string[]
25
+ */
26
+ private static $notices = array();
27
+
28
+ /**
29
+ * Constructor
30
+ * Setup actions
31
+ *
32
+ * @since 3.0
33
+ *
34
+ * @param object $polylang
35
+ */
36
+ public function __construct() {
37
+ add_action( 'admin_init', array( $this, 'hide_notice' ) );
38
+ add_action( 'admin_notices', array( $this, 'display_notices' ) );
39
+ }
40
+
41
+ /**
42
+ * Add a custom notice
43
+ *
44
+ * @since 3.0
45
+ *
46
+ * @param string $name Notice name
47
+ * @param string $html Content of the notice
48
+ * @return void
49
+ */
50
+ public static function add_notice( $name, $html ) {
51
+ self::$notices[ $name ] = $html;
52
+ }
53
+
54
+ /**
55
+ * Get custom notices
56
+ *
57
+ * @since 3.0
58
+ *
59
+ * @return string[]
60
+ */
61
+ public static function get_notices() {
62
+ return self::$notices;
63
+ }
64
+
65
+ /**
66
+ * Has a notice been dismissed?
67
+ *
68
+ * @since 3.0
69
+ *
70
+ * @param string $notice Notice name
71
+ * @return bool
72
+ */
73
+ public static function is_dismissed( $notice ) {
74
+ $dismissed = get_option( 'megamenu_dismissed_notices', array() );
75
+
76
+ return in_array( $notice, $dismissed );
77
+ }
78
+
79
+ /**
80
+ * Should we display notices on this screen?
81
+ *
82
+ * @since 3.0
83
+ *
84
+ * @param string $notice The notice name.
85
+ * @return bool
86
+ */
87
+ protected function can_display_notice( $notice ) {
88
+ $screen = get_current_screen();
89
+
90
+ if ( empty( $screen ) ) {
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Filter admin notices which can be displayed
96
+ *
97
+ * @since 2.7.0
98
+ *
99
+ * @param bool $display Whether the notice should be displayed or not.
100
+ * @param string $notice The notice name.
101
+ */
102
+ return apply_filters(
103
+ 'mmm_can_display_notice',
104
+ in_array(
105
+ $screen->id,
106
+ array(
107
+ 'dashboard',
108
+ 'plugins',
109
+ 'toplevel_page_maxmegamenu'
110
+ )
111
+ ),
112
+ $notice
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Stores a dismissed notice in database
118
+ *
119
+ * @since 3.0
120
+ *
121
+ * @param string $notice
122
+ * @return void
123
+ */
124
+ public static function dismiss( $notice ) {
125
+ $dismissed = get_option( 'megamenu_dismissed_notices', array() );
126
+
127
+ if ( ! in_array( $notice, $dismissed ) ) {
128
+ $dismissed[] = $notice;
129
+ update_option( 'megamenu_dismissed_notices', array_unique( $dismissed ) );
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Handle a click on the dismiss button
135
+ *
136
+ * @since 3.0
137
+ *
138
+ * @return void
139
+ */
140
+ public function hide_notice() {
141
+ if ( isset( $_GET['mmm-hide-notice'], $_GET['_mmm_notice_nonce'] ) ) {
142
+ $notice = sanitize_key( $_GET['mmm-hide-notice'] );
143
+ check_admin_referer( $notice, '_mmm_notice_nonce' );
144
+ self::dismiss( $notice );
145
+ wp_safe_redirect( remove_query_arg( array( 'mmm-hide-notice', '_mmm_notice_nonce' ), wp_get_referer() ) );
146
+ exit;
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Displays notices
152
+ *
153
+ * @since 2.3.9
154
+ *
155
+ * @return void
156
+ */
157
+ public function display_notices() {
158
+
159
+ if ( ! $this->can_display_notice( 'review' ) ) {
160
+ return;
161
+ }
162
+
163
+ if ( defined( 'MEGAMENU_PRO_VERSION' ) ) {
164
+ return;
165
+ }
166
+
167
+ if ( $this->is_dismissed( 'review' ) ) {
168
+ return;
169
+ }
170
+
171
+ if ( ! current_user_can( 'manage_options' ) ) {
172
+ return;
173
+ }
174
+
175
+ $install_date = get_option( 'megamenu_install_date' );
176
+
177
+ if ( ! $install_date ) {
178
+ return;
179
+ }
180
+
181
+ if ( time() > $install_date + ( 14 * DAY_IN_SECONDS ) ) {
182
+ $this->review_notice();
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Displays a dismiss button
188
+ *
189
+ * @since 3.0
190
+ *
191
+ * @param string $name Notice name
192
+ * @return void
193
+ */
194
+ public function dismiss_button( $name ) {
195
+ printf(
196
+ '<a style="text-decoration: none;" class="notice-dismiss" href="%s"><span class="screen-reader-text">%s</span></a>',
197
+ esc_url( wp_nonce_url( add_query_arg( 'mmm-hide-notice', $name ), $name, '_mmm_notice_nonce' ) ),
198
+ /* translators: accessibility text */
199
+ esc_html__( 'Dismiss this notice.', 'megamenu' )
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Displays a notice asking for a review
205
+ *
206
+ * @since 3.0
207
+ *
208
+ * @return void
209
+ */
210
+ private function review_notice() {
211
+ ?>
212
+ <div class="mmm-notice notice notice-info" style="position: relative; margin-left: 0;">
213
+ <?php $this->dismiss_button( 'review' ); ?>
214
+ <p>
215
+ <?php
216
+ printf(
217
+ /* translators: %1$s is link start tag, %2$s is link end tag. */
218
+ esc_html__( 'We have noticed that you have been using Max Mega Menu for some time. We hope you love it, and we would really appreciate it if you would %1$sgive us a 5 stars rating%2$s.', 'megamenu' ),
219
+ '<a href="https://wordpress.org/support/plugin/megamenu/reviews/?rate=5#new-post">',
220
+ '</a>'
221
+ );
222
+ ?>
223
+ </p>
224
+ </div>
225
+ <?php
226
+ }
227
+ }
classes/pages/tools.php CHANGED
@@ -68,6 +68,8 @@ if ( ! class_exists( 'Mega_Menu_Tools' ) ) :
68
  delete_option( 'megamenu_initial_version' );
69
  delete_option( 'megamenu_themes_last_updated' );
70
  delete_option( 'megamenu_multisite_share_themes' );
 
 
71
 
72
  // delete all widgets assigned to menus
73
  $widget_manager = new Mega_Menu_Widget_Manager();
68
  delete_option( 'megamenu_initial_version' );
69
  delete_option( 'megamenu_themes_last_updated' );
70
  delete_option( 'megamenu_multisite_share_themes' );
71
+ delete_option( 'megamenu_dismissed_notices' );
72
+ delete_option( 'megamenu_install_date' );
73
 
74
  // delete all widgets assigned to menus
75
  $widget_manager = new Mega_Menu_Widget_Manager();
classes/widgets/widget-reusable-block.class.php CHANGED
@@ -19,7 +19,7 @@ if ( ! class_exists( 'Mega_Menu_Widget_Reusable_Block' ) ) :
19
  public function __construct() {
20
  parent::__construct(
21
  'maxmegamenu_reusable_block', // Base ID
22
- 'Reusable Block', // Name
23
  array( 'description' => __( 'Outputs a reusable block.', 'megamenu' ) ) // Args
24
  );
25
  }
@@ -94,17 +94,17 @@ if ( ! class_exists( 'Mega_Menu_Widget_Reusable_Block' ) ) :
94
 
95
  // Input field with id is required for WordPress to display the title in the widget header.
96
  ?>
97
- <input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
98
 
99
- <p>
100
- <label for="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>"><?php esc_attr_e( 'Block', 'megamenu' ); ?>:</label>
101
- <select id="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>" class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'block' ) ); ?>">
102
- <option value=""><?php esc_html_e( '- Select -', 'megamenu' ); ?></option>
103
- <?php foreach ( $posts as $post ) : ?>
104
- <option value="<?php echo esc_attr( $post->ID ); ?>"<?php selected( $post->ID, $block_id ); ?>><?php echo esc_html( $post->post_title ); ?></option>
105
- <?php endforeach; ?>
106
- </select>
107
- </p>
108
 
109
  <?php
110
  }
19
  public function __construct() {
20
  parent::__construct(
21
  'maxmegamenu_reusable_block', // Base ID
22
+ 'Reusable Block (MMM)', // Name
23
  array( 'description' => __( 'Outputs a reusable block.', 'megamenu' ) ) // Args
24
  );
25
  }
94
 
95
  // Input field with id is required for WordPress to display the title in the widget header.
96
  ?>
97
+ <input type="hidden" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $widget_title ); ?>">
98
 
99
+ <p>
100
+ <label for="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>"><?php esc_attr_e( 'Block', 'megamenu' ); ?>:</label>
101
+ <select id="<?php echo esc_attr( $this->get_field_id( 'block' ) ); ?>" class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'block' ) ); ?>">
102
+ <option value=""><?php esc_html_e( '- Select -', 'megamenu' ); ?></option>
103
+ <?php foreach ( $posts as $post ) : ?>
104
+ <option value="<?php echo esc_attr( $post->ID ); ?>"<?php selected( $post->ID, $block_id ); ?>><?php echo esc_html( $post->post_title ); ?></option>
105
+ <?php endforeach; ?>
106
+ </select>
107
+ </p>
108
 
109
  <?php
110
  }
megamenu.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Max Mega Menu
4
  * Plugin URI: https://www.megamenu.com
5
  * Description: An easy to use mega menu plugin. Written the WordPress way.
6
- * Version: 2.9.9
7
  * Author: megamenu.com
8
  * Author URI: https://www.megamenu.com
9
  * License: GPL-2.0+
@@ -35,7 +35,7 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
35
  *
36
  * @var string
37
  */
38
- public $version = '2.9.9';
39
 
40
 
41
  /**
@@ -111,6 +111,7 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
111
  'Mega_Menu_Locations',
112
  'Mega_Menu_Themes',
113
  'Mega_Menu_Tools',
 
114
  );
115
 
116
  foreach ( $admin_classes as $class ) {
@@ -231,7 +232,7 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
231
  * Load TinyMCE assets on nav-menus.php page.
232
  *
233
  * @since 1.8
234
- . * @param array $pages Pages to load tinymce scripts on
235
  * @return array $pages
236
  */
237
  public function megamenu_blackstudio_tinymce( $pages ) {
@@ -247,18 +248,18 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
247
  */
248
  public function install_upgrade_check() {
249
  $version = get_option( 'megamenu_version' );
 
250
 
251
- if ( $version ) {
 
 
252
 
 
253
  if ( version_compare( $this->version, $version, '!=' ) ) {
254
-
255
  update_option( 'megamenu_version', $this->version );
256
-
257
  do_action( 'megamenu_after_update' );
258
-
259
  }
260
  } else {
261
-
262
  add_option( 'megamenu_version', $this->version );
263
  add_option( 'megamenu_initial_version', $this->version );
264
  add_option( 'megamenu_multisite_share_themes', 'false' );
@@ -288,7 +289,10 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
288
  if ( class_exists( 'Mega_Menu_Widget' ) ) {
289
  register_widget( 'Mega_Menu_Widget' );
290
  }
291
- //register_widget( 'Mega_Menu_Widget_Reusable_Block' );
 
 
 
292
 
293
  // Check if Elementor installed and activated
294
  //if ( did_action( 'elementor/loaded' ) ) {
@@ -296,7 +300,6 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
296
  //}
297
  }
298
 
299
-
300
  /**
301
  * Create our own widget area to store all mega menu widgets.
302
  * All widgets from all menus are stored here, they are filtered later
@@ -385,6 +388,7 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
385
  'Mega_Menu_Widget_Reusable_Block' => MEGAMENU_PATH . 'classes/widgets/widget-reusable-block.class.php',
386
  'Mega_Menu_Widget_Elementor_Template' => MEGAMENU_PATH . 'classes/widgets/widget-elementor-template.class.php',
387
  'Mega_Menu_toggle_Blocks' => MEGAMENU_PATH . 'classes/toggle-blocks.class.php',
 
388
  );
389
 
390
  return $classes;
@@ -420,7 +424,7 @@ if ( ! class_exists( 'Mega_Menu' ) ) :
420
  }
421
 
422
  // gutenberg block
423
- include_once MEGAMENU_PATH . "integration/block/location/block.php";
424
 
425
  }
426
 
3
  * Plugin Name: Max Mega Menu
4
  * Plugin URI: https://www.megamenu.com
5
  * Description: An easy to use mega menu plugin. Written the WordPress way.
6
+ * Version: 3.0
7
  * Author: megamenu.com
8
  * Author URI: https://www.megamenu.com
9
  * License: GPL-2.0+
35
  *
36
  * @var string
37
  */
38
+ public $version = '3.0';
39
 
40
 
41
  /**
111
  'Mega_Menu_Locations',
112
  'Mega_Menu_Themes',
113
  'Mega_Menu_Tools',
114
+ 'Mega_Menu_Admin_Notices'
115
  );
116
 
117
  foreach ( $admin_classes as $class ) {
232
  * Load TinyMCE assets on nav-menus.php page.
233
  *
234
  * @since 1.8
235
+ * @param array $pages Pages to load tinymce scripts on
236
  * @return array $pages
237
  */
238
  public function megamenu_blackstudio_tinymce( $pages ) {
248
  */
249
  public function install_upgrade_check() {
250
  $version = get_option( 'megamenu_version' );
251
+ $install_date = get_option( 'megamenu_install_date');
252
 
253
+ if ( ! $install_date ) {
254
+ add_option( 'megamenu_install_date', time() );
255
+ }
256
 
257
+ if ( $version ) {
258
  if ( version_compare( $this->version, $version, '!=' ) ) {
 
259
  update_option( 'megamenu_version', $this->version );
 
260
  do_action( 'megamenu_after_update' );
 
261
  }
262
  } else {
 
263
  add_option( 'megamenu_version', $this->version );
264
  add_option( 'megamenu_initial_version', $this->version );
265
  add_option( 'megamenu_multisite_share_themes', 'false' );
289
  if ( class_exists( 'Mega_Menu_Widget' ) ) {
290
  register_widget( 'Mega_Menu_Widget' );
291
  }
292
+
293
+ if ( class_exists( 'Mega_Menu_Widget_Reusable_Block' ) ) {
294
+ register_widget( 'Mega_Menu_Widget_Reusable_Block' );
295
+ }
296
 
297
  // Check if Elementor installed and activated
298
  //if ( did_action( 'elementor/loaded' ) ) {
300
  //}
301
  }
302
 
 
303
  /**
304
  * Create our own widget area to store all mega menu widgets.
305
  * All widgets from all menus are stored here, they are filtered later
388
  'Mega_Menu_Widget_Reusable_Block' => MEGAMENU_PATH . 'classes/widgets/widget-reusable-block.class.php',
389
  'Mega_Menu_Widget_Elementor_Template' => MEGAMENU_PATH . 'classes/widgets/widget-elementor-template.class.php',
390
  'Mega_Menu_toggle_Blocks' => MEGAMENU_PATH . 'classes/toggle-blocks.class.php',
391
+ 'Mega_Menu_Admin_Notices' => MEGAMENU_PATH . 'classes/admin-notices.class.php'
392
  );
393
 
394
  return $classes;
424
  }
425
 
426
  // gutenberg block
427
+ include_once MEGAMENU_PATH . 'integration/block/location/block.php';
428
 
429
  }
430
 
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Max Mega Menu ===
2
  Contributors: megamenu
3
- Tags: menu, megamenu, mega menu, full site editing, gutenberg
4
- Requires at least: 4.9
5
- Tested up to: 6.0
6
  Stable tag: 2.9.8
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
@@ -136,9 +136,10 @@ See https://www.megamenu.com for more screenshots
136
 
137
  == Changelog ==
138
 
139
- = 2.9.9 =
140
 
141
  * New feature: Add Gutenberg Block. Restores the *Appearance > Menus* page for FSE (Full Site Editing) themes and adds a new Max Mega Menu block to display a menu location.
 
142
 
143
  = 2.9.8 =
144
 
1
  === Max Mega Menu ===
2
  Contributors: megamenu
3
+ Tags: menu, megamenu, mega menu, navigation, mobile
4
+ Requires at least: 5.0
5
+ Tested up to: 6.1
6
  Stable tag: 2.9.8
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
136
 
137
  == Changelog ==
138
 
139
+ = 3.0 =
140
 
141
  * New feature: Add Gutenberg Block. Restores the *Appearance > Menus* page for FSE (Full Site Editing) themes and adds a new Max Mega Menu block to display a menu location.
142
+ * New feature: Add Reusable Block widget. Allows block content to be saved as a Reusable Block and displayed within sub menus.
143
 
144
  = 2.9.8 =
145