Plugin Directory

Changeset 3344552


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

trunk Version 2.0.3

Location:
responsive-mobile-select-menu/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • responsive-mobile-select-menu/trunk/assets/css/responsive-menu.css

    r3344449 r3344552  
    1010    display: none !important;
    1111    width: 100%;
    12     max-width: 300px;
    13     padding: 12px 16px;
    14     border: 2px solid #ddd;
    15     border-radius: 6px;
    16     background-color: #fff;
    17     font-size: 16px;
    18     line-height: 1.4;
     12    max-width: 200px;
     13    padding: 8px 12px;
     14    font-size: inherit;
    1915    font-family: inherit;
    20     color: #333;
     16    color: inherit;
     17    border: 1px solid #ddd;
    2118    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    2219    background-repeat: no-repeat;
     
    3936}
    4037
    41 /* Hover state */
    42 .responsive-menu-select:hover {
    43     border-color: #999;
    44 }
    45 
    46 /* Active state */
    47 .responsive-menu-select:active {
    48     transform: translateY(1px);
    49 }
    50 
    5138/* Disabled state */
    5239.responsive-menu-select:disabled {
     
    5946.responsive-menu-select option {
    6047    padding: 8px 12px;
    61     font-size: 14px;
    62     line-height: 1.3;
     48    font-size: inherit;
     49    line-height: inherit;
    6350}
    6451
     
    122109@media (max-width: 768px) {
    123110    .responsive-menu-select {
    124         font-size: 18px; /* Larger touch target */
    125         padding: 14px 18px;
     111        font-size: 18px; /* Larger touch target, you may adjust this in your custom css if you don't need or care about accessibility */
     112        padding: 6px 34px 6px 12px;
    126113    }
    127114}
     
    131118        max-width: 100%;
    132119        font-size: 16px;
    133         padding: 12px 16px;
    134120    }
    135121}
     
    161147/* Dark mode support */
    162148@media (prefers-color-scheme: dark) {
    163     .responsive-menu-select {
    164         background-color: #2c2c2c;
    165         border-color: #555;
    166         color: #fff;
    167     }
    168    
    169149    .responsive-menu-select option {
    170150        background-color: #2c2c2c;
  • responsive-mobile-select-menu/trunk/assets/js/responsive-menu.js

    r3344449 r3344552  
    3131            this.bindEvents();
    3232            this.updateVisibility();
     33           
     34            // Restore saved selections on initial load
     35            this.restoreAllSelections();
     36           
    3337            this.isInitialized = true;
    3438        }
     
    6569                return;
    6670            }
     71
     72            // Save the selected option to localStorage for persistence
     73            this.saveSelectedOption($select, selectedValue);
    6774
    6875            // Validate URL
     
    7885
    7986        /**
     87         * Save selected option to localStorage
     88         */
     89        saveSelectedOption($select, value) {
     90            const menuId = this.getMenuIdentifier($select);
     91            if (menuId) {
     92                localStorage.setItem(`responsive-menu-selection-${menuId}`, value);
     93            }
     94        }
     95
     96        /**
     97         * Restore selected option from localStorage
     98         */
     99        restoreSelectedOption($select) {
     100            const menuId = this.getMenuIdentifier($select);
     101            if (menuId) {
     102                const savedValue = localStorage.getItem(`responsive-menu-selection-${menuId}`);
     103                if (savedValue && savedValue !== '') {
     104                    // Check if the saved option still exists in the select
     105                    const $option = $select.find(`option[value="${savedValue}"]`);
     106                    if ($option.length > 0) {
     107                        $select.val(savedValue);
     108                        return true;
     109                    }
     110                }
     111            }
     112            return false;
     113        }
     114
     115        /**
     116         * Get unique identifier for the menu
     117         */
     118        getMenuIdentifier($select) {
     119            // Use data attributes from the select element itself
     120            const themeLocation = $select.attr('data-theme-location');
     121            const menuId = $select.attr('data-menu-id');
     122           
     123            if (themeLocation && themeLocation !== '') {
     124                return `theme-${themeLocation}`;
     125            }
     126           
     127            if (menuId && menuId !== '') {
     128                return `menu-${menuId}`;
     129            }
     130           
     131            // Fallback: use the select's position in the document
     132            return `select-${$select.index()}`;
     133        }
     134
     135        /**
     136         * Restore all saved selections on initial load
     137         */
     138        restoreAllSelections() {
     139            this.selects.each((index, select) => {
     140                const $select = $(select);
     141                this.restoreSelectedOption($select);
     142            });
     143        }
     144
     145        /**
    80146         * Update visibility based on viewport width
    81147         */
     
    96162                    $select.addClass('is-mobile');
    97163                    $desktopMenu.addClass('is-hidden');
     164                   
     165                    // Restore previously selected option if available
     166                    this.restoreSelectedOption($select);
    98167                } else {
    99168                    // Hide select, show desktop menu
     
    260329            $('#responsive-menu-announcement').remove();
    261330
     331            // Clean up localStorage entries for this instance
     332            this.cleanupLocalStorage();
     333
    262334            this.isInitialized = false;
     335        }
     336
     337        /**
     338         * Clean up localStorage entries
     339         */
     340        cleanupLocalStorage() {
     341            // Remove all responsive menu related localStorage entries
     342            const keysToRemove = [];
     343            for (let i = 0; i < localStorage.length; i++) {
     344                const key = localStorage.key(i);
     345                if (key && key.startsWith('responsive-menu-selection-')) {
     346                    keysToRemove.push(key);
     347                }
     348            }
     349           
     350            keysToRemove.forEach(key => {
     351                localStorage.removeItem(key);
     352            });
    263353        }
    264354    }
  • responsive-mobile-select-menu/trunk/includes/class-plugin.php

    r3344502 r3344552  
    121121        }
    122122
     123        // Convert object to array if needed for safe access
     124        $args_array = is_object( $args ) ? (array) $args : $args;
     125       
    123126        // Add custom walker to collect options.
    124         $args['walker'] = $this->menu_walker;
     127        $args_array['walker'] = $this->menu_walker;
    125128       
    126129        // Add responsive-menu-desktop class to both container and menu classes for maximum compatibility.
    127         if ( isset( $args['container_class'] ) ) {
    128             $args['container_class'] .= ' responsive-menu-desktop';
     130        if ( isset( $args_array['container_class'] ) ) {
     131            $args_array['container_class'] .= ' responsive-menu-desktop';
    129132        } else {
    130             $args['container_class'] = 'responsive-menu-desktop';
    131         }
    132        
    133         if ( isset( $args['menu_class'] ) ) {
    134             $args['menu_class'] .= ' responsive-menu-desktop';
     133            $args_array['container_class'] = 'responsive-menu-desktop';
     134        }
     135       
     136        if ( isset( $args_array['menu_class'] ) ) {
     137            $args_array['menu_class'] .= ' responsive-menu-desktop';
    135138        } else {
    136             $args['menu_class'] = 'responsive-menu-desktop';
    137         }
     139            $args_array['menu_class'] = 'responsive-menu-desktop';
     140        }
     141       
     142        // Convert back to object if it was originally an object
     143        $args = is_object( $args ) ? (object) $args_array : $args_array;
    138144       
    139145        // Add filter to output select menu after the normal menu.
     
    170176        $max_width = $this->settings->get( 'max_width', 960 );
    171177
     178        // Convert object to array if needed for safe access
     179        $args_array = is_object( $args ) ? (array) $args : $args;
     180       
     181        // Get theme location for identification
     182        $theme_location = isset( $args_array['theme_location'] ) ? $args_array['theme_location'] : '';
     183        $menu_id = isset( $args_array['menu'] ) ? $args_array['menu'] : '';
     184       
     185        // Ensure both values are strings for safe output
     186        $theme_location = is_object( $theme_location ) ? $theme_location->slug : (string) $theme_location;
     187        $menu_id = is_object( $menu_id ) ? $menu_id->term_id : (string) $menu_id;
     188
    172189        $select_html = sprintf(
    173             '<select class="responsive-menu-select" aria-label="%1$s" aria-hidden="true" data-breakpoint="%2$s">
    174                 <option value="">%3$s</option>
    175                 %4$s
     190            '<select class="responsive-menu-select" aria-label="%1$s" aria-hidden="true" data-breakpoint="%2$s" data-theme-location="%3$s" data-menu-id="%4$s">
     191                <option value="" selected>%5$s</option>
     192                %6$s
    176193            </select>',
    177194            esc_attr__( 'Mobile Navigation', 'responsive-mobile-select-menu' ),
    178195            esc_attr( $max_width ),
     196            esc_attr( $theme_location ),
     197            esc_attr( $menu_id ),
    179198            esc_html( $placeholder ),
    180199            $select_options
     
    218237        // Check menu ID restrictions.
    219238        if ( ! empty( $menu_ids ) ) {
    220             if ( isset( $args['menu'] ) && in_array( (int) $args['menu'], $menu_ids, true ) ) {
    221                 return true;
     239            if ( isset( $args['menu'] ) ) {
     240                $menu_id = $args['menu'];
     241                // Ensure menu_id is an integer for comparison
     242                $menu_id_int = is_object( $menu_id ) ? $menu_id->term_id : (int) $menu_id;
     243                if ( in_array( $menu_id_int, $menu_ids, true ) ) {
     244                    return true;
     245                }
    222246            }
    223247        }
     
    251275            .responsive-menu-select.is-mobile {
    252276                display: inline-block;
    253                 width: 100%;
    254                 max-width: 200px;
    255                 padding: 8px 12px;
    256                 border: 1px solid #ccc;
    257                 border-radius: 4px;
    258                 background-color: #fff;
    259                 font-size: 16px;
    260                 line-height: 1.4;
    261             }
    262             .responsive-menu-select:focus {
    263                 outline: 2px solid #0073aa;
    264                 outline-offset: 2px;
    265277            }
    266278        }
  • responsive-mobile-select-menu/trunk/readme.md

    r3344502 r3344552  
    66**Tested up to:** 6.8 
    77**Requires PHP:** 8.0 
    8 **Stable tag:** 2.0.2 
     8**Stable tag:** 2.0.3 
    99**License:** GPLv2 or later 
    1010**License URI:** https://www.gnu.org/licenses/gpl-2.0.html 
     
    192192## Changelog
    193193
     194### 2.0.3 - Critical Bug Fixes & Object Handling
     195* **Object handling improvements** - Proper handling of WordPress menu objects and WP_Term instances
     196* **String conversion safety** - Enhanced safe conversion of menu IDs and theme locations
     197* **Code robustness** - Improved error handling for various WordPress menu argument types
     198* **User experience** - Fixed dropdown visibility issues and placeholder text display
     199
    194200### 2.0.2 - Theme Compatibility & Responsive Fixes
    195201* **Theme compatibility improvements** - Enhanced CSS class application for better theme compatibility
  • responsive-mobile-select-menu/trunk/readme.txt

    r3344502 r3344552  
    66Tested up to: 6.8
    77Requires PHP: 8.0
    8 Stable tag: 2.0.2
     8Stable tag: 2.0.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    127127
    128128== Changelog ==
     129
     130= 2.0.3 =
     131* **Object handling improvements** - Proper handling of WordPress menu objects and WP_Term instances
     132* **String conversion safety** - Enhanced safe conversion of menu IDs and theme locations
     133* **Code robustness** - Improved error handling for various WordPress menu argument types
     134* **User experience** - Fixed dropdown visibility issues and placeholder text display
    129135
    130136= 2.0.2 =
     
    203209== Upgrade Notice ==
    204210
     211= 2.0.3 =
     212This is a critical bug fix release that resolves fatal errors caused by WordPress menu object handling issues. The update includes proper WP_Term object conversion, enhanced error handling, and fixes dropdown visibility problems. Strongly recommended for all users.
     213
    205214= 2.0.2 =
    206215This is a compatibility release that improves theme integration and responsive behavior. The update includes better CSS class application, WordPress Codex compliance, and fixes the issue where both desktop and mobile menus were displayed simultaneously. Recommended for all users.
  • responsive-mobile-select-menu/trunk/responsive-mobile-select-menu.php

    r3344502 r3344552  
    44 * Plugin URI: https://www.saskialund.de/responsive-mobile-select-menu/
    55 * 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.2
     6 * Version: 2.0.3
    77 * Requires at least: 6.5
    88 * Tested up to: 6.8
     
    2424
    2525// Plugin-Konstanten.
    26 define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0.2' );
     26define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0.3' );
    2727define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_FILE', __FILE__ );
    2828define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.