| | 216 | /** |
| | 217 | * Ensure that settings associated with partials use the 'postMessage' transport. |
| | 218 | */ |
| | 219 | public function check_transport_of_settings_with_partials() { |
| | 220 | foreach ( $this->partials() as $partial ) { |
| | 221 | /* |
| | 222 | * It's possible to register a partial for a setting while intending |
| | 223 | * to use the partial in only certain circumstances. Before |
| | 224 | * enforcing the 'postMessage' transport for such settings, check |
| | 225 | * that the partial is configured to request a full refresh of the |
| | 226 | * preview if the selective refresh fails because the partial isn't |
| | 227 | * actually used in the preview. |
| | 228 | */ |
| | 229 | if ( ! $partial->fallback_refresh ) { |
| | 230 | continue; |
| | 231 | } |
| | 232 | |
| | 233 | foreach ( $partial->settings as $setting_id ) { |
| | 234 | $setting = $this->manager->get_setting( $setting_id ); |
| | 235 | |
| | 236 | if ( $setting instanceof WP_Customize_Setting ) { |
| | 237 | // Change only the 'refresh' transport, not custom transports. |
| | 238 | if ( 'refresh' !== $setting->transport ) { |
| | 239 | continue; |
| | 240 | } |
| | 241 | |
| | 242 | /* |
| | 243 | * If the partial is unsupported, don't change any settings. |
| | 244 | * |
| | 245 | * Save this check until the end to avoid unnecessarily |
| | 246 | * re-checking the capabilities for partials and all their |
| | 247 | * settings when the settings already use 'postMessage'. |
| | 248 | */ |
| | 249 | if ( ! $partial->check_capabilities() ) { |
| | 250 | continue 2; |
| | 251 | } |
| | 252 | |
| | 253 | $setting->transport = 'postMessage'; |
| | 254 | } |
| | 255 | } |
| | 256 | } |
| | 257 | } |
| | 258 | |