| @@ -1,36 +1,72 @@ | ||
| 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.1.6 | |
| 8 | -Author: Peter Featherstone | |
| 9 | -Text Domain: responsive-menu | |
| 10 | -Author URI: https://peterfeatherstone.com | |
| 11 | -License: GPL2 | |
| 12 | -Tags: responsive, menu, responsive menu | |
| 13 | -*/ | |
| 14 | - | |
| 15 | -add_action('admin_init', 'check_responsive_menu_php_version'); | |
| 16 | -function check_responsive_menu_php_version() { | |
| 17 | - if(version_compare(PHP_VERSION, '5.4', '<')): | |
| 18 | - add_action('admin_notices', 'responsive_menu_deactivation_text'); | |
| 19 | - deactivate_plugins(plugin_basename(__FILE__)); | |
| 20 | - endif; | |
| 21 | -} | |
| 22 | - | |
| 23 | -function responsive_menu_deactivation_text() { | |
| 24 | - echo '<div class="error"><p>' . sprintf('Responsive Menu requires PHP 5.4 or higher to function and has therefore been automatically disabled. You are still on %s.%sPlease speak to your webhost about upgrading your PHP version. For more information please visit %s', PHP_VERSION, '<br /><br />', '<a target="_blank" href="https://responsive.menu/why-php-5-4/">this page</a>.') . '</p></div>'; | |
| 25 | -} | |
| 26 | - | |
| 27 | -if(version_compare(PHP_VERSION, '5.4', '<')) | |
| 28 | - return; | |
| 29 | - | |
| 30 | -include dirname(__FILE__) . '/vendor/autoload.php'; | |
| 31 | -include dirname(__FILE__) . '/config/default_options.php'; | |
| 32 | -include dirname(__FILE__) . '/config/services.php'; | |
| 33 | -include dirname(__FILE__) . '/config/wp/scripts.php'; | |
| 34 | -include dirname(__FILE__) . '/config/routing.php'; | |
| 35 | -include dirname(__FILE__) . '/migration.php'; | |
| 36 | -include dirname(__FILE__) . '/config/polylang.php'; | |
| 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.9 | |
| 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 | +add_action('admin_init', 'check_responsive_menu_php_version'); | |
| 17 | +function check_responsive_menu_php_version() { | |
| 18 | + if(version_compare(PHP_VERSION, '5.4', '<')): | |
| 19 | + add_action('admin_notices', 'responsive_menu_deactivation_text'); | |
| 20 | + deactivate_plugins(plugin_basename(__FILE__)); | |
| 21 | + endif; | |
| 22 | +} | |
| 23 | + | |
| 24 | +function responsive_menu_deactivation_text() { | |
| 25 | + echo '<div class="error"><p>' . sprintf(__('Responsive Menu requires PHP 5.4 or higher to function and has therefore been automatically disabled. You are still on %s.%sPlease speak to your webhost about upgrading your PHP version. For more information please visit %s', 'responsive-menu'), PHP_VERSION, '<br /><br />', '<a target="_blank" href="https://responsive.menu/why-php-5-4/">this page</a>.') . '</p></div>'; | |
| 26 | +} | |
| 27 | + | |
| 28 | +if(version_compare(PHP_VERSION, '5.4', '<')) | |
| 29 | + return; | |
| 30 | + | |
| 31 | +/* Required includes for plugin to function */ | |
| 32 | +include dirname(__FILE__) . '/autoload.php'; | |
| 33 | +include dirname(__FILE__) . '/src/config/route_dependencies.php'; | |
| 34 | + | |
| 35 | +/* Internationalise the plugin */ | |
| 36 | +add_action('plugins_loaded', function() { | |
| 37 | + load_plugin_textdomain('responsive-menu', false, basename(dirname(__FILE__)) . '/translations/'); | |
| 38 | +}); | |
| 39 | + | |
| 40 | +/* Route the plugin */ | |
| 41 | +$wp_router = new ResponsiveMenu\Routing\WpRouting($container); | |
| 42 | +$wp_router->route(); | |
| 43 | + | |
| 44 | +/* | |
| 45 | +* Initial Migration and Version Check synchronisation */ | |
| 46 | +add_action('init', function() use($container) { | |
| 47 | + $migration = $container['migration']; | |
| 48 | + $migration->setup(); | |
| 49 | + $migration->synchronise(); | |
| 50 | +}); | |
| 51 | + | |
| 52 | +if(is_admin()): | |
| 53 | + | |
| 54 | + /* | |
| 55 | + Polylang Integration Section */ | |
| 56 | + add_action('plugins_loaded', function() use($container) { | |
| 57 | + if(function_exists('pll_register_string')): | |
| 58 | + $service = $container['option_service']; | |
| 59 | + $options = $service->all(); | |
| 60 | + | |
| 61 | + $menu_to_use = isset($options['menu_to_use']) ? $options['menu_to_use']->getValue() : ''; | |
| 62 | + $button_title = isset($options['button_title']) ? $options['button_title']->getValue() : ''; | |
| 63 | + $menu_title = isset($options['menu_title']) ? $options['menu_title']->getValue() : ''; | |
| 64 | + $menu_title_link = isset($options['menu_title_link']) ? $options['menu_title_link']->getValue() : ''; | |
| 65 | + | |
| 66 | + pll_register_string('Menu Slug', $menu_to_use, 'Responsive Menu'); | |
| 67 | + pll_register_string('Button Title', $button_title, 'Responsive Menu'); | |
| 68 | + pll_register_string('Menu Title', $menu_title, 'Responsive Menu'); | |
| 69 | + pll_register_string('Menu Title Link', $menu_title_link, 'Responsive Menu'); | |
| 70 | + endif; | |
| 71 | + }); | |
| 72 | +endif; | |