Changeset 3686562
- Timestamp:
- 09/08/2026 12:12:32 PM (7 weeks ago)
- File:
-
- 1 edited
-
megamenu/trunk/classes/style-manager.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
megamenu/trunk/classes/style-manager.class.php
r3542351 r3686562 103 103 * Defer to `shutdown` so `nav_menu_locations` is saved before regeneration (see `set_theme_mod`). 104 104 * 105 * Only acts on `set_theme_mod()` calls made from a genuine admin/API save context (Customizer, 106 * nav-menus.php, REST). Multilingual plugins such as Polylang/WPML can end up calling 107 * `set_theme_mod( 'nav_menu_locations', ... )` on plain front-end requests to swap in the 108 * current language's menu; treating that as a real reassignment would wipe and regenerate the 109 * entire CSS cache (all languages) on almost every request. See `Mega_Menu_Integration_Polylang`. 110 * 105 111 * @param array|false $new_value New location => menu ID map. 106 112 * @param array|false $old_value Previous map or false. … … 108 114 */ 109 115 public function schedule_delete_cache_on_nav_menu_locations_change( $new_value, $old_value ) { 116 if ( ! $this->is_genuine_nav_menu_locations_save() ) { 117 return is_array( $new_value ) ? $new_value : []; 118 } 119 110 120 if ( ! is_array( $new_value ) ) { 111 121 $new_value = []; … … 141 151 142 152 /** 153 * Whether the current request is a context where a user (or the REST API on their behalf) 154 * could genuinely be saving menu-location assignments, as opposed to a plain front-end 155 * request where a multilingual plugin may be swapping the theme mod value transiently. 156 * 157 * @since 3.11.0 158 * @return bool 159 */ 160 private function is_genuine_nav_menu_locations_save() { 161 if ( is_admin() ) { 162 return true; 163 } 164 165 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 166 return true; 167 } 168 169 if ( wp_doing_ajax() ) { 170 return true; 171 } 172 173 return apply_filters( 'megamenu_is_genuine_nav_menu_locations_save', false ); 174 } 175 176 177 /** 143 178 * Run after theme mods are persisted so `get_nav_menu_locations()` matches the new assignments. 144 179 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)