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 +73 -65 4.1.3 → 4.7.4 View file →
@@ -1,9 +1,9 @@
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
@@ -43,21 +43,27 @@
43 43 *
44 44 * @return void
45 45 */
46 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' ) );
47 49
48 - add_action( 'plugins_loaded', [ $this, 'rmp_load_plugin_text_domain' ] );
49 - add_action( 'admin_notices', [ $this, 'rmp_deactivate_paid_version_notice' ] );
50 - add_action( 'admin_notices', [ $this, 'rmp_upgrade_pro_admin_notice'] );
51 - add_action( 'plugin_action_links_' . plugin_basename( RMP_PLUGIN_FILE ) , [ $this, 'rmp_upgrade_pro_plugin_link' ] );
52 - add_action( "wp_ajax_rmp_upgrade_admin_notice_dismiss", [ $this, 'rmp_upgrade_pro_notice_dismiss'] );
53 - add_action( 'admin_notices', [ $this, 'no_menu_admin_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' ) );
54 60
55 61 // Check current config and environment support wp_body_open or not.
56 - if( $this->has_support( 'wp_body_open' ) ) {
57 - add_action( 'wp_body_open' , [ $this, 'menu_render_on_frontend'] );
62 + if ( $this->has_support( 'wp_body_open' ) ) {
63 + add_action( 'wp_body_open', array( $this, 'menu_render_on_frontend' ) );
58 64 } else {
59 - add_action( 'wp_footer' , [ $this, 'menu_render_on_frontend'] );
65 + add_action( 'wp_footer', array( $this, 'menu_render_on_frontend' ) );
60 66 }
61 67 }
62 68
63 69 /**
@@ -68,12 +74,16 @@
68 74 * @return void
69 75 */
70 76 public function no_menu_admin_notice() {
71 77
72 - //Check post type.
78 + // Check post type.
73 79 $post_type = get_post_type();
74 80 if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) {
75 - $post_type = $_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 + : '';
76 86 }
77 87
78 88 if ( 'rmp_menu' !== $post_type || ! empty( $_GET['page'] ) ) {
79 89 return;
@@ -80,10 +90,9 @@
80 90 }
81 91
82 92 // Count all post which are in list except trash.
83 93 $post_count = 0;
84 - foreach( wp_count_posts( 'rmp_menu' ) as $status => $count ) {
85 -
94 + foreach ( wp_count_posts( 'rmp_menu' ) as $status => $count ) {
86 95 if ( 'trash' == $status ) {
87 96 continue;
88 97 }
89 98
@@ -91,17 +100,19 @@
91 100 }
92 101
93 102 if ( $post_count >= 1 ) {
94 103 return;
95 - }
96 -
97 - printf(
98 - '<div class="notice notice-error">
99 - <p> %s <a href="%s" target="_blank"> documentation </a> </p>
100 - </div>',
101 - __( 'Responsive menu list is empty. Create a menu by clicking the <b>Create New Menu</b> button. For more details visit ', 'responsive-menu-pro' ),
102 - esc_url( 'https://responsive.menu/knowledgebase/responsive-menu-4-0-overview/' )
103 - );
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
104 115 }
105 116
106 117 /**
107 118 * Add plugin upgrade link.
@@ -106,17 +117,16 @@
106 117 /**
107 118 * Add plugin upgrade link.
108 119 *
109 120 * Add a link to the settings page on the responsive menu page.
110 - *
111 - * @param array $links List of existing plugin action links.
121 + *
122 + * @param array $links List of existing plugin action links.
112 123 * @return array List of modified plugin action links.
113 124 */
114 125 public function rmp_upgrade_pro_plugin_link( $links ) {
115 -
116 126 $links = array_merge(
117 127 $links,
118 - array( '<a class="responsive-menu-license-upgrade-link" target="_blank" href="https://responsive.menu/pricing/">' . __( 'Upgrade', 'responsive-menu-pro') . '</a>')
128 + array( '<a class="responsive-menu-license-upgrade-link" target="_blank" rel="noopener" href="https://responsive.menu/pricing/">' . esc_html__( 'Upgrade', 'responsive-menu' ) . '</a>' )
119 129 );
120 130
121 131 return $links;
122 132 }
@@ -122,17 +132,19 @@
122 132 }
123 133
124 134 /**
125 135 * Function to add the admin notice to upgrade as pro.
126 - *
136 + *
127 137 * @version 4.1.0
128 - *
129 138 */
130 139 public function rmp_upgrade_pro_admin_notice() {
131 -
132 - $post_type = get_post_type();
140 + $post_type = get_post_type();
133 141 if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) {
134 - $post_type = $_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 + : '';
135 147 }
136 148
137 149 if ( 'rmp_menu' !== $post_type ) {
138 150 return;
@@ -138,9 +150,9 @@
138 150 return;
139 151 }
140 152
141 153 $user_id = get_current_user_id();
142 - if ( ! empty( get_user_meta( $user_id, 'rmp_upgrade_pro_admin_notice') ) ) {
154 + if ( ! empty( get_user_meta( $user_id, 'rmp_upgrade_pro_admin_notice' ) ) ) {
143 155 return;
144 156 }
145 157
146 158 include_once RMP_PLUGIN_PATH_V4 . '/templates/admin-notices.php';
@@ -155,19 +167,18 @@
155 167 }
156 168
157 169 /**
158 170 * Function to show the admin notice if plugin deactivate.
159 - *
171 + *
160 172 * @return void
161 173 */
162 174 public function rmp_deactivate_paid_version_notice() {
163 - if( get_transient('og-admin-notice-activation') ) {
164 - printf(
165 - '<div class="notice notice-error is-dismissible">
166 - <p>%s</p>
167 - </div>',
168 - __('Responsive Menu has been deactivated','responsive-menu-pro' )
169 - );
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
170 181 delete_transient( 'og-admin-notice-activation-pro' );
171 182 }
172 183 }
173 184
@@ -172,35 +183,33 @@
172 183 }
173 184
174 185 /**
175 186 * Load plugin text domain.
176 - *
187 + *
177 188 * @version 4.0.0
178 - *
189 + *
179 190 * @return void
180 191 */
181 192 public function rmp_load_plugin_text_domain() {
182 - 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' );
183 194 }
184 195
185 196 /**
186 197 * Function to render the nenu on frontend.
187 - *
198 + *
188 199 * @version 4.0.0
189 200 */
190 - 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();
191 204
192 - $option_manager = Option_Manager::get_instance();
193 - $menu_ids = get_all_rmp_menu_ids();
194 -
195 205 if ( empty( $menu_ids ) ) {
196 206 return;
197 207 }
198 -
208 +
199 209 foreach ( $menu_ids as $menu_id ) {
210 + $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
200 211
201 - $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
202 -
203 212 if ( ! empty( $menu_show_on ) && 'shortcode' === $menu_show_on ) {
204 213 continue;
205 214 }
206 215
@@ -210,11 +219,11 @@
210 219 }
211 220
212 221 /**
213 222 * Check support of wp_body_open for plugins and themes.
214 - *
223 + *
215 224 * @since 4.0.0
216 - *
225 + *
217 226 * @param string $hook Name of hook.
218 227 * @return boolean
219 228 */
220 229 public function has_support( $hook ) {
@@ -219,30 +228,30 @@
219 228 */
220 229 public function has_support( $hook ) {
221 230
222 231 // Check wp footer option is enabled.
223 - $option_manager = Option_Manager::get_instance();
224 - if ( 'wp_body_open' == $hook && 'on' == $option_manager->get_global_option( 'rmp_wp_footer_hook' ) ) {
232 + $option_manager = Option_Manager::get_instance();
233 + if ( 'wp_body_open' === $hook && 'on' === $option_manager->get_global_option( 'rmp_wp_footer_hook' ) ) {
225 234 return false;
226 235 }
227 236
228 237 // Check wp core support wp_body_open hook or not.
229 - if( ! has_action( $hook ) ) {
238 + if ( ! has_action( $hook ) ) {
230 239 return false;
231 240 }
232 241
233 242 // If is_plugin_active function not exist then add plugin.php file from core.
234 - if( ! function_exists( 'is_plugin_active' ) ) {
235 - include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
243 + if ( ! function_exists( 'is_plugin_active' ) ) {
244 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
236 245 }
237 246
238 247 // List of unsupported themes and plugins.
239 - $unsupported_extensions = [
240 - 'oxygen/functions.php'
241 - ];
248 + $unsupported_extensions = array(
249 + 'oxygen/functions.php',
250 + );
242 251
243 - foreach( $unsupported_extensions as $extension ) {
244 - if( is_plugin_active( $extension ) ) {
252 + foreach ( $unsupported_extensions as $extension ) {
253 + if ( is_plugin_active( $extension ) ) {
245 254 return false;
246 255 }
247 256 }
248 257
@@ -247,6 +256,5 @@
247 256 }
248 257
249 258 return true;
250 259 }
251 -
252 260 }