Plugin Directory

Changeset 3344449


Ignore:
Timestamp:
08/14/2025 08:31:21 AM (6 months ago)
Author:
Jyria
Message:

Version 2.0.0: Complete plugin refactoring

Location:
responsive-mobile-select-menu/trunk
Files:
15 added
6 deleted
3 edited

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
    212
    3 **Author URI:** https://www.saskialund.de
     13**Mobile Menu Made Simple**
    414
    5 **Contributors:** Jyria
     15Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices.
    616
    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
    823
    9 **Tags:** responsive, menu, select, drop down, dropdown, mobile menu
     24**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.
    1025
    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.
    2427
    2528## Description ##
    2629
    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**
    2931
    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
     32Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices.
    3233
    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
    3440
    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.
    3842
    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.
    4044
    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.
    4246
    43 This section describes how to install the plugin and get it working.
     47## 🚀 Version 2.0.0 - Complete Restructuring
    4448
    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
    4850
     51```
     52responsive-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```
    4975
    50 ## Frequently Asked Questions ##
     76### Technical Improvements
    5177
    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
    5383
    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
    5789
    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
    5995
    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
    61102
     103### WordPress 6.5+ Compatibility
    62104
     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
    63109
    64 ## Screenshots ##
     110### Developer API
    65111
    66 1. Responsive select menu on the iPhone/iPod Touch
    67 2. Responsive select menu Control Panel
     112#### Hooks & Filters
    68113
    69 ## Changelog ##
     114```php
     115// Customize breakpoint
     116add_filter('responsive_mobile_select_breakpoint', function($breakpoint) {
     117    return 768; // Custom breakpoint
     118});
    70119
    71 **1.1.4**
    72 * readme update and versioning
    73 * Compatibility with WordPress 6.6.9
     120// Modify menu locations
     121add_filter('responsive_mobile_select_locations', function($locations) {
     122    $locations[] = 'custom-location';
     123    return $locations;
     124});
    74125
    75 **1.1.3**
    76 * readme update and versioning
    77 * Compatibility with WordPress 6.4.x
     126// Custom CSS classes
     127add_filter('responsive_mobile_select_css_classes', function($classes) {
     128    $classes[] = 'my-custom-class';
     129    return $classes;
     130});
     131```
    78132
    79 **1.1.2**
    80 * readme update and versioning
    81 * typo correction regarding compatibility with WordPress 6.3.1
     133#### Actions
    82134
    83 **1.1.1**
    84 * readme update and versioning
    85 * Compatibility with PHP 8.0 and 8.1
     135```php
     136// Before menu rendering
     137do_action('responsive_mobile_select_before_menu', $args);
    86138
    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
     140do_action('responsive_mobile_select_after_menu', $args);
    90141
    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
     143do_action('responsive_mobile_select_settings_saved', $settings);
     144```
    95145
    96 **1.0.4**
    97 * readme update and versioning
     146### Installation & Usage
    98147
    99 **1.0.3**
    100 * Fix: under certain circumstances settings weren't saving - refactored
     1481. **Install plugin** via WordPress Admin
     1492. **Activate plugin** under Plugins
     1503. **Configure settings** under Appearance > Responsive Menu
     1514. **Done!** The plugin works automatically
    101152
    102 **1.0.2**
    103 * Fix: under certain circumstances settings weren't saving.
     153### Configuration
    104154
    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
    107160
    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
    109165
    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
     190GPL 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  
    11=== Responsive Mobile Select Menu ===
    2 Contributors: Jyria, sevenspark
     2Contributors: Jyria
    33Donate link: https://www.saskialund.de/donate/
    4 Tags: responsive, menu, select, drop down, mobile menu
    5 Requires at least: 4.6
    6 Tested up to: 6.6.9
    7 Requires PHP: 7.4
    8 Stable tag: 1.1.4
     4Tags: responsive, menu, select, drop down, accessible mobile menu
     5Requires at least: 6.5
     6Tested up to: 6.8
     7Requires PHP: 8.0
     8Stable tag: 2.0.0
    99License: GPLv2 or later
    10 License URI: http://www.gnu.org/licenses/gpl-2.0.html
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 The Responsive Mobile Select Menu plugin automatically turns any WordPress Menu into a select box / dropdown on mobile devices.
     12Your WordPress menu automatically becomes a touch-friendly dropdown on mobile devices.
    1313
    1414== Description ==
    1515
    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
    1822
    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.
    2124
    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
     29Your 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.
    2343
    2444= Features =
    2545
    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
    2966
    3067== Installation ==
     
    36731. Navigate to Appearance > Responsive Menu to configure your new mobile select menu
    3774
    38 
    3975== Frequently Asked Questions ==
    4076
    4177= Do I have to have a "Navigate" item as my first item =
    4278
    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.
     79You 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.
    4680
    4781= It doesn't work =
    4882
    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.
     83If 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.
    5084
     85= Will this change my desktop menu? =
     86
     87No! 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
     91No 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
     95Yes! 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
     99Yes! 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
     103By 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
     107Yes! 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
     111Yes! The plugin is fully compatible with WordPress block themes and Full Site Editing features.
     112
     113= Can I customize the breakpoint? =
     114
     115Yes! You can set any breakpoint between 320px and 1920px in the settings panel.
     116
     117= Is it compatible with my theme? =
     118
     119The 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.
    51120
    52121== Screenshots ==
    53122
    541231. Responsive mobile select menu on the iPhone/iPod Touch
     1242. Modern admin settings panel with responsive design
     1253. Accessibility features demonstration with ARIA support
     1264. Block theme compatibility showcase
    55127
    56128== 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
    57143
    58144= 1.1.4 =
     
    79165* readme update and versioning
    80166* Feature: added accessibility aria code (thanks @haefele for asking)
    81 * Compatibility with PHP 7.4
     167* Compatibility with PHP 8.0+
    82168
    83169= 1.0.4 =
     
    98184* Bugfix due to PHP 7.3 debug_log warnings
    99185* Removed Ads and external hotlinked images from ControlPanel
     186
     187== Upgrade Notice ==
     188
     189= 2.0.0 =
     190This 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  
    33 * Plugin Name: Responsive Mobile Select Menu
    44 * 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
    710 * Author: Saskia Teichmann
    811 * Author URI: https://www.saskialund.de
    9  * Text Domain: rms
    10  * Domain Path: /languages/
    11  * Contributors: Jyria
     12 * License: GPLv2 or later
     13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     14 * Text Domain: responsive-mobile-select-menu
    1215 *
    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
    1618 */
    1719
    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.
     21if ( ! defined( 'ABSPATH' ) ) {
     22    exit;
    2323}
    2424
    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.
     26define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0.0' );
     27define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_FILE', __FILE__ );
     28define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     29define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     30define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    3231
    33 require_once $rms_dir . '/classes/class-rms-walker.php';
     32// Manuell benötigte Dateien laden (klare Abhängigkeiten, kein Autoloader vorausgesetzt).
     33require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-settings.php';
     34require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-menu-walker.php';
     35require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-asset-manager.php';
     36require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'includes/class-plugin.php';
     37require_once RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR . 'admin/class-admin.php';
    3438
    3539/**
    36  * Use textdomain for translation
     40 * Plugin initialisieren (nur Laufzeit-Setup, keine Migrationen).
     41 *
     42 * @since 2.0.0
    3743 */
    38 function rms_init() {
    39     load_plugin_textdomain( 'rms', false, 'responsive-mobile-select-menu/languages' );
     44function responsive_mobile_select_init() {
     45    // Haupt-Plugin-Klasse initialisieren.
     46    $plugin = new ResponsiveMobileSelect\Core\Plugin();
     47    $plugin->init();
    4048}
    41 add_action( 'init', 'rms_init' );
     49add_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 */
     59function 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}
     106add_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 */
     116function 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}
     153register_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 */
     162function responsive_mobile_select_deactivate() {
     163    // Nichts löschen – bewusst leer.
     164}
     165register_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 */
     172function 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}
     185register_uninstall_hook( __FILE__, 'responsive_mobile_select_uninstall' );
Note: See TracChangeset for help on using the changeset viewer.