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 +148 -37 4.0.2 → 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,34 +43,142 @@
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 + //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' ) );
50 60
51 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 + }
52 68
53 - if( $this->has_support( 'wp_body_open' ) ) {
54 - add_action( 'wp_body_open' , [ $this, 'menu_render_on_frontend'] );
55 - } else {
56 - 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 + : '';
57 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
58 115 }
59 116
60 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 + /**
61 170 * Function to show the admin notice if plugin deactivate.
62 - *
171 + *
63 172 * @return void
64 173 */
65 174 public function rmp_deactivate_paid_version_notice() {
66 - if( get_transient('og-admin-notice-activation') ) {
67 - printf(
68 - '<div class="notice notice-error is-dismissible">
69 - <p>%s</p>
70 - </div>',
71 - __('Responsive Menu has been deactivated','responsive-menu-pro' )
72 - );
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
73 181 delete_transient( 'og-admin-notice-activation-pro' );
74 182 }
75 183 }
76 184
@@ -75,35 +183,33 @@
75 183 }
76 184
77 185 /**
78 186 * Load plugin text domain.
79 - *
187 + *
80 188 * @version 4.0.0
81 - *
189 + *
82 190 * @return void
83 191 */
84 192 public function rmp_load_plugin_text_domain() {
85 - 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' );
86 194 }
87 195
88 196 /**
89 197 * Function to render the nenu on frontend.
90 - *
198 + *
91 199 * @version 4.0.0
92 200 */
93 - 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();
94 204
95 - $option_manager = Option_Manager::get_instance();
96 - $menu_ids = get_all_rmp_menu_ids();
97 -
98 205 if ( empty( $menu_ids ) ) {
99 206 return;
100 207 }
101 -
208 +
102 209 foreach ( $menu_ids as $menu_id ) {
210 + $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
103 211
104 - $menu_show_on = $option_manager->get_option( $menu_id, 'menu_display_on' );
105 -
106 212 if ( ! empty( $menu_show_on ) && 'shortcode' === $menu_show_on ) {
107 213 continue;
108 214 }
109 215
@@ -113,33 +219,39 @@
113 219 }
114 220
115 221 /**
116 222 * Check support of wp_body_open for plugins and themes.
117 - *
223 + *
118 224 * @since 4.0.0
119 - *
225 + *
120 226 * @param string $hook Name of hook.
121 227 * @return boolean
122 228 */
123 229 public function has_support( $hook ) {
124 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 +
125 237 // Check wp core support wp_body_open hook or not.
126 - if( ! has_action( $hook ) ) {
238 + if ( ! has_action( $hook ) ) {
127 239 return false;
128 240 }
129 241
130 242 // If is_plugin_active function not exist then add plugin.php file from core.
131 - if( ! function_exists( 'is_plugin_active' ) ) {
132 - include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
243 + if ( ! function_exists( 'is_plugin_active' ) ) {
244 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
133 245 }
134 246
135 247 // List of unsupported themes and plugins.
136 - $unsupported_extensions = [
137 - 'oxygen/functions.php'
138 - ];
248 + $unsupported_extensions = array(
249 + 'oxygen/functions.php',
250 + );
139 251
140 - foreach( $unsupported_extensions as $extension ) {
141 - if( is_plugin_active( $extension ) ) {
252 + foreach ( $unsupported_extensions as $extension ) {
253 + if ( is_plugin_active( $extension ) ) {
142 254 return false;
143 255 }
144 256 }
145 257
@@ -144,6 +256,5 @@
144 256 }
145 257
146 258 return true;
147 259 }
148 -
149 260 }