Changeset 3344552
- Timestamp:
- 08/14/2025 10:14:54 AM (6 months ago)
- Location:
- responsive-mobile-select-menu/trunk
- Files:
-
- 6 edited
-
assets/css/responsive-menu.css (modified) (6 diffs)
-
assets/js/responsive-menu.js (modified) (5 diffs)
-
includes/class-plugin.php (modified) (4 diffs)
-
readme.md (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
responsive-mobile-select-menu.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
responsive-mobile-select-menu/trunk/assets/css/responsive-menu.css
r3344449 r3344552 10 10 display: none !important; 11 11 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; 19 15 font-family: inherit; 20 color: #333; 16 color: inherit; 17 border: 1px solid #ddd; 21 18 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"); 22 19 background-repeat: no-repeat; … … 39 36 } 40 37 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 51 38 /* Disabled state */ 52 39 .responsive-menu-select:disabled { … … 59 46 .responsive-menu-select option { 60 47 padding: 8px 12px; 61 font-size: 14px;62 line-height: 1.3;48 font-size: inherit; 49 line-height: inherit; 63 50 } 64 51 … … 122 109 @media (max-width: 768px) { 123 110 .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; 126 113 } 127 114 } … … 131 118 max-width: 100%; 132 119 font-size: 16px; 133 padding: 12px 16px;134 120 } 135 121 } … … 161 147 /* Dark mode support */ 162 148 @media (prefers-color-scheme: dark) { 163 .responsive-menu-select {164 background-color: #2c2c2c;165 border-color: #555;166 color: #fff;167 }168 169 149 .responsive-menu-select option { 170 150 background-color: #2c2c2c; -
responsive-mobile-select-menu/trunk/assets/js/responsive-menu.js
r3344449 r3344552 31 31 this.bindEvents(); 32 32 this.updateVisibility(); 33 34 // Restore saved selections on initial load 35 this.restoreAllSelections(); 36 33 37 this.isInitialized = true; 34 38 } … … 65 69 return; 66 70 } 71 72 // Save the selected option to localStorage for persistence 73 this.saveSelectedOption($select, selectedValue); 67 74 68 75 // Validate URL … … 78 85 79 86 /** 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 /** 80 146 * Update visibility based on viewport width 81 147 */ … … 96 162 $select.addClass('is-mobile'); 97 163 $desktopMenu.addClass('is-hidden'); 164 165 // Restore previously selected option if available 166 this.restoreSelectedOption($select); 98 167 } else { 99 168 // Hide select, show desktop menu … … 260 329 $('#responsive-menu-announcement').remove(); 261 330 331 // Clean up localStorage entries for this instance 332 this.cleanupLocalStorage(); 333 262 334 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 }); 263 353 } 264 354 } -
responsive-mobile-select-menu/trunk/includes/class-plugin.php
r3344502 r3344552 121 121 } 122 122 123 // Convert object to array if needed for safe access 124 $args_array = is_object( $args ) ? (array) $args : $args; 125 123 126 // Add custom walker to collect options. 124 $args ['walker'] = $this->menu_walker;127 $args_array['walker'] = $this->menu_walker; 125 128 126 129 // 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'; 129 132 } 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'; 135 138 } 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; 138 144 139 145 // Add filter to output select menu after the normal menu. … … 170 176 $max_width = $this->settings->get( 'max_width', 960 ); 171 177 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 172 189 $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$s190 '<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 176 193 </select>', 177 194 esc_attr__( 'Mobile Navigation', 'responsive-mobile-select-menu' ), 178 195 esc_attr( $max_width ), 196 esc_attr( $theme_location ), 197 esc_attr( $menu_id ), 179 198 esc_html( $placeholder ), 180 199 $select_options … … 218 237 // Check menu ID restrictions. 219 238 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 } 222 246 } 223 247 } … … 251 275 .responsive-menu-select.is-mobile { 252 276 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;265 277 } 266 278 } -
responsive-mobile-select-menu/trunk/readme.md
r3344502 r3344552 6 6 **Tested up to:** 6.8 7 7 **Requires PHP:** 8.0 8 **Stable tag:** 2.0. 28 **Stable tag:** 2.0.3 9 9 **License:** GPLv2 or later 10 10 **License URI:** https://www.gnu.org/licenses/gpl-2.0.html … … 192 192 ## Changelog 193 193 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 194 200 ### 2.0.2 - Theme Compatibility & Responsive Fixes 195 201 * **Theme compatibility improvements** - Enhanced CSS class application for better theme compatibility -
responsive-mobile-select-menu/trunk/readme.txt
r3344502 r3344552 6 6 Tested up to: 6.8 7 7 Requires PHP: 8.0 8 Stable tag: 2.0. 28 Stable tag: 2.0.3 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 127 127 128 128 == 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 129 135 130 136 = 2.0.2 = … … 203 209 == Upgrade Notice == 204 210 211 = 2.0.3 = 212 This 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 205 214 = 2.0.2 = 206 215 This 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 4 4 * Plugin URI: https://www.saskialund.de/responsive-mobile-select-menu/ 5 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. 26 * Version: 2.0.3 7 7 * Requires at least: 6.5 8 8 * Tested up to: 6.8 … … 24 24 25 25 // Plugin-Konstanten. 26 define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0. 2' );26 define( 'RESPONSIVE_MOBILE_SELECT_VERSION', '2.0.3' ); 27 27 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_FILE', __FILE__ ); 28 28 define( 'RESPONSIVE_MOBILE_SELECT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.