PluginProbe
Responsive Menu – Mobile Menu & Hamburger Menu Builder / 4.7.4
Responsive Menu – Mobile Menu & Hamburger Menu Builder v4.7.4
4.7.4 4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 All 91 releases
← All changes | v4.0.0/inc/classes/class-plugin.php +150 -37 4.0.0 → 4.7.4 View file →
@@ -1,13 +1,14 @@
1 1 <?php
2 2 /**
3 3 * Plugin manifest class.
4 4 *
5 - * @package responsive-menu-pro
5 + * @package responsive-menu
6 6 */
7 7
8 8 namespace RMP\Features\Inc;
9 9
10 +use RMP\Features\Inc\Elementor\Elementor_Manager;
10 11 use RMP\Features\Inc\Traits\Singleton;
11 12
12 13 /**
13 14 * Class Plugin
@@ -31,8 +32,9 @@
31 32 Option_Manager::get_instance();
32 33 Style_Manager::get_instance();
33 34 UI_Manager::get_instance();
34 35 RMP_Migration::get_instance();
36 + Elementor_Manager::get_instance();
35 37
36 38 $this->setup_hooks();
37 39 }
38 40
@@ -41,34 +43,142 @@
41 43 *
42 44 * @return void
43 45 */
44 46 protected function setup_hooks() {
47 + add_action( 'plugins_loaded', array( $this, 'rmp_load_plugin_text_domain' ) );
48 + add_action( 'admin_notices', array( $this, 'rmp_deactivate_paid_version_notice' ) );
45 49
46 - add_action( 'plugins_loaded', [ $this, 'rmp_load_plugin_text_domain' ] );
47 - add_action( 'admin_notices', [ $this, 'rmp_deactivate_paid_version_notice' ] );
50 + //Hiding upgrade to pro notice for v3 users
51 + global $wpdb;
52 + $table_name = $wpdb->prefix . 'responsive_menu';
53 + $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
54 + if ( ! $wpdb->get_var( $query ) == $table_name ) {
55 + add_action( 'admin_notices', array( $this, 'rmp_upgrade_pro_admin_notice' ) );
56 + }
57 + add_action( 'plugin_action_links_' . plugin_basename( RMP_PLUGIN_FILE ), array( $this, 'rmp_upgrade_pro_plugin_link' ) );
58 + add_action( 'wp_ajax_rmp_upgrade_admin_notice_dismiss', array( $this, 'rmp_upgrade_pro_notice_dismiss' ) );
59 + add_action( 'admin_notices', array( $this, 'no_menu_admin_notice' ) );
48 60
49 61 // Check current config and environment support wp_body_open or not.
62 + if ( $this->has_support( 'wp_body_open' ) ) {
63 + add_action( 'wp_body_open', array( $this, 'menu_render_on_frontend' ) );
64 + } else {
65 + add_action( 'wp_footer', array( $this, 'menu_render_on_frontend' ) );
66 + }
67 + }
50 68
51 - if( $this->has_support( 'wp_body_open' ) ) {
52 - add_action( 'wp_body_open' , [ $this, 'menu_render_on_frontend'] );
53 - } else {
54 - add_action( 'wp_footer' , [ $this, 'menu_render_on_frontend'] );
69 + /**
70 + * Function to show the admin notice when no menu exist.
71 + *
72 + * @since 4.1.0
73 + *
74 + * @return void
75 + */
76 + public function no_menu_admin_notice() {
77 +
78 + // Check post type.
79 + $post_type = get_post_type();
80 + if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) {
81 + // A post type is a slug, not a number: intval() made this always 0.
82 + // is_scalar() because ?post_type[]=x would otherwise reach strtolower( array ).
83 + $post_type = is_scalar( $_GET['post_type'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
84 + ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
85 + : '';
55 86 }
87 +
88 + if ( 'rmp_menu' !== $post_type || ! empty( $_GET['page'] ) ) {
89 + return;
90 + }
91 +
92 + // Count all post which are in list except trash.
93 + $post_count = 0;
94 + foreach ( wp_count_posts( 'rmp_menu' ) as $status => $count ) {
95 + if ( 'trash' == $status ) {
96 + continue;
97 + }
98 +
99 + $post_count += $count;
100 + }
101 +
102 + if ( $post_count >= 1 ) {
103 + return;
104 + } ?>
105 + <div class="notice notice-error">
106 + <p>
107 + <?php
108 + /* translators: %s: HTML tag */
109 + echo sprintf( esc_html__( 'Responsive menu list is empty. Create a menu by clicking the %1$sCreate New Menu%2$s button. For more details visit ', 'responsive-menu' ), '<b>', '</b>' );
110 + ?>
111 + <a target="_blank" rel="noopener" href="<?php echo esc_url( 'https://responsive.menu/knowledgebase/responsive-menu-4-0-overview/' ); ?>"> <?php esc_html_e( 'Documentation', 'responsive-menu' ); ?></a>
112 + </p>
113 + </div>
114 + <?php
56 115 }
57 116
58 117 /**
118 + * Add plugin upgrade link.
119 + *
120 + * Add a link to the settings page on the responsive menu page.
121 + *
122 + * @param array $links List of existing plugin action links.
123 + * @return array List of modified plugin action links.
124 + */
125 + public function rmp_upgrade_pro_plugin_link( $links ) {
126 + $links = array_merge(
127 + $links,
128 + array( '<a class="responsive-menu-license-upgrade-link" target="_blank" rel="noopener" href="https://responsive.menu/pricing/">' . esc_html__( 'Upgrade', 'responsive-menu' ) . '</a>' )
129 + );
130 +
131 + return $links;
132 + }
133 +
134 + /**
135 + * Function to add the admin notice to upgrade as pro.
136 + *
137 + * @version 4.1.0
138 + */
139 + public function rmp_upgrade_pro_admin_notice() {
140 + $post_type = get_post_type();
141 + if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) {
142 + // A post type is a slug, not a number: intval() made this always 0.
143 + // is_scalar() because ?post_type[]=x would otherwise reach strtolower( array ).
144 + $post_type = is_scalar( $_GET['post_type'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
145 + ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
146 + : '';
147 + }
148 +
149 + if ( 'rmp_menu' !== $post_type ) {
150 + return;
151 + }
152 +
153 + $user_id = get_current_user_id();
154 + if ( ! empty( get_user_meta( $user_id, 'rmp_upgrade_pro_admin_notice' ) ) ) {
155 + return;
156 + }
157 +
158 + include_once RMP_PLUGIN_PATH_V4 . '/templates/admin-notices.php';
159 + }
160 +
161 + /**
162 + * Function to hide the admin notice permanent.
163 + */
164 + public function rmp_upgrade_pro_notice_dismiss() {
165 + $user_id = get_current_user_id();
166 + update_user_meta( $user_id, 'rmp_upgrade_pro_admin_notice', true );
167 + }
168 +
169 + /**
59 170 * Function to show the admin notice if plugin deactivate.
60 - *
171 + *
61 172 * @return void
62 173 */
63 174 public function rmp_deactivate_paid_version_notice() {
64 - if( get_transient('og-admin-notice-activation') ) {
65 - printf(
66 - '<div class="notice notice-error is-dismissible">
67 - <p>%s</p>
68 - </div>',
69 - __('Responsive Menu has been deactivated','responsive-menu-pro' )
70 - );
175 + if ( get_transient( 'og-admin-notice-activation' ) ) {
176 + ?>
177 + <div class="notice notice-error is-dismissible">
178 + <p><?php esc_html_e( 'Responsive Menu has been deactivated', 'responsive-menu' ); ?></p>
179 + </div>
180 + <?php
71 181 delete_transient( 'og-admin-notice-activation-pro' );
72 182 }
73 183 }
74 184
@@ -73,35 +183,33 @@
73 183 }
74 184
75 185 /**
76 186 * Load plugin text domain.
77 - *
187 + *
78 188 * @version 4.0.0
79 - *
189 + *
80 190 * @return void
81 191 */
82 192 public function rmp_load_plugin_text_domain() {
83 - load_plugin_textdomain( 'responsive-menu-pro', false, RMP_PLUGIN_DIR_NAME . '/v4.0.0/languages' );
193 + load_plugin_textdomain( 'responsive-menu', false, RMP_PLUGIN_DIR_NAME . '/v4.0.0/languages' );
84 194 }
85 195
86 196 /**
87 197 * Function to render the nenu on frontend.
88 - *
198 + *
89 199 * @version 4.0.0
90 200 */
91 - function menu_render_on_frontend() {
201 + public function menu_render_on_frontend() {
202 + $option_manager = Option_Manager::get_instance();
203 + $menu_ids = get_all_rmp_menu_ids();
92 204
93 - $option_manager = Option_Manager::get_instance();
94 - $menu_ids = get_all_rmp_menu_ids();
95 -
96 205 if ( empty( $menu_ids ) ) {
97 206 return;
98 207 }
99 -
208 +
100 209 foreach ( $menu_ids as $menu_id ) {
210 + $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
101 211
102 - $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
103 -
104 212 if ( ! empty( $menu_show_on ) && 'shortcode' === $menu_show_on ) {
105 213 continue;
106 214 }
107 215
@@ -111,33 +219,39 @@
111 219 }
112 220
113 221 /**
114 222 * Check support of wp_body_open for plugins and themes.
115 - *
223 + *
116 224 * @since 4.0.0
117 - *
225 + *
118 226 * @param string $hook Name of hook.
119 227 * @return boolean
120 228 */
121 229 public function has_support( $hook ) {
122 230
231 + // Check wp footer option is enabled.
232 + $option_manager = Option_Manager::get_instance();
233 + if ( 'wp_body_open' === $hook && 'on' === $option_manager->get_global_option( 'rmp_wp_footer_hook' ) ) {
234 + return false;
235 + }
236 +
123 237 // Check wp core support wp_body_open hook or not.
124 - if( ! has_action( $hook ) ) {
238 + if ( ! has_action( $hook ) ) {
125 239 return false;
126 240 }
127 241
128 242 // If is_plugin_active function not exist then add plugin.php file from core.
129 - if( ! function_exists( 'is_plugin_active' ) ) {
130 - include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
243 + if ( ! function_exists( 'is_plugin_active' ) ) {
244 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
131 245 }
132 246
133 247 // List of unsupported themes and plugins.
134 - $unsupported_extensions = [
135 - 'oxygen/functions.php'
136 - ];
248 + $unsupported_extensions = array(
249 + 'oxygen/functions.php',
250 + );
137 251
138 - foreach( $unsupported_extensions as $extension ) {
139 - if( is_plugin_active( $extension ) ) {
252 + foreach ( $unsupported_extensions as $extension ) {
253 + if ( is_plugin_active( $extension ) ) {
140 254 return false;
141 255 }
142 256 }
143 257
@@ -142,6 +256,5 @@
142 256 }
143 257
144 258 return true;
145 259 }
146 -
147 260 }