diff options
Diffstat (limited to 'wp-includes/functions.php')
-rw-r--r-- | wp-includes/functions.php | 108 |
1 files changed, 81 insertions, 27 deletions
diff --git a/wp-includes/functions.php b/wp-includes/functions.php index f9d6176..e659a5f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1347,6 +1347,7 @@ function wp( $query_vars = '' ) { * @since 3.9.0 Added status codes 418, 428, 429, 431, and 511. * @since 4.5.0 Added status codes 308, 421, and 451. * @since 5.1.0 Added status code 103. + * @since 6.6.0 Added status code 425. * * @global array $wp_header_to_desc * @@ -1408,6 +1409,7 @@ function get_status_header_desc( $code ) { 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', + 425 => 'Too Early', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', @@ -2268,7 +2270,7 @@ function wp_is_writable( $path ) { * PHP has issues with Windows ACL's for determine if a * directory is writable or not, this works around them by * checking the ability to open files rather than relying - * upon PHP to interprate the OS ACL. + * upon PHP to interpret the OS ACL. * * @since 2.8.0 * @@ -2342,10 +2344,10 @@ function wp_get_upload_dir() { * @since 2.0.0 * @uses _wp_upload_dir() * - * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. - * @param bool $create_dir Optional. Whether to check and create the uploads directory. - * Default true for backward compatibility. - * @param bool $refresh_cache Optional. Whether to refresh the cache. Default false. + * @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null. + * @param bool $create_dir Optional. Whether to check and create the uploads directory. + * Default true for backward compatibility. + * @param bool $refresh_cache Optional. Whether to refresh the cache. Default false. * @return array { * Array of information about the upload directory. * @@ -2417,7 +2419,7 @@ function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false * @since 4.5.0 * @access private * - * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. + * @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null. * @return array See wp_upload_dir() */ function _wp_upload_dir( $time = null ) { @@ -2869,7 +2871,7 @@ function _wp_check_existing_file_names( $filename, $files ) { * @param string $name Filename. * @param null|string $deprecated Never used. Set to null. * @param string $bits File content - * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. + * @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null. * @return array { * Information about the newly-uploaded file. * @@ -3860,6 +3862,9 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { <?php if ( function_exists( 'wp_robots' ) && function_exists( 'wp_robots_no_robots' ) && function_exists( 'add_filter' ) ) { add_filter( 'wp_robots', 'wp_robots_no_robots' ); + // Prevent warnings because of $wp_query not existing. + remove_filter( 'wp_robots', 'wp_robots_noindex_embeds' ); + remove_filter( 'wp_robots', 'wp_robots_noindex_search' ); wp_robots(); } ?> @@ -4609,7 +4614,8 @@ function wp_json_file_decode( $filename, $options = array() ) { $filename = wp_normalize_path( realpath( $filename ) ); if ( ! $filename ) { - trigger_error( + wp_trigger_error( + __FUNCTION__, sprintf( /* translators: %s: Path to the JSON file. */ __( "File %s doesn't exist!" ), @@ -4623,7 +4629,8 @@ function wp_json_file_decode( $filename, $options = array() ) { $decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] ); if ( JSON_ERROR_NONE !== json_last_error() ) { - trigger_error( + wp_trigger_error( + __FUNCTION__, sprintf( /* translators: 1: Path to the JSON file, 2: Error message. */ __( 'Error when decoding a JSON file at path %1$s: %2$s' ), @@ -4760,10 +4767,10 @@ function wp_is_serving_rest_request() { * the description. Probably should create a Codex page for it, so that it is * available. * + * @since 2.2.0 + * * @global array $wpsmiliestrans * @global array $wp_smiliessearch - * - * @since 2.2.0 */ function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch; @@ -5398,7 +5405,7 @@ function wp_widgets_add_menu() { } $menu_name = __( 'Widgets' ); - if ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) { + if ( wp_is_block_theme() ) { $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); } else { $submenu['themes.php'][8] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); @@ -5991,7 +5998,7 @@ function _doing_it_wrong( $function_name, $message, $version ) { $message .= ' ' . sprintf( /* translators: %s: Documentation URL. */ __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), - __( 'https://wordpress.org/documentation/article/debugging-in-wordpress/' ) + __( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ) ); $message = sprintf( @@ -6008,7 +6015,7 @@ function _doing_it_wrong( $function_name, $message, $version ) { $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', - 'https://wordpress.org/documentation/article/debugging-in-wordpress/' + 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ); $message = sprintf( @@ -6066,11 +6073,11 @@ function wp_trigger_error( $function_name, $message, $error_level = E_USER_NOTIC $message = wp_kses( $message, array( - 'a' => array( 'href' ), - 'br', - 'code', - 'em', - 'strong', + 'a' => array( 'href' => true ), + 'br' => array(), + 'code' => array(), + 'em' => array(), + 'strong' => array(), ), array( 'http', 'https' ) ); @@ -6192,8 +6199,10 @@ function validate_file( $file, $allowed_files = array() ) { return 0; } - // Normalize path for Windows servers + // Normalize path for Windows servers. $file = wp_normalize_path( $file ); + // Normalize path for $allowed_files as well so it's an apples to apples comparison. + $allowed_files = array_map( 'wp_normalize_path', $allowed_files ); // `../` on its own is not allowed: if ( '../' === $file ) { @@ -7467,6 +7476,40 @@ function get_tag_regex( $tag ) { } /** + * Indicates if a given slug for a character set represents the UTF-8 + * text encoding. If not provided, examines the current blog's charset. + * + * A charset is considered to represent UTF-8 if it is a case-insensitive + * match of "UTF-8" with or without the hyphen. + * + * Example: + * + * true === is_utf8_charset( 'UTF-8' ); + * true === is_utf8_charset( 'utf8' ); + * false === is_utf8_charset( 'latin1' ); + * false === is_utf8_charset( 'UTF 8' ); + * + * // Only strings match. + * false === is_utf8_charset( [ 'charset' => 'utf-8' ] ); + * + * // Without a given charset, it depends on the site option "blog_charset". + * $is_utf8 = is_utf8_charset(); + * + * @since 6.6.0 + * @since 6.6.1 A wrapper for _is_utf8_charset + * + * @see _is_utf8_charset + * + * @param string|null $blog_charset Optional. Slug representing a text character encoding, or "charset". + * E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS". + * Default value is to infer from "blog_charset" option. + * @return bool Whether the slug represents the UTF-8 encoding. + */ +function is_utf8_charset( $blog_charset = null ) { + return _is_utf8_charset( $blog_charset ?? get_option( 'blog_charset' ) ); +} + +/** * Retrieves a canonical form of the provided charset appropriate for passing to PHP * functions such as htmlspecialchars() and charset HTML attributes. * @@ -7475,17 +7518,27 @@ function get_tag_regex( $tag ) { * * @see https://core.trac.wordpress.org/ticket/23688 * - * @param string $charset A charset name. + * @param string $charset A charset name, e.g. "UTF-8", "Windows-1252", "SJIS". * @return string The canonical form of the charset. */ function _canonical_charset( $charset ) { - if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset ) ) { - + if ( is_utf8_charset( $charset ) ) { return 'UTF-8'; } - if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) { - + /* + * Normalize the ISO-8859-1 family of languages. + * + * This is not required for htmlspecialchars(), as it properly recognizes all of + * the input character sets that here are transformed into "ISO-8859-1". + * + * @todo Should this entire check be removed since it's not required for the stated purpose? + * @todo Should WordPress transform other potential charset equivalents, such as "latin1"? + */ + if ( + ( 0 === strcasecmp( 'iso-8859-1', $charset ) ) || + ( 0 === strcasecmp( 'iso8859-1', $charset ) ) + ) { return 'ISO-8859-1'; } @@ -8508,7 +8561,7 @@ function wp_get_update_https_url() { */ function wp_get_default_update_https_url() { /* translators: Documentation explaining HTTPS and why it should be used. */ - return __( 'https://wordpress.org/documentation/article/why-should-i-use-https/' ); + return __( 'https://developer.wordpress.org/advanced-administration/security/https/' ); } /** @@ -8705,7 +8758,8 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul */ function clean_dirsize_cache( $path ) { if ( ! is_string( $path ) || empty( $path ) ) { - trigger_error( + wp_trigger_error( + '', sprintf( /* translators: 1: Function name, 2: A variable type, like "boolean" or "integer". */ __( '%1$s only accepts a non-empty path string, received %2$s.' ), |