703 if ( $optionall ) |
703 if ( $optionall ) |
704 $show_option_all = $all; |
704 $show_option_all = $all; |
705 |
705 |
706 $show_option_none = ''; |
706 $show_option_none = ''; |
707 if ( $optionnone ) |
707 if ( $optionnone ) |
708 $show_option_none = _x( 'None', 'Categories dropdown (show_option_none parameter)' ); |
708 $show_option_none = _x( 'None', 'Categories dropdown (show_option_none parameter)' ); |
709 |
709 |
710 $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
710 $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
711 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); |
711 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); |
712 $query = add_query_arg($vars, ''); |
712 $query = add_query_arg($vars, ''); |
713 return wp_dropdown_categories($query); |
713 return wp_dropdown_categories($query); |
6308 */ |
6307 */ |
6309 function wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block ): array { |
6308 function wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block ): array { |
6310 _deprecated_function( __FUNCTION__, '6.6.0' ); |
6309 _deprecated_function( __FUNCTION__, '6.6.0' ); |
6311 return $parsed_block; |
6310 return $parsed_block; |
6312 } |
6311 } |
|
6312 |
|
6313 /** |
|
6314 * Gets the global styles custom CSS from theme.json. |
|
6315 * |
|
6316 * @since 6.2.0 |
|
6317 * @deprecated 6.7.0 Use {@see 'wp_get_global_stylesheet'} instead for top-level custom CSS, or {@see 'WP_Theme_JSON::get_styles_for_block'} for block-level custom CSS. |
|
6318 * |
|
6319 * @return string The global styles custom CSS. |
|
6320 */ |
|
6321 function wp_get_global_styles_custom_css() { |
|
6322 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_get_global_stylesheet' ); |
|
6323 if ( ! wp_theme_has_theme_json() ) { |
|
6324 return ''; |
|
6325 } |
|
6326 /* |
|
6327 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme |
|
6328 * developer's workflow. |
|
6329 */ |
|
6330 $can_use_cached = ! wp_is_development_mode( 'theme' ); |
|
6331 |
|
6332 /* |
|
6333 * By using the 'theme_json' group, this data is marked to be non-persistent across requests. |
|
6334 * @see `wp_cache_add_non_persistent_groups()`. |
|
6335 * |
|
6336 * The rationale for this is to make sure derived data from theme.json |
|
6337 * is always fresh from the potential modifications done via hooks |
|
6338 * that can use dynamic data (modify the stylesheet depending on some option, |
|
6339 * settings depending on user permissions, etc.). |
|
6340 * See some of the existing hooks to modify theme.json behavior: |
|
6341 * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ |
|
6342 * |
|
6343 * A different alternative considered was to invalidate the cache upon certain |
|
6344 * events such as options add/update/delete, user meta, etc. |
|
6345 * It was judged not enough, hence this approach. |
|
6346 * @see https://github.com/WordPress/gutenberg/pull/45372 |
|
6347 */ |
|
6348 $cache_key = 'wp_get_global_styles_custom_css'; |
|
6349 $cache_group = 'theme_json'; |
|
6350 if ( $can_use_cached ) { |
|
6351 $cached = wp_cache_get( $cache_key, $cache_group ); |
|
6352 if ( $cached ) { |
|
6353 return $cached; |
|
6354 } |
|
6355 } |
|
6356 |
|
6357 $tree = WP_Theme_JSON_Resolver::get_merged_data(); |
|
6358 $stylesheet = $tree->get_custom_css(); |
|
6359 |
|
6360 if ( $can_use_cached ) { |
|
6361 wp_cache_set( $cache_key, $stylesheet, $cache_group ); |
|
6362 } |
|
6363 |
|
6364 return $stylesheet; |
|
6365 } |
|
6366 |
|
6367 /** |
|
6368 * Enqueues the global styles custom css defined via theme.json. |
|
6369 * |
|
6370 * @since 6.2.0 |
|
6371 * @deprecated 6.7.0 Use {@see 'wp_enqueue_global_styles'} instead. |
|
6372 */ |
|
6373 function wp_enqueue_global_styles_custom_css() { |
|
6374 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_enqueue_global_styles' ); |
|
6375 if ( ! wp_is_block_theme() ) { |
|
6376 return; |
|
6377 } |
|
6378 |
|
6379 // Don't enqueue Customizer's custom CSS separately. |
|
6380 remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); |
|
6381 |
|
6382 $custom_css = wp_get_custom_css(); |
|
6383 $custom_css .= wp_get_global_styles_custom_css(); |
|
6384 |
|
6385 if ( ! empty( $custom_css ) ) { |
|
6386 wp_add_inline_style( 'global-styles', $custom_css ); |
|
6387 } |
|
6388 } |
|
6389 |
|
6390 /** |
|
6391 * Generate block style variation instance name. |
|
6392 * |
|
6393 * @since 6.6.0 |
|
6394 * @deprecated 6.7.0 Use `wp_unique_id( $variation . '--' )` instead. |
|
6395 * |
|
6396 * @access private |
|
6397 * |
|
6398 * @param array $block Block object. |
|
6399 * @param string $variation Slug for the block style variation. |
|
6400 * |
|
6401 * @return string The unique variation name. |
|
6402 */ |
|
6403 function wp_create_block_style_variation_instance_name( $block, $variation ) { |
|
6404 _deprecated_function( __FUNCTION__, '6.7.0', 'wp_unique_id' ); |
|
6405 return $variation . '--' . md5( serialize( $block ) ); |
|
6406 } |
|
6407 |
|
6408 /** |
|
6409 * Returns whether the current user has the specified capability for a given site. |
|
6410 * |
|
6411 * @since 3.0.0 |
|
6412 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter |
|
6413 * by adding it to the function signature. |
|
6414 * @since 5.8.0 Wraps current_user_can() after switching to blog. |
|
6415 * @deprecated 6.7.0 Use current_user_can_for_site() instead. |
|
6416 * |
|
6417 * @param int $blog_id Site ID. |
|
6418 * @param string $capability Capability name. |
|
6419 * @param mixed ...$args Optional further parameters, typically starting with an object ID. |
|
6420 * @return bool Whether the user has the given capability. |
|
6421 */ |
|
6422 function current_user_can_for_blog( $blog_id, $capability, ...$args ) { |
|
6423 return current_user_can_for_site( $blog_id, $capability, ...$args ); |
|
6424 } |
|
6425 |
|
6426 /** |
|
6427 * Loads classic theme styles on classic themes in the editor. |
|
6428 * |
|
6429 * This is used for backwards compatibility for Button and File blocks specifically. |
|
6430 * |
|
6431 * @since 6.1.0 |
|
6432 * @since 6.2.0 Added File block styles. |
|
6433 * @deprecated 6.8.0 Styles are enqueued, not printed in the body element. |
|
6434 * |
|
6435 * @param array $editor_settings The array of editor settings. |
|
6436 * @return array A filtered array of editor settings. |
|
6437 */ |
|
6438 function wp_add_editor_classic_theme_styles( $editor_settings ) { |
|
6439 _deprecated_function( __FUNCTION__, '6.8.0', 'wp_enqueue_classic_theme_styles' ); |
|
6440 |
|
6441 if ( wp_theme_has_theme_json() ) { |
|
6442 return $editor_settings; |
|
6443 } |
|
6444 |
|
6445 $suffix = wp_scripts_get_suffix(); |
|
6446 $classic_theme_styles = ABSPATH . WPINC . "/css/classic-themes$suffix.css"; |
|
6447 |
|
6448 /* |
|
6449 * This follows the pattern of get_block_editor_theme_styles, |
|
6450 * but we can't use get_block_editor_theme_styles directly as it |
|
6451 * only handles external files or theme files. |
|
6452 */ |
|
6453 $classic_theme_styles_settings = array( |
|
6454 'css' => file_get_contents( $classic_theme_styles ), |
|
6455 '__unstableType' => 'core', |
|
6456 'isGlobalStyles' => false, |
|
6457 ); |
|
6458 |
|
6459 // Add these settings to the start of the array so that themes can override them. |
|
6460 array_unshift( $editor_settings['styles'], $classic_theme_styles_settings ); |
|
6461 |
|
6462 return $editor_settings; |
|
6463 } |