| @@ -1,224 +1,65 @@ | ||
| 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.0.3 | |
| 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.0.3' ); | |
| 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 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* | |
| 4 | +Plugin Name: Responsive Menu | |
| 5 | +Plugin URI: https://responsive.menu | |
| 6 | +Description: Highly Customisable Responsive Menu Plugin for WordPress | |
| 7 | +Version: 3.0.4 | |
| 8 | +Author: Responsive Menu | |
| 9 | +Text Domain: responsive-menu | |
| 10 | +Author URI: https://responsive.menu | |
| 11 | +License: GPL2 | |
| 12 | +Tags: responsive, menu, responsive menu | |
| 13 | +*/ | |
| 14 | + | |
| 15 | +/* Check correct PHP version first */ | |
| 16 | +register_activation_hook(__FILE__, 'activate_responsive_menu'); | |
| 17 | +function activate_responsive_menu() { | |
| 18 | + if(version_compare(PHP_VERSION, '5,4', '<')): | |
| 19 | + deactivate_plugins(plugin_basename(__FILE__ )); | |
| 20 | + wp_die(sprintf('Responsive Menu requires PHP 5.4 or higher. You are still on %s', PHP_VERSION)); | |
| 21 | + endif; | |
| 22 | +} | |
| 23 | + | |
| 24 | +/* Required includes for plugin to function */ | |
| 25 | +include dirname(__FILE__) . '/autoload.php'; | |
| 26 | +include dirname(__FILE__) . '/src/config/route_dependencies.php'; | |
| 27 | + | |
| 28 | +/* Internationalise the plugin */ | |
| 29 | +add_action('plugins_loaded', function() { | |
| 30 | + load_plugin_textdomain('responsive-menu', false, basename(dirname(__FILE__)) . '/translations/'); | |
| 31 | +}); | |
| 32 | + | |
| 33 | +/* Route the plugin */ | |
| 34 | +$wp_router = new ResponsiveMenu\Routing\WpRouting($container); | |
| 35 | +$wp_router->route(); | |
| 36 | + | |
| 37 | +if(is_admin()): | |
| 38 | + /* | |
| 39 | + * Initial Migration and Version Check synchronisation */ | |
| 40 | + add_action('admin_init', function() use($container) { | |
| 41 | + include dirname(__FILE__) . '/src/config/default_options.php'; | |
| 42 | + $migration = new ResponsiveMenu\Database\Migration($container['database'], $default_options); | |
| 43 | + $migration->setup(); | |
| 44 | + $migration->synchronise(); | |
| 45 | + }); | |
| 46 | + | |
| 47 | + /* | |
| 48 | + Polylang Integration Section */ | |
| 49 | + add_action('plugins_loaded', function() use($container) { | |
| 50 | + if(function_exists('pll_register_string')): | |
| 51 | + $repo = $container['option_repository']; | |
| 52 | + $options = $repo->all(); | |
| 53 | + | |
| 54 | + $menu_to_use = isset($options['menu_to_use']) ? $options['menu_to_use']->getValue() : ''; | |
| 55 | + $button_title = isset($options['button_title']) ? $options['button_title']->getValue() : ''; | |
| 56 | + $menu_title = isset($options['menu_title']) ? $options['menu_title']->getValue() : ''; | |
| 57 | + $menu_title_link = isset($options['menu_title_link']) ? $options['menu_title_link']->getValue() : ''; | |
| 58 | + | |
| 59 | + pll_register_string('Menu Slug', $menu_to_use, 'Responsive Menu'); | |
| 60 | + pll_register_string('Button Title', $button_title, 'Responsive Menu'); | |
| 61 | + pll_register_string('Menu Title', $menu_title, 'Responsive Menu'); | |
| 62 | + pll_register_string('Menu Title Link', $menu_title_link, 'Responsive Menu'); | |
| 63 | + endif; | |
| 64 | + }); | |
| 65 | +endif; | |