Changeset 49080
- Timestamp:
- 10/01/2020 12:37:54 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r49079 r49080 2161 2161 */ 2162 2162 function wp_common_block_scripts_and_styles() { 2163 global $current_screen; 2164 2165 if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) { 2163 if ( is_admin() && ! _should_load_block_editor_scripts_and_styles() ) { 2166 2164 return; 2167 2165 } … … 2187 2185 2188 2186 /** 2187 * Checks if the editor scripts and styles for all registered block types 2188 * should be enqueued on the current screen. 2189 * 2190 * @access private 2191 * 2192 * @return boolean 2193 */ 2194 function _should_load_block_editor_scripts_and_styles() { 2195 global $current_screen; 2196 2197 $is_block_editor_screen = ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor(); 2198 2199 /** 2200 * Filters the flag that decides whether or not block editor scripts and 2201 * styles are going to be enqueued on the current screen. 2202 * 2203 * @since 5.6.0 2204 * 2205 * @param boolean $is_block_editor_screen Current value of the flag 2206 */ 2207 return apply_filters( 'should_load_block_editor_scripts_and_styles', $is_block_editor_screen ); 2208 } 2209 2210 /** 2189 2211 * Enqueues registered block scripts and styles, depending on current rendered 2190 2212 * context (only enqueuing editor scripts while in context of the editor). … … 2197 2219 global $current_screen; 2198 2220 2199 $ is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor());2221 $load_editor_scripts = _should_load_block_editor_scripts_and_styles(); 2200 2222 2201 2223 $block_registry = WP_Block_Type_Registry::get_instance(); … … 2212 2234 2213 2235 // Editor styles. 2214 if ( $ is_editor&& ! empty( $block_type->editor_style ) ) {2236 if ( $load_editor_scripts && ! empty( $block_type->editor_style ) ) { 2215 2237 wp_enqueue_style( $block_type->editor_style ); 2216 2238 } 2217 2239 2218 2240 // Editor script. 2219 if ( $ is_editor&& ! empty( $block_type->editor_script ) ) {2241 if ( $load_editor_scripts && ! empty( $block_type->editor_script ) ) { 2220 2242 wp_enqueue_script( $block_type->editor_script ); 2221 2243 }
Note: See TracChangeset
for help on using the changeset viewer.