| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
Plugin Name: Responsive Menu |
| 5 |
Plugin URI: https://expresstech.io |
| 6 |
Description: Highly Customisable Responsive Menu Plugin for WordPress |
| 7 |
Version: 4.1.1 |
| 8 |
Author: ExpressTech |
| 9 |
Text Domain: responsive-menu |
| 10 |
Author URI: https://responsive.menu |
| 11 |
License: GPL2 |
| 12 |
Tags: responsive, menu, responsive menu, mega menu, max mega menu, max menu |
| 13 |
*/ |
| 14 |
|
| 15 |
/** |
| 16 |
* Constant as plugin version. |
| 17 |
*/ |
| 18 |
if ( ! defined( 'RMP_PLUGIN_VERSION' ) ) { |
| 19 |
define( 'RMP_PLUGIN_VERSION', '4.1.1' ); |
| 20 |
} |
| 21 |
|
| 22 |
define('RESPONSIVE_MENU_URL', plugin_dir_url( __FILE__ ) ); |
| 23 |
|
| 24 |
add_action('admin_init', 'check_responsive_menu_php_version'); |
| 25 |
function check_responsive_menu_php_version() { |
| 26 |
if(version_compare(PHP_VERSION, '5.4', '<')): |
| 27 |
add_action('admin_notices', 'responsive_menu_deactivation_text'); |
| 28 |
deactivate_plugins(plugin_basename(__FILE__)); |
| 29 |
endif; |
| 30 |
} |
| 31 |
|
| 32 |
function responsive_menu_deactivation_text() { |
| 33 |
echo '<div class="error"><p>' . sprintf( |
| 34 |
'Responsive Menu requires PHP 5.4 or higher to function and has therefore been automatically disabled. |
| 35 |
You are still on %s.%sPlease speak to your web host about upgrading your PHP version.', |
| 36 |
PHP_VERSION, |
| 37 |
'<br /><br />' |
| 38 |
) . '</p></div>'; |
| 39 |
} |
| 40 |
|
| 41 |
if(version_compare(PHP_VERSION, '5.4', '<')) |
| 42 |
return; |
| 43 |
|
| 44 |
if ( empty( get_option( 'is_rmp_new_version') ) && ! empty( get_option('responsive_menu_version') ) ) { |
| 45 |
|
| 46 |
/** |
| 47 |
* Add admin notice to upgrade the plugin license. |
| 48 |
*/ |
| 49 |
add_action( 'admin_notices', 'rmp_move_new_version_admin_notice' ); |
| 50 |
function rmp_move_new_version_admin_notice() { |
| 51 |
|
| 52 |
if ( ! empty( get_option( 'rm_upgrade_admin_notice' ) ) ) { |
| 53 |
return; |
| 54 |
} |
| 55 |
|
| 56 |
if ( empty( $_GET['page'] ) || 'responsive-menu' !== $_GET['page'] ) { |
| 57 |
return; |
| 58 |
} |
| 59 |
?> |
| 60 |
|
| 61 |
<div class="notice-responsive-menu notice error is-dismissible rmp-version-upgrade-notice"> |
| 62 |
<div class="notice-responsive-menu-logo"> |
| 63 |
<img src="<?php echo RESPONSIVE_MENU_URL;?>/imgs/responsive-menu-logo.png" width="60" height="60" alt="logo" /> |
| 64 |
</div> |
| 65 |
<div class="notice-responsive-menu-message"> |
| 66 |
<h4 style="font-weight: 700;"><?php _e('Responsive Menu', 'responsive-menu-pro'); ?></h4> |
| 67 |
<p><?php _e( 'Try out our new version with improved layout, live preview and many more.', 'responsive-menu-pro' ); ?></p> |
| 68 |
</div> |
| 69 |
<div class="notice-responsive-menu-action"> |
| 70 |
<a href="javascript:void(0)" class="rmp-upgrade-version" > <?php _e('Try, New version', 'responsive-menu-pro'); ?> </a> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
<?php |
| 74 |
} |
| 75 |
|
| 76 |
add_action( 'admin_notices', 'og_pro_deactivate_pro_version_notice'); |
| 77 |
|
| 78 |
function og_pro_deactivate_pro_version_notice() { |
| 79 |
if(get_transient('og-admin-notice-activation-pro')) { |
| 80 |
?> |
| 81 |
<div class="notice notice-error is-dismissible"> |
| 82 |
<p>Responsive Menu Pro has been deactivated<p/> |
| 83 |
|
| 84 |
</div> |
| 85 |
<?php |
| 86 |
delete_transient('og-admin-notice-activation-pro'); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
function og_deactivate_responsive_menu_pro() { |
| 91 |
|
| 92 |
$plugin = 'responsive-menu-pro/responsive-menu-pro.php'; |
| 93 |
|
| 94 |
if( is_plugin_active($plugin) ){ |
| 95 |
deactivate_plugins( 'responsive-menu-pro/responsive-menu-pro.php'); |
| 96 |
set_transient( 'og-admin-notice-activation-pro', true, 5 ); |
| 97 |
|
| 98 |
return; |
| 99 |
} |
| 100 |
} |
| 101 |
//to check weather another plugin is acivated or not. |
| 102 |
register_activation_hook( __FILE__, 'og_deactivate_responsive_menu_pro'); |
| 103 |
|
| 104 |
include dirname(__FILE__) . '/vendor/autoload.php'; |
| 105 |
include dirname(__FILE__) . '/config/default_options.php'; |
| 106 |
include dirname(__FILE__) . '/config/services.php'; |
| 107 |
include dirname(__FILE__) . '/config/wp/scripts.php'; |
| 108 |
include dirname(__FILE__) . '/config/routing.php'; |
| 109 |
include dirname(__FILE__) . '/migration.php'; |
| 110 |
include dirname(__FILE__) . '/config/polylang.php'; |
| 111 |
|
| 112 |
} else { |
| 113 |
|
| 114 |
// If this file called directly then abort. |
| 115 |
if ( ! defined( 'WPINC' ) ) { |
| 116 |
die; |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Constant as plugin file. |
| 121 |
*/ |
| 122 |
if ( ! defined( 'RMP_PLUGIN_FILE' ) ) { |
| 123 |
define('RMP_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . 'responsive-menu.php'); |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Constant as dir of plugin. |
| 128 |
*/ |
| 129 |
if ( ! defined( 'RMP_PLUGIN_DIR_NAME' ) ) { |
| 130 |
define( 'RMP_PLUGIN_DIR_NAME', untrailingslashit ( dirname( plugin_basename( __FILE__ ) ) ) ); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Constant as plugin path. |
| 135 |
*/ |
| 136 |
if ( ! defined( 'RMP_PLUGIN_PATH' ) ) { |
| 137 |
define( 'RMP_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Constant as plugin URL. |
| 142 |
*/ |
| 143 |
if ( ! defined( 'RMP_PLUGIN_URL' ) ) { |
| 144 |
define( 'RMP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) ); |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Constant as URI of assets build. |
| 149 |
*/ |
| 150 |
if ( ! defined( 'RMP_PLUGIN_BUILD_URI' ) ) { |
| 151 |
define( 'RMP_PLUGIN_BUILD_URI', untrailingslashit( plugin_dir_url( __FILE__ ) ) . '/assets/build' ); |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Constant as dir of assets build. |
| 156 |
*/ |
| 157 |
if ( ! defined( 'RMP_PLUGIN_BUILD_DIR' ) ) { |
| 158 |
define( 'RMP_PLUGIN_BUILD_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/assets/build' ); |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Constant as path of template file. |
| 163 |
*/ |
| 164 |
if ( ! defined( 'RMP_PLUGIN_TEMPLATE_PATH' ) ) { |
| 165 |
define( 'RMP_PLUGIN_TEMPLATE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' ); |
| 166 |
} |
| 167 |
|
| 168 |
if ( ! defined( 'RMP_PLUGIN_PATH_V4' ) ) { |
| 169 |
define ( 'RMP_PLUGIN_PATH_V4', RMP_PLUGIN_PATH . '/v4.0.0' ); |
| 170 |
} |
| 171 |
|
| 172 |
if ( ! defined( 'RMP_PLUGIN_URL_V4' ) ) { |
| 173 |
define ( 'RMP_PLUGIN_URL_V4', RMP_PLUGIN_URL . '/v4.0.0' ); |
| 174 |
} |
| 175 |
|
| 176 |
/** Include the required files only*/ |
| 177 |
require_once RMP_PLUGIN_PATH_V4 . '/inc/helpers/autoloader.php'; |
| 178 |
require_once RMP_PLUGIN_PATH_V4 . '/inc/helpers/custom-functions.php'; |
| 179 |
require_once RMP_PLUGIN_PATH_V4 . '/inc/helpers/default-options.php'; |
| 180 |
require_once RMP_PLUGIN_PATH_V4 . '/libs/scssphp/vendor/autoload.php'; |
| 181 |
|
| 182 |
/** |
| 183 |
* To load plugin manifest class. |
| 184 |
* |
| 185 |
* @return void |
| 186 |
*/ |
| 187 |
function responsive_menu_features_plugin_loader() { |
| 188 |
\RMP\Features\Inc\Plugin::get_instance(); |
| 189 |
} |
| 190 |
|
| 191 |
responsive_menu_features_plugin_loader(); |
| 192 |
|
| 193 |
// Active and de-active plugin hook. |
| 194 |
register_activation_hook( __FILE__, 'responsive_menu_plugin_activation' ); |
| 195 |
register_deactivation_hook( __FILE__, 'responsive_menu_plugin_deactivation' ); |
| 196 |
|
| 197 |
/** |
| 198 |
* Activation of plugin. |
| 199 |
* |
| 200 |
* @return void |
| 201 |
*/ |
| 202 |
function responsive_menu_plugin_activation() { |
| 203 |
|
| 204 |
$plugin = 'responsive-menu-pro/responsive-menu-pro.php'; |
| 205 |
|
| 206 |
// Check if responsive menu (paid version) is activate then deactivate it. |
| 207 |
if( is_plugin_active( $plugin ) ) { |
| 208 |
deactivate_plugins( $plugin ); |
| 209 |
set_transient( 'og-admin-notice-activation-pro', true, 5 ); |
| 210 |
} |
| 211 |
|
| 212 |
flush_rewrite_rules(); |
| 213 |
} |
| 214 |
|
| 215 |
/** |
| 216 |
* Deactivation of plugin. |
| 217 |
* |
| 218 |
* @return void |
| 219 |
*/ |
| 220 |
function responsive_menu_plugin_deactivation() { |
| 221 |
flush_rewrite_rules(); |
| 222 |
} |
| 223 |
|
| 224 |
/** |
| 225 |
* Function to include the menu themes templates. |
| 226 |
* |
| 227 |
* @since 4.0.5 |
| 228 |
* |
| 229 |
* @return void |
| 230 |
*/ |
| 231 |
function rm_includes_menu_theme_template() { |
| 232 |
|
| 233 |
$theme_manager = \RMP\Features\Inc\Theme_Manager::get_instance(); |
| 234 |
|
| 235 |
//Check class theme manager has this method or not. |
| 236 |
if ( ! method_exists( $theme_manager, 'get_menu_active_themes' ) ) { |
| 237 |
return; |
| 238 |
} |
| 239 |
|
| 240 |
$active_themes = $theme_manager->get_menu_active_themes(); |
| 241 |
if ( empty( $active_themes ) ) { |
| 242 |
return; |
| 243 |
} |
| 244 |
|
| 245 |
//Include the file from each theme which has php template. |
| 246 |
foreach( $active_themes as $key => $theme_name ) { |
| 247 |
|
| 248 |
$theme_index = $theme_manager->get_theme_index_file( $theme_name ); |
| 249 |
|
| 250 |
if ( file_exists( $theme_index ) ) { |
| 251 |
require_once $theme_index; |
| 252 |
} |
| 253 |
} |
| 254 |
|
| 255 |
} |
| 256 |
|
| 257 |
rm_includes_menu_theme_template(); |
| 258 |
} |