wp/wp-includes/deprecated.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   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);
  3671  * @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure.
  3671  * @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure.
  3672  */
  3672  */
  3673 function wp_get_http( $url, $file_path = false, $red = 1 ) {
  3673 function wp_get_http( $url, $file_path = false, $red = 1 ) {
  3674 	_deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
  3674 	_deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
  3675 
  3675 
       
  3676 	// Add 60 seconds to the script timeout to ensure the remote request has enough time.
  3676 	if ( function_exists( 'set_time_limit' ) ) {
  3677 	if ( function_exists( 'set_time_limit' ) ) {
  3677 		@set_time_limit( 60 );
  3678 		@set_time_limit( 60 );
  3678 	}
  3679 	}
  3679 
  3680 
  3680 	if ( $red > 5 )
  3681 	if ( $red > 5 )
  5187 
  5188 
  5188 /**
  5189 /**
  5189  * Returns the duotone filter SVG string for the preset.
  5190  * Returns the duotone filter SVG string for the preset.
  5190  *
  5191  *
  5191  * @since 5.9.1
  5192  * @since 5.9.1
  5192  * @deprecated 6.3.0
  5193  * @deprecated 6.3.0 Use WP_Duotone::get_filter_svg_from_preset() instead.
  5193  *
  5194  *
  5194  * @access private
  5195  * @access private
  5195  *
  5196  *
  5196  * @param array $preset Duotone preset value as seen in theme.json.
  5197  * @param array $preset Duotone preset value as seen in theme.json.
  5197  * @return string Duotone SVG filter.
  5198  * @return string Duotone SVG filter.
  5198  */
  5199  */
  5199 function wp_get_duotone_filter_svg( $preset ) {
  5200 function wp_get_duotone_filter_svg( $preset ) {
  5200 	_deprecated_function( __FUNCTION__, '6.3.0' );
  5201 	_deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::get_filter_svg_from_preset()' );
  5201 	return WP_Duotone::get_filter_svg_from_preset( $preset );
  5202 	return WP_Duotone::get_filter_svg_from_preset( $preset );
  5202 }
  5203 }
  5203 
  5204 
  5204 /**
  5205 /**
  5205  * Registers the style and colors block attributes for block types that support it.
  5206  * Registers the style and colors block attributes for block types that support it.
  6000 	 * @param null|WP_Error $pre Error object to short-circuit detection,
  6001 	 * @param null|WP_Error $pre Error object to short-circuit detection,
  6001 	 *                           or null to continue with the default behavior.
  6002 	 *                           or null to continue with the default behavior.
  6002 	 */
  6003 	 */
  6003 	$support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null );
  6004 	$support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null );
  6004 	if ( is_wp_error( $support_errors ) ) {
  6005 	if ( is_wp_error( $support_errors ) ) {
  6005 		update_option( 'https_detection_errors', $support_errors->errors );
  6006 		update_option( 'https_detection_errors', $support_errors->errors, false );
  6006 		return;
  6007 		return;
  6007 	}
  6008 	}
  6008 
  6009 
  6009 	$support_errors = wp_get_https_detection_errors();
  6010 	$support_errors = wp_get_https_detection_errors();
  6010 
  6011 
  6166 	 */
  6167 	 */
  6167 	?>
  6168 	?>
  6168 	<style id="skip-link-styles">
  6169 	<style id="skip-link-styles">
  6169 		.skip-link.screen-reader-text {
  6170 		.skip-link.screen-reader-text {
  6170 			border: 0;
  6171 			border: 0;
  6171 			clip: rect(1px,1px,1px,1px);
       
  6172 			clip-path: inset(50%);
  6172 			clip-path: inset(50%);
  6173 			height: 1px;
  6173 			height: 1px;
  6174 			margin: -1px;
  6174 			margin: -1px;
  6175 			overflow: hidden;
  6175 			overflow: hidden;
  6176 			padding: 0;
  6176 			padding: 0;
  6179 			word-wrap: normal !important;
  6179 			word-wrap: normal !important;
  6180 		}
  6180 		}
  6181 
  6181 
  6182 		.skip-link.screen-reader-text:focus {
  6182 		.skip-link.screen-reader-text:focus {
  6183 			background-color: #eee;
  6183 			background-color: #eee;
  6184 			clip: auto !important;
       
  6185 			clip-path: none;
  6184 			clip-path: none;
  6186 			color: #444;
  6185 			color: #444;
  6187 			display: block;
  6186 			display: block;
  6188 			font-size: 1em;
  6187 			font-size: 1em;
  6189 			height: auto;
  6188 			height: auto;
  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 }