: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'odg' => 'application/vnd.oasis.opendocument.graphics',
'odc' => 'application/vnd.oasis.opendocument.chart',
'odb' => 'application/vnd.oasis.opendocument.database',
'odf' => 'application/vnd.oasis.opendocument.formula',
'wp|wpd' => 'application/wordperfect',
'key' => 'application/vnd.apple.keynote',
'numbers' => 'application/vnd.apple.numbers',
'pages' => 'application/vnd.apple.pages',
* Retrieves the list of common file extensions and their types.
* @return array[] Multi-dimensional array of file extensions types keyed by the type of file.
function wp_get_ext_types() {
* Filters file type based on the extension name.
* @param array[] $ext2type Multi-dimensional array of file extensions types keyed by the type of file.
'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp', 'avif' ),
'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ),
'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ),
'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
'text' => array( 'asc', 'csv', 'tsv', 'txt' ),
'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
* Wrapper for PHP filesize with filters and casting the result as an integer.
* @link https://www.php.net/manual/en/function.filesize.php
* @param string $path Path to the file.
* @return int The size of the file in bytes, or 0 in the event of an error.
function wp_filesize( $path ) {
* Filters the result of wp_filesize before the PHP function is run.
* @param null|int $size The unfiltered value. Returning an int from the callback bypasses the filesize call.
* @param string $path Path to the file.
$size = apply_filters( 'pre_wp_filesize', null, $path );
$size = file_exists( $path ) ? (int) filesize( $path ) : 0;
* Filters the size of the file.
* @param int $size The result of PHP filesize on the file.
* @param string $path Path to the file.
return (int) apply_filters( 'wp_filesize', $size, $path );
* Retrieves the list of allowed mime types and file extensions.
* @param int|WP_User $user Optional. User to check. Defaults to current user.
* @return string[] Array of mime types keyed by the file extension regex corresponding
function get_allowed_mime_types( $user = null ) {
$t = wp_get_mime_types();
unset( $t['swf'], $t['exe'] );
if ( function_exists( 'current_user_can' ) ) {
$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
if ( empty( $unfiltered ) ) {
unset( $t['htm|html'], $t['js'] );
* Filters the list of allowed mime types and file extensions.
* @param array $t Mime types keyed by the file extension regex corresponding to those types.
* @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user).
return apply_filters( 'upload_mimes', $t, $user );
* Displays "Are You Sure" message to confirm the action being taken.
* If the action has the nonce explain message, then it will be displayed
* along with the "Are you sure?" message.
* @param string $action The nonce action.
function wp_nonce_ays( $action ) {
// Default title and response code.
$title = __( 'Something went wrong.' );
if ( 'log-out' === $action ) {
/* translators: %s: Site title. */
__( 'You are attempting to log out of %s' ),
$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
/* translators: %s: Logout URL. */
__( 'Do you really want to <a href="%s">log out</a>?' ),
wp_logout_url( $redirect_to )
$html = __( 'The link you followed has expired.' );
if ( wp_get_referer() ) {
$wp_http_referer = remove_query_arg( 'updated', wp_get_referer() );
$wp_http_referer = wp_validate_redirect( sanitize_url( $wp_http_referer ) );
esc_url( $wp_http_referer ),
__( 'Please try again.' )
wp_die( $html, $title, $response_code );
* Kills WordPress execution and displays HTML page with an error message.
* This function complements the `die()` PHP function. The difference is that
* HTML will be displayed to the user. It is recommended to use this function
* only when the execution should not continue any further. It is not recommended
* to call this function very often, and try to handle as many errors as possible
* silently or more gracefully.
* As a shorthand, the desired HTTP response code may be passed as an integer to
* the `$title` parameter (the default title would apply) or the `$args` parameter.
* @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept
* an integer to be used as the response code.
* @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added.
* @since 5.3.0 The `$charset` argument was added.
* @since 5.5.0 The `$text_direction` argument has a priority over get_language_attributes()
* in the default handler.
* @global WP_Query $wp_query WordPress Query object.
* @param string|WP_Error $message Optional. Error message. If this is a WP_Error object,
* and not an Ajax or XML-RPC request, the error's messages are used.
* @param string|int $title Optional. Error title. If `$message` is a `WP_Error` object,
* error data with the key 'title' may be used to specify the title.
* If `$title` is an integer, then it is treated as the response code.
* @param string|array|int $args {
* Optional. Arguments to control behavior. If `$args` is an integer, then it is treated
* as the response code. Default empty array.
* @type int $response The HTTP response code. Default 200 for Ajax requests, 500 otherwise.
* @type string $link_url A URL to include a link to. Only works in combination with $link_text.
* @type string $link_text A label for the link to include. Only works in combination with $link_url.
* @type bool $back_link Whether to include a link to go back. Default false.
* @type string $text_direction The text direction. This is only useful internally, when WordPress is still
* loading and the site's locale is not set up yet. Accepts 'rtl' and 'ltr'.
* Default is the value of is_rtl().
* @type string $charset Character set of the HTML output. Default 'utf-8'.
* @type string $code Error code to use. Default is 'wp_die', or the main error code if $message
* @type bool $exit Whether to exit the process after completion. Default true.
function wp_die( $message = '', $title = '', $args = array() ) {
$args = array( 'response' => $args );
} elseif ( is_int( $title ) ) {
$args = array( 'response' => $title );
* Filters the callback for killing WordPress execution for Ajax requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
} elseif ( wp_is_json_request() ) {
* Filters the callback for killing WordPress execution for JSON requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' );
} elseif ( wp_is_serving_rest_request() && wp_is_jsonp_request() ) {
* Filters the callback for killing WordPress execution for JSONP REST requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' );
} elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
* Filters the callback for killing WordPress execution for XML-RPC requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
} elseif ( wp_is_xml_request()
( function_exists( 'is_feed' ) && is_feed()
|| function_exists( 'is_comment_feed' ) && is_comment_feed()
|| function_exists( 'is_trackback' ) && is_trackback() ) ) {
* Filters the callback for killing WordPress execution for XML requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' );
* Filters the callback for killing WordPress execution for all non-Ajax, non-JSON, non-XML requests.
* @param callable $callback Callback function name.
$callback = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
call_user_func( $callback, $message, $title, $args );
* Kills WordPress execution and displays HTML page with an error message.
* This is the default handler for wp_die(). If you want a custom one,
* you can override this using the {@see 'wp_die_handler'} filter in wp_die().
* @param string|WP_Error $message Error message or WP_Error object.
* @param string $title Optional. Error title. Default empty string.
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
function _default_wp_die_handler( $message, $title = '', $args = array() ) {
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
if ( is_string( $message ) ) {
if ( ! empty( $parsed_args['additional_errors'] ) ) {
wp_list_pluck( $parsed_args['additional_errors'], 'message' )
$message = "<ul>\n\t\t<li>" . implode( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>";
'<div class="wp-die-message">%s</div>',
$have_gettext = function_exists( '__' );
if ( ! empty( $parsed_args['link_url'] ) && ! empty( $parsed_args['link_text'] ) ) {
$link_url = $parsed_args['link_url'];
if ( function_exists( 'esc_url' ) ) {
$link_url = esc_url( $link_url );
$link_text = $parsed_args['link_text'];
$message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>";
if ( isset( $parsed_args['back_link'] ) && $parsed_args['back_link'] ) {
$back_text = $have_gettext ? __( '« Back' ) : '« Back';
$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
if ( ! did_action( 'admin_head' ) ) :
if ( ! headers_sent() ) {
header( "Content-Type: text/html; charset={$parsed_args['charset']}" );
status_header( $parsed_args['response'] );
$text_direction = $parsed_args['text_direction'];
$dir_attr = "dir='$text_direction'";
* If `text_direction` was not explicitly passed,
* use get_language_attributes() if available.
if ( empty( $args['text_direction'] )
&& function_exists( 'language_attributes' ) && function_exists( 'is_rtl' )
$dir_attr = get_language_attributes();
<html <?php echo $dir_attr; ?>>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $parsed_args['charset']; ?>" />
<meta name="viewport" content="width=device-width">
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' );
<title><?php echo $title; ?></title>
border: 1px solid #ccd0d4;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
border-bottom: 1px solid #dadada;
#error-page .wp-die-message {
font-family: Consolas, Monaco, monospace;
box-shadow: 0 0 0 2px #2271b1;
outline: 2px solid transparent;
border: 1px solid #016087;
-webkit-border-radius: 3px;
-webkit-appearance: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-shadow: 0 0 0 1px #007cba;
box-shadow: 0 0 0 1px #007cba;
outline: 2px solid transparent;
-webkit-box-shadow: none;
if ( 'rtl' === $text_direction ) {
echo 'body { font-family: Tahoma, Arial; }';
<?php endif; // ! did_action( 'admin_head' ) ?>
if ( $parsed_args['exit'] ) {
* Kills WordPress execution and displays Ajax response with an error message.
* This is the handler for wp_die() when processing Ajax requests.