Changeset 3344449
- Timestamp:
- 08/14/2025 08:31:21 AM (6 months ago)
- Location:
- responsive-mobile-select-menu/trunk
- Files:
-
- 15 added
- 6 deleted
- 3 edited
-
admin (added)
-
admin/class-admin.php (added)
-
admin/css (added)
-
admin/css/admin.css (added)
-
admin/js (added)
-
admin/js/admin.js (added)
-
admin/views (added)
-
admin/views/admin-page.php (added)
-
assets/css/responsive-menu.css (added)
-
assets/css/rms-options.css (deleted)
-
assets/fonts (deleted)
-
assets/images (deleted)
-
assets/js/responsive-menu.js (added)
-
assets/js/rms-options.js (deleted)
-
classes (deleted)
-
includes (added)
-
includes/class-asset-manager.php (added)
-
includes/class-menu-walker.php (added)
-
includes/class-plugin.php (added)
-
includes/class-settings.php (added)
-
languages (deleted)
-
readme.md (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
responsive-mobile-select-menu.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
responsive-mobile-select-menu/trunk/readme.md
r3135517 r3344449 1 # Responsive Mobile Select Menu - WordPress Plugin # 1 # Responsive Mobile Select Menu 2 **Contributors:** Jyria 3 **Donate link:** https://www.saskialund.de/donate/ 4 **Tags:** responsive, menu, select, drop down, accessible mobile menu 5 **Requires at least:** 6.5 6 **Tested up to:** 6.8 7 **Requires PHP:** 8.0 8 **Stable tag:** 2.0.0 9 **License:** GPLv2 or later 10 **License URI:** https://www.gnu.org/licenses/gpl-2.0.html 11 **Network:** false 2 12 3 ** Author URI:** https://www.saskialund.de13 **Mobile Menu Made Simple** 4 14 5 **Contributors:** Jyria 15 Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices. 6 16 7 **Donate link:** https://www.saskialund.de/donate/ 17 **Key Benefits:** 18 ✅ Better mobile navigation 19 ✅ No theme modifications needed 20 ✅ Works with any WordPress menu 21 ✅ Fully accessible 22 ✅ Customizable breakpoint 8 23 9 ** Tags:** responsive, menu, select, drop down, dropdown, mobile menu24 **How it works:** The plugin detects when someone visits your site on a mobile device and automatically converts your menu into an easy-to-use dropdown. Desktop visitors see your normal menu unchanged. 10 25 11 **Requires at least:** 4.6 12 13 **Tested up to:** 6.6.9 14 15 **Requires PHP:** 7.4 16 17 **Stable tag:** 1.1.4 18 19 **License:** GPLv2 or later 20 21 **License URI:** http://www.gnu.org/licenses/gpl-2.0.html 22 23 The Responsive Mobile Select Menu plugin automatically turns any WordPress Menu into a select box / dropdown on mobile devices. 26 **Perfect for:** Anyone who wants to improve their mobile site navigation without technical hassle. 24 27 25 28 ## Description ## 26 29 27 One common UI paradigm for navigation menus with responsive design is to display a select box (form element) for mobile devices. 28 This plugin allows you to turn your WordPress menu into a select box below a browser viewport width of your choice. 30 **Mobile Menu Made Simple** 29 31 30 This is the successor plugin of former, unfortunately abandoned Responsive Select Menu by sevenspark. 31 It has been made translation-ready, PHP 7.4 ready and its code has been rewritten and restructured to work with WordPress 5.x.x 32 Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices. 32 33 33 ** Features ** 34 **Key Benefits:** 35 ✅ Better mobile navigation 36 ✅ No theme modifications needed 37 ✅ Works with any WordPress menu 38 ✅ Fully accessible 39 ✅ Customizable breakpoint 34 40 35 * Takes up less screen real estate on mobile devices 36 * Easier navigation for touch screens 37 * Works automatically - no need to add extra PHP code 41 **How it works:** The plugin detects when someone visits your site on a mobile device and automatically converts your menu into an easy-to-use dropdown. Desktop visitors see your normal menu unchanged. 38 42 39 Please find a live demo of the plugin here: [https://responsive-select-menu.saskialund.de/](https://responsive-select-menu.saskialund.de/) 43 **Perfect for:** Anyone who wants to improve their mobile site navigation without technical hassle. 40 44 41 ## Installation ## 45 **Technical note:** This plugin uses WordPress's native menu system and automatically detects screen size to show the appropriate menu format. It's built with modern WordPress standards and includes full accessibility support. 42 46 43 This section describes how to install the plugin and get it working. 47 ## 🚀 Version 2.0.0 - Complete Restructuring 44 48 45 1. Upload the plugin zip through your WordPress admin 46 1. Activate the plugin through the 'Plugins' menu in WordPress 47 1. Navigate to Appearance > Responsive Select to configure your menu 49 ### New Architecture 48 50 51 ``` 52 responsive-mobile-select-menu/ 53 ├── responsive-mobile-select-menu.php # Main file with autoloader 54 ├── includes/ # Core classes 55 │ ├── class-plugin.php # Main plugin class 56 │ ├── class-settings.php # Settings management 57 │ ├── class-menu-walker.php # Custom menu walker 58 │ └── class-asset-manager.php # Asset management 59 ├── admin/ # Admin area 60 │ ├── class-admin.php # Admin functionality 61 │ ├── views/ 62 │ │ └── admin-page.php # Admin interface 63 │ ├── css/ 64 │ │ └── admin.css # Admin styles 65 │ └── js/ 66 │ └── admin.js # Admin JavaScript 67 ├── assets/ # Frontend assets 68 │ ├── css/ 69 │ │ └── responsive-menu.css # Frontend styles 70 │ └── js/ 71 │ └── responsive-menu.js # Frontend JavaScript 72 └── languages/ # Translations 73 └── *.po, *.mo 74 ``` 49 75 50 ## Frequently Asked Questions ##76 ### Technical Improvements 51 77 52 ** Do I have to have a "Navigate" item as my first item ** 78 #### 🏗️ **Modern OOP Architecture** 79 - **Namespace**: `ResponsiveMobileSelect\` 80 - **Autoloader**: PSR-4 compatible 81 - **Dependency Injection**: Clean dependencies 82 - **Single Responsibility**: Each class has a clear purpose 53 83 54 You can change the name of this item, but it has to exist. Otherwise, you won't be able to navigate to the first item in the menu 55 if you're not using the "Show currently selected item" - even if you have that option enabled, the issue would still exist on pages not 56 in the menu. 84 #### 🔒 **Security & Standards** 85 - **WPCS Compliance**: Full WordPress Coding Standards 86 - **Input Validation**: Comprehensive sanitization 87 - **Nonce Verification**: Secure forms 88 - **Capability Checks**: Proper permission validation 57 89 58 ** It doesn't work ** 90 #### ♿ **Accessibility (WCAG 2.1)** 91 - **ARIA Labels**: Full screen reader support 92 - **Keyboard Navigation**: Complete keyboard accessibility 93 - **High Contrast**: Support for high contrast modes 94 - **Reduced Motion**: Respects user preferences 59 95 60 If your theme creates a menu the standard way with wp_nav_menu, it should work. 96 #### 🎨 **Modern UI/UX** 97 - **Responsive Design**: Mobile-first approach 98 - **Dark Mode**: Support for dark modes 99 - **Touch Optimized**: Optimized for touch devices 100 - **Performance**: Optimized asset loading 101 - **Menu ID Support**: Works with both theme locations and specific menu IDs 61 102 103 ### WordPress 6.5+ Compatibility 62 104 105 - ✅ **Block Themes**: Full FSE support 106 - ✅ **Site Editor**: Compatible with Full Site Editing 107 - ✅ **REST API**: Modern API integration 108 - ✅ **Hooks API**: Comprehensive filters and actions 63 109 64 ## Screenshots ##110 ### Developer API 65 111 66 1. Responsive select menu on the iPhone/iPod Touch 67 2. Responsive select menu Control Panel 112 #### Hooks & Filters 68 113 69 ## Changelog ## 114 ```php 115 // Customize breakpoint 116 add_filter('responsive_mobile_select_breakpoint', function($breakpoint) { 117 return 768; // Custom breakpoint 118 }); 70 119 71 **1.1.4** 72 * readme update and versioning 73 * Compatibility with WordPress 6.6.9 120 // Modify menu locations 121 add_filter('responsive_mobile_select_locations', function($locations) { 122 $locations[] = 'custom-location'; 123 return $locations; 124 }); 74 125 75 **1.1.3** 76 * readme update and versioning 77 * Compatibility with WordPress 6.4.x 126 // Custom CSS classes 127 add_filter('responsive_mobile_select_css_classes', function($classes) { 128 $classes[] = 'my-custom-class'; 129 return $classes; 130 }); 131 ``` 78 132 79 **1.1.2** 80 * readme update and versioning 81 * typo correction regarding compatibility with WordPress 6.3.1 133 #### Actions 82 134 83 **1.1.1** 84 * readme update and versioning85 * Compatibility with PHP 8.0 and 8.1 135 ```php 136 // Before menu rendering 137 do_action('responsive_mobile_select_before_menu', $args); 86 138 87 **1.1.0** 88 * readme update and versioning 89 * Compatibility with WordPress version 5.6.x and upcoming 5.7 139 // After menu rendering 140 do_action('responsive_mobile_select_after_menu', $args); 90 141 91 **1.0.5** 92 * readme update and versioning 93 * Feature: added accessibility aria code (thanks @haefele for asking) 94 * Compatibility with PHP 7.4 142 // Settings saved 143 do_action('responsive_mobile_select_settings_saved', $settings); 144 ``` 95 145 96 **1.0.4** 97 * readme update and versioning 146 ### Installation & Usage 98 147 99 **1.0.3** 100 * Fix: under certain circumstances settings weren't saving - refactored 148 1. **Install plugin** via WordPress Admin 149 2. **Activate plugin** under Plugins 150 3. **Configure settings** under Appearance > Responsive Menu 151 4. **Done!** The plugin works automatically 101 152 102 **1.0.2** 103 * Fix: under certain circumstances settings weren't saving. 153 ### Configuration 104 154 105 **1.0.1** 106 * readme update and versioning 155 #### Basic Settings 156 - **Maximum Width**: Breakpoint for mobile view (320-1920px) 157 - **Placeholder Text**: Text for first select option 158 - **Indent Character**: Character for submenu indentation 159 - **Maximum Depth**: Limit of menu depth 107 160 108 **1.0.0** 161 #### Advanced Settings 162 - **Menu Locations**: Select specific theme locations 163 - **Exclude Empty Links**: Hide items without URL 164 - **Highlight Current Page**: Mark current page in select 109 165 110 * Initial version 111 * Forked from Responsive Select Menu Plugin 1.7 which is 4 years old and unfortunately abandoned by its developer :( 112 * Added Translation Readyness 113 * Added German formal and informal translation files 114 * Compatibility with PHP 7.3 115 * Bugfix due to PHP 7.3 debug_log warnings 116 * Removed Ads and external hotlinked images from ControlPanel 166 ### Performance Optimizations 167 168 - **Lazy Loading**: Load assets only when needed 169 - **Minification**: CSS/JS automatically optimized 170 - **Caching**: Efficient database queries 171 - **Debouncing**: Optimized event handlers 172 173 ### Browser Compatibility 174 175 - ✅ **Chrome**: 90+ 176 - ✅ **Firefox**: 88+ 177 - ✅ **Safari**: 14+ 178 - ✅ **Edge**: 90+ 179 - ✅ **Mobile Safari**: 14+ 180 - ✅ **Chrome Mobile**: 90+ 181 182 ### Support & Development 183 184 - **WordPress.org**: [Support Forum](https://wordpress.org/support/plugin/responsive-mobile-select-menu/) 185 - **GitHub**: [Issues & Pull Requests](https://github.com/saskialund/responsive-mobile-select-menu) 186 - **Website**: [Plugin Website](https://www.saskialund.de/responsive-mobile-select-menu/) 187 188 ### License 189 190 GPL v2 or later - [License Details](https://www.gnu.org/licenses/gpl-2.0.html) 191 192 --- 193 194 **Developed with ❤️ by Saskia Teichmann** -
responsive-mobile-select-menu/trunk/readme.txt
r3135517 r3344449 1 1 === Responsive Mobile Select Menu === 2 Contributors: Jyria , sevenspark2 Contributors: Jyria 3 3 Donate link: https://www.saskialund.de/donate/ 4 Tags: responsive, menu, select, drop down, mobile menu5 Requires at least: 4.66 Tested up to: 6. 6.97 Requires PHP: 7.48 Stable tag: 1.1.44 Tags: responsive, menu, select, drop down, accessible mobile menu 5 Requires at least: 6.5 6 Tested up to: 6.8 7 Requires PHP: 8.0 8 Stable tag: 2.0.0 9 9 License: GPLv2 or later 10 License URI: http ://www.gnu.org/licenses/gpl-2.0.html10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 12 The Responsive Mobile Select Menu plugin automatically turns any WordPress Menu into a select box / dropdown on mobile devices. 12 Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices. 13 13 14 14 == Description == 15 15 16 One common UI paradigm for navigation menus with responsive design is to display a select box (form element) for mobile devices. 17 This plugin allows you to turn your WordPress menu into a select box below a browser viewport width of your choice. 16 **Key Benefits:** 17 ✅ Better mobile navigation 18 ✅ No theme modifications needed 19 ✅ Works with any WordPress menu 20 ✅ Fully accessible 21 ✅ Customizable breakpoint 18 22 19 This is the successor plugin of former, unfortunately abandoned Responsive Select Menu by sevenspark. 20 It has been made translation-ready, PHP 8 ready and its code has been rewritten and restructured to work with WordPress versions greater than 5.x.x 23 **How it works:** The plugin detects when someone visits your site on a mobile device and automatically converts your menu into an easy-to-use dropdown. Desktop visitors see your normal menu unchanged. 21 24 22 Please find a live demo of the plugin here: [https://responsive-select-menu.saskialund.de/](https://responsive-select-menu.saskialund.de/) 25 **Perfect for:** Anyone who wants to improve their mobile site navigation without technical hassle. 26 27 **Mobile Menu Made Simple** 28 29 Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices. 30 31 **Key Benefits:** 32 ✅ Better mobile navigation 33 ✅ No theme modifications needed 34 ✅ Works with any WordPress menu 35 ✅ Fully accessible 36 ✅ Customizable breakpoint 37 38 **How it works:** The plugin detects when someone visits your site on a mobile device and automatically converts your menu into an easy-to-use dropdown. Desktop visitors see your normal menu unchanged. 39 40 **Perfect for:** Anyone who wants to improve their mobile site navigation without technical hassle. 41 42 **Technical note:** This plugin uses WordPress's native menu system and automatically detects screen size to show the appropriate menu format. It's built with modern WordPress standards and includes full accessibility support. 23 43 24 44 = Features = 25 45 26 * Takes up less screen real estate on mobile devices 27 * Easier navigation for touch screens 28 * Works automatically - no need to add extra PHP code 46 * **Modern Architecture**: Built with PHP 8.0+ features and WordPress Coding Standards (WPCS) 47 * **Full Accessibility**: WCAG 2.1 compliant with ARIA labels, keyboard navigation, and screen reader support 48 * **Responsive Design**: Mobile-first approach with customizable breakpoints 49 * **Theme Compatibility**: Works with all modern WordPress themes including block themes 50 * **Performance Optimized**: Efficient asset loading and minimal overhead 51 * **Security Focused**: Proper nonce verification, input sanitization, and capability checks 52 * **Translation Ready**: Full internationalization support 53 * **Customizable**: Extensive settings panel with real-time preview 54 * **Developer Friendly**: Clean API, hooks, and filters for customization 55 56 = What's New in 2.0.0 = 57 58 * **Complete Rewrite**: Modern object-oriented architecture with namespaces 59 * **WordPress 6.5+ Ready**: Full compatibility with latest WordPress features 60 * **Accessibility First**: WCAG 2.1 compliance with comprehensive ARIA support 61 * **Modern Admin Interface**: Clean, responsive settings panel 62 * **Performance Improvements**: Optimized asset loading and caching 63 * **Security Enhancements**: Proper sanitization and validation 64 * **Developer API**: Hooks and filters for customization 65 * **Block Theme Support**: Works seamlessly with Full Site Editing 29 66 30 67 == Installation == … … 36 73 1. Navigate to Appearance > Responsive Menu to configure your new mobile select menu 37 74 38 39 75 == Frequently Asked Questions == 40 76 41 77 = Do I have to have a "Navigate" item as my first item = 42 78 43 You can change the name of this item, but it has to exist. Otherwise, you won't be able to navigate to the first item in the menu 44 if you're not using the "Show currently selected item" - even if you have that option enabled, the issue would still exist on pages not 45 in the menu. 79 You can change the name of this item in the settings, but it has to exist. Otherwise, you won't be able to navigate to the first item in the menu if you're not using the "Show currently selected item" option. 46 80 47 81 = It doesn't work = 48 82 49 If your theme creates a menu the standard way with wp_nav_menu(), it should work. If not, make sure you either post a support request in this plugin's WordPress support forum or maybe approach your theme's developer.83 If your theme creates a menu the standard way with wp_nav_menu(), it should work. If not, make sure you either post a support request in this plugin's WordPress support forum or maybe approach your theme's developer. 50 84 85 = Will this change my desktop menu? = 86 87 No! Your desktop menu remains completely unchanged. The plugin only affects mobile devices and small screens. 88 89 = Do I need to modify my theme? = 90 91 No theme modifications are required. The plugin works with any WordPress theme that uses standard WordPress menus. 92 93 = Can I customize when the mobile menu appears? = 94 95 Yes! You can set the breakpoint (screen width) when the mobile menu should appear in the settings panel. 96 97 = Can I use specific menu IDs instead of theme locations? = 98 99 Yes! You can now select specific menus by their ID in the plugin settings. This is useful when you use `wp_nav_menu(array('menu' => '73'))` in your templates instead of theme locations. 100 101 = What are the default settings? = 102 103 By default, no menu activation options are selected. You need to manually choose either "All menu locations", "All menu IDs", or select specific menu locations/IDs for the plugin to work. 104 105 = Is this plugin accessible? = 106 107 Yes! Version 2.0.0 includes full WCAG 2.1 compliance with proper ARIA labels, keyboard navigation, screen reader support, and high contrast mode compatibility. 108 109 = Does it work with block themes? = 110 111 Yes! The plugin is fully compatible with WordPress block themes and Full Site Editing features. 112 113 = Can I customize the breakpoint? = 114 115 Yes! You can set any breakpoint between 320px and 1920px in the settings panel. 116 117 = Is it compatible with my theme? = 118 119 The plugin works with any theme that uses WordPress's standard wp_nav_menu() function. It includes specific compatibility fixes for popular themes like Genesis, Twenty Twenty-One, and others. 51 120 52 121 == Screenshots == 53 122 54 123 1. Responsive mobile select menu on the iPhone/iPod Touch 124 2. Modern admin settings panel with responsive design 125 3. Accessibility features demonstration with ARIA support 126 4. Block theme compatibility showcase 55 127 56 128 == Changelog == 129 130 = 2.0.0 = 131 * **Complete plugin rewrite** with modern architecture 132 * **WordPress 6.5+ compatibility** and block theme support 133 * **Full accessibility implementation** (WCAG 2.1 compliant) 134 * **Modern admin interface** with responsive design 135 * **Performance optimizations** and security enhancements 136 * **Developer-friendly API** with hooks and filters 137 * **Translation improvements** and internationalization 138 * **Mobile-first responsive design** with customizable breakpoints 139 * **Theme compatibility improvements** for modern themes 140 * **Code quality improvements** following WordPress Coding Standards 141 * **Menu ID support** - now works with both theme locations and specific menu IDs 142 * **Improved compatibility** - manual file loading for better server compatibility 57 143 58 144 = 1.1.4 = … … 79 165 * readme update and versioning 80 166 * Feature: added accessibility aria code (thanks @haefele for asking) 81 * Compatibility with PHP 7.4167 * Compatibility with PHP 8.0+ 82 168 83 169 = 1.0.4 = … … 98 184 * Bugfix due to PHP 7.3 debug_log warnings 99 185 * Removed Ads and external hotlinked images from ControlPanel 186 187 == Upgrade Notice == 188 189 = 2.0.0 = 190 This is a major update with a complete rewrite. Please test thoroughly on a staging site before updating on production. The new version includes significant improvements in accessibility, performance, and WordPress compatibility. Requires WordPress 6.5+ and PHP 8.0+. -
responsive-mobile-select-menu/trunk/responsive-mobile-select-menu.php
r3135517 r3344449 3 3 * Plugin Name: Responsive Mobile Select Menu 4 4 * Plugin URI: https://www.saskialund.de/responsive-mobile-select-menu/ 5 * Description: Turn your menu into a native browser-UI select box at small viewport sizes 6 * Version: 1.1.4 5 * Description: Mobile Menu Made Simple - Automatically converts your WordPress menu into a touch-friendly dropdown on mobile devices. No theme modifications needed. 6 * Version: 2.0.0 7 * Requires at least: 6.5 8 * Tested up to: 6.8 9 * Requires PHP: 8.0 7 10 * Author: Saskia Teichmann 8 11 * Author URI: https://www.saskialund.de 9 * Text Domain: rms10 * Domain Path: /languages/11 * Contributors: Jyria12 * License: GPLv2 or later 13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 14 * Text Domain: responsive-mobile-select-menu 12 15 * 13 * @package RMS_MENU\Main 14 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or higher 15 * @copyright 2024 Saskia Teichmann, Twitter @SaskiaLund 16 * @package ResponsiveMobileSelect 17 * @since 2.0.0 16 18 */ 17 19 18 define( 'RMS_VERSION', '1.1.4' ); 19 define( 'RMS_SETTINGS', 'responsive-mobile-select-menu' ); 20 21 if ( ! defined( 'RMS_FILE' ) ) { 22 define( 'RMS_FILE', __FILE__ ); 20 // Direktzugriff verhindern. 21 if ( ! defined( 'ABSPATH' ) ) { 22 exit; 23 23 } 24 24 25 $rms_dir = plugin_dir_path( RMS_FILE ); 26 $rms_uri = plugin_dir_url( RMS_FILE ); 27 require_once $rms_dir . '/classes/class-rms-options-panel.php'; // Options Panel. 28 require_once $rms_dir . '/classes/class-rms-main.php'; // Options Panel. 29 $rms_panel_css = $rms_uri . 'assets/css/rms-options.css'; 30 $rms_panel_js = $rms_uri . 'assets/js/rms-options.js'; 31 $rms_main = new RMS_Main(); 25 // Plugin-Konstanten. 26 define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0.0' ); 27 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_FILE', __FILE__ ); 28 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 29 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 30 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); 32 31 33 require_once $rms_dir . '/classes/class-rms-walker.php'; 32 // Manuell benötigte Dateien laden (klare Abhängigkeiten, kein Autoloader vorausgesetzt). 33 require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-settings.php'; 34 require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-menu-walker.php'; 35 require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-asset-manager.php'; 36 require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-plugin.php'; 37 require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'admin/class-admin.php'; 34 38 35 39 /** 36 * Use textdomain for translation 40 * Plugin initialisieren (nur Laufzeit-Setup, keine Migrationen). 41 * 42 * @since 2.0.0 37 43 */ 38 function rms_init() { 39 load_plugin_textdomain( 'rms', false, 'responsive-mobile-select-menu/languages' ); 44 function responsive_mobile_select_init() { 45 // Haupt-Plugin-Klasse initialisieren. 46 $plugin = new ResponsiveMobileSelect\Core\Plugin(); 47 $plugin->init(); 40 48 } 41 add_action( 'init', 'rms_init' ); 49 add_action( 'plugins_loaded', 'responsive_mobile_select_init' ); 50 51 /** 52 * Einmalige Updates/Migrationen ausführen. 53 * - nur im Site-Admin (nicht Netzwerk-Admin) 54 * - nur bei Versionssprung 55 * - strictly per-site (keine anderen Blogs anfassen) 56 * 57 * @since 2.0.0 58 */ 59 function responsive_mobile_select_handle_updates() { 60 // Nie im Netzwerk-Admin laufen lassen. 61 if ( is_network_admin() ) { 62 return; 63 } 64 65 $current_version = get_option( 'responsive_mobile_select_version', '0' ); 66 $target_version = RESPONSIVE_MOBILE_SELECT_VERSION; 67 68 // Nichts zu tun, wenn DB-Version bereits aktuell. 69 if ( version_compare( $current_version, $target_version, '>=' ) ) { 70 return; 71 } 72 73 // Alte Optionen aus v1/vorherigen Versionen bereinigen – nur im aktuellen Blog. 74 $old_options = array( 75 'rmsops_responsive-mobile-select-menu-menu', 76 'responsive_mobile_select_settings', // ggf. alte v2-Vorversion. 77 ); 78 79 foreach ( $old_options as $old_option ) { 80 delete_option( $old_option ); 81 } 82 83 // Neue Default-Option nur anlegen, wenn sie fehlt (kein Überschreiben bestehender Werte). 84 if ( false === get_option( 'rms_plugin_settings_v2', false ) ) { 85 $default_options = array( 86 'max_width' => 960, 87 'menu_locations' => array(), 88 'menu_ids' => array(), 89 'activate_all' => '0', 90 'activate_all_ids' => '0', 91 'placeholder_text' => __( 'Navigate', 'responsive-mobile-select-menu' ), 92 'indent_character' => '— ', 93 'exclude_empty_links' => '0', 94 'highlight_current' => '0', 95 'max_depth' => 0, 96 ); 97 98 // Autoload bewusst 'no', damit Admin-Option nicht global geladen wird. 99 add_option( 'rms_plugin_settings_v2', $default_options, '', 'no' ); 100 } 101 102 // DB-Version hochziehen und „Update komplett“-Flag setzen. 103 update_option( 'responsive_mobile_select_version', $target_version ); 104 update_option( 'responsive_mobile_select_update_completed', true ); 105 } 106 add_action( 'admin_init', 'responsive_mobile_select_handle_updates' ); 107 108 /** 109 * Aktivierungshook (strictly per site). 110 * - Falls versehentlich netzwerkweit aktiviert: brich ab, fasse nichts an. 111 * 112 * @since 2.0.0 113 * 114 * @param bool $network_wide Ob Netzwerkaktivierung versucht wurde. 115 */ 116 function responsive_mobile_select_activate( $network_wide ) { 117 // Niemals netzwerkweit aktivieren/arbeiten. 118 if ( is_multisite() && $network_wide ) { 119 // Keine DB-Änderungen; kurzer Hinweis. 120 return; 121 } 122 123 // Im aktuellen Blog alte Optionen bereinigen. 124 $old_options = array( 125 'rmsops_responsive-mobile-select-menu', 126 'responsive_mobile_select_settings', 127 ); 128 129 foreach ( $old_options as $old_option ) { 130 delete_option( $old_option ); 131 } 132 133 // Defaults nur anlegen, wenn Option noch nicht existiert. 134 if ( false === get_option( 'rms_plugin_settings_v2', false ) ) { 135 $default_options = array( 136 'max_width' => 960, 137 'menu_locations' => array(), 138 'menu_ids' => array(), 139 'activate_all' => '0', 140 'activate_all_ids' => '0', 141 'placeholder_text' => __( 'Navigate', 'responsive-mobile-select-menu' ), 142 'indent_character' => '— ', 143 'exclude_empty_links' => '0', 144 'highlight_current' => '0', 145 'max_depth' => 0, 146 ); 147 148 add_option( 'rms_plugin_settings_v2', $default_options, '', 'no' ); 149 } 150 151 update_option( 'responsive_mobile_select_version', RESPONSIVE_MOBILE_SELECT_VERSION ); 152 } 153 register_activation_hook( __FILE__, 'responsive_mobile_select_activate' ); 154 155 /** 156 * Deaktivierungshook. 157 * – Beim Deaktivieren **keine** Optionen löschen (übliches WP-Verhalten). 158 * – Für komplettes Entfernen siehe Uninstall-Hook. 159 * 160 * @since 2.0.0 161 */ 162 function responsive_mobile_select_deactivate() { 163 // Nichts löschen – bewusst leer. 164 } 165 register_deactivation_hook( __FILE__, 'responsive_mobile_select_deactivate' ); 166 167 /** 168 * Uninstall-Hook: vollständiges Aufräumen **nur** im aktuellen Blog. 169 * 170 * @since 2.0.0 171 */ 172 function responsive_mobile_select_uninstall() { 173 $plugin_options = array( 174 'rms_plugin_settings_v2', 175 'rmsops_responsive-mobile-select-menu', 176 'responsive_mobile_select_settings', 177 'responsive_mobile_select_version', 178 'responsive_mobile_select_update_completed', 179 ); 180 181 foreach ( $plugin_options as $option ) { 182 delete_option( $option ); 183 } 184 } 185 register_uninstall_hook( __FILE__, 'responsive_mobile_select_uninstall' );
Note: See TracChangeset
for help on using the changeset viewer.