: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'tagname-lowercase' => true,
'attr-lowercase' => true,
'attr-value-double-quotes' => false,
'doctype-first' => false,
'spec-char-escape' => true,
'attr-no-duplication' => true,
'space-tab-mixed-disabled' => 'tab',
'attr-unsafe-chars' => true,
if ( isset( $args['type'] ) ) {
// Remap MIME types to ones that CodeMirror modes will recognize.
if ( 'application/x-patch' === $type || 'text/x-patch' === $type ) {
} elseif ( isset( $args['file'] ) && str_contains( basename( $args['file'] ), '.' ) ) {
$extension = strtolower( pathinfo( $args['file'], PATHINFO_EXTENSION ) );
foreach ( wp_get_mime_types() as $exts => $mime ) {
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
// Supply any types that are not matched by wp_get_mime_types().
$type = 'text/javascript';
$type = 'application/json';
$type = 'application/x-httpd-php';
$type = 'application/svg+xml';
if ( in_array( $type, array( 'text/css', 'text/x-scss', 'text/x-less', 'text/x-sass' ), true ) ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( 'text/x-diff' === $type ) {
$settings['codemirror'] = array_merge(
} elseif ( 'text/html' === $type ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
if ( ! current_user_can( 'unfiltered_html' ) ) {
$settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' );
} elseif ( 'text/x-gfm' === $type ) {
$settings['codemirror'] = array_merge(
'highlightFormatting' => true,
} elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( str_contains( $type, 'json' ) ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
if ( 'application/ld+json' === $type ) {
$settings['codemirror']['mode']['jsonld'] = true;
$settings['codemirror']['mode']['json'] = true;
} elseif ( str_contains( $type, 'jsx' ) ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( 'text/x-markdown' === $type ) {
$settings['codemirror'] = array_merge(
'highlightFormatting' => true,
} elseif ( 'text/nginx' === $type ) {
$settings['codemirror'] = array_merge(
} elseif ( 'application/x-httpd-php' === $type ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( str_contains( $type, 'xml' ) ) {
$settings['codemirror'] = array_merge(
'autoCloseBrackets' => true,
} elseif ( 'text/x-yaml' === $type ) {
$settings['codemirror'] = array_merge(
$settings['codemirror']['mode'] = $type;
if ( ! empty( $settings['codemirror']['lint'] ) ) {
$settings['codemirror']['gutters'][] = 'CodeMirror-lint-markers';
// Let settings supplied via args override any defaults.
foreach ( wp_array_slice_assoc( $args, array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ) ) as $key => $value ) {
$settings[ $key ] = array_merge(
* Filters settings that are passed into the code editor.
* Returning a falsey value will disable the syntax-highlighting code editor.
* @param array $settings The array of settings passed to the code editor.
* A falsey value disables the editor.
* Args passed when calling `get_code_editor_settings()`.
* @type string $type The MIME type of the file to be edited.
* @type string $file Filename being edited.
* @type WP_Theme $theme Theme being edited when on the theme file editor.
* @type string $plugin Plugin being edited when on the plugin file editor.
* @type array $codemirror Additional CodeMirror setting overrides.
* @type array $csslint CSSLint rule overrides.
* @type array $jshint JSHint rule overrides.
* @type array $htmlhint HTMLHint rule overrides.
return apply_filters( 'wp_code_editor_settings', $settings, $args );
* Retrieves the contents of the search WordPress query variable.
* The search query string is passed through esc_attr() to ensure that it is safe
* for placing in an HTML attribute.
* @param bool $escaped Whether the result is escaped. Default true.
* Only use when you are later escaping it. Do not use unescaped.
function get_search_query( $escaped = true ) {
* Filters the contents of the search query variable.
* @param mixed $search Contents of the search query variable.
$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
$query = esc_attr( $query );
* Displays the contents of the search query variable.
* The search query string is passed through esc_attr() to ensure that it is safe
* for placing in an HTML attribute.
function the_search_query() {
* Filters the contents of the search query variable for display.
* @param mixed $search Contents of the search query variable.
echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
* Gets the language attributes for the 'html' tag.
* Builds up a set of HTML attributes containing the text direction and language
* information for the page.
* @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'.
* @return string A space-separated list of language attributes.
function get_language_attributes( $doctype = 'html' ) {
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
$attributes[] = 'dir="rtl"';
$lang = get_bloginfo( 'language' );
if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) {
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) {
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
$output = implode( ' ', $attributes );
* Filters the language attributes for display in the 'html' tag.
* @since 4.3.0 Added the `$doctype` parameter.
* @param string $output A space-separated list of language attributes.
* @param string $doctype The type of HTML document (xhtml|html).
return apply_filters( 'language_attributes', $output, $doctype );
* Displays the language attributes for the 'html' tag.
* Builds up a set of HTML attributes containing the text direction and language
* information for the page.
* @since 4.3.0 Converted into a wrapper for get_language_attributes().
* @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'.
function language_attributes( $doctype = 'html' ) {
echo get_language_attributes( $doctype );
* Retrieves paginated links for archive post pages.
* Technically, the function can be used to create paginated link list for any
* area. The 'base' argument is used to reference the url, which will be used to
* create the paginated links. The 'format' argument is then used for replacing
* the page number. It is however, most likely and by default, to be used on the
* The 'type' argument controls format of the returned value. The default is
* 'plain', which is just a string with the links separated by a newline
* character. The other possible values are either 'array' or 'list'. The
* 'array' value will return an array of the paginated link list to offer full
* control of display. The 'list' value will place all of the paginated links in
* an unordered HTML list.
* The 'total' argument is the total amount of pages and is an integer. The
* 'current' argument is the current page number and is also an integer.
* An example of the 'base' argument is "http://example.com/all_posts.php%_%"
* and the '%_%' is required. The '%_%' will be replaced by the contents of in
* the 'format' argument. An example for the 'format' argument is "?page=%#%"
* and the '%#%' is also required. The '%#%' will be replaced with the page
* You can include the previous and next links in the list by setting the
* 'prev_next' argument to true, which it is by default. You can set the
* previous text, by using the 'prev_text' argument. You can set the next text
* by setting the 'next_text' argument.
* If the 'show_all' argument is set to true, then it will show all of the pages
* instead of a short list of the pages near the current page. By default, the
* 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
* arguments. The 'end_size' argument is how many numbers on either the start
* and the end list edges, by default is 1. The 'mid_size' argument is how many
* numbers to either side of current page, but not including current page.
* It is possible to add query vars to the link by using the 'add_args' argument
* and see add_query_arg() for more information.
* The 'before_page_number' and 'after_page_number' arguments allow users to
* augment the links themselves. Typically this might be to add context to the
* numbered links so that screen reader users understand what the links are for.
* The text strings are added before and after the page number - within the
* @since 4.9.0 Added the `aria_current` argument.
* @global WP_Query $wp_query WordPress Query object.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
* @param string|array $args {
* Optional. Array or string of arguments for generating paginated links for archives.
* @type string $base Base of the paginated url. Default empty.
* @type string $format Format for the pagination structure. Default empty.
* @type int $total The total amount of pages. Default is the value WP_Query's
* @type int $current The current page number. Default is 'paged' query var or 1.
* @type string $aria_current The value for the aria-current attribute. Possible values are 'page',
* 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
* @type bool $show_all Whether to show all pages. Default false.
* @type int $end_size How many numbers on either the start and the end list edges.
* @type int $mid_size How many numbers to either side of the current pages. Default 2.
* @type bool $prev_next Whether to include the previous and next links in the list. Default true.
* @type string $prev_text The previous page text. Default '« Previous'.
* @type string $next_text The next page text. Default 'Next »'.
* @type string $type Controls format of the returned value. Possible values are 'plain',
* 'array' and 'list'. Default is 'plain'.
* @type array $add_args An array of query args to add. Default false.
* @type string $add_fragment A string to append to each link. Default empty.
* @type string $before_page_number A string to appear before the page number. Default empty.
* @type string $after_page_number A string to append after the page number. Default empty.
* @return string|string[]|void String of page links or array of page links, depending on 'type' argument.
* Void if total number of pages is less than 2.
function paginate_links( $args = '' ) {
global $wp_query, $wp_rewrite;
// Setting up default values based on the current URL.
$pagenum_link = html_entity_decode( get_pagenum_link() );
$url_parts = explode( '?', $pagenum_link );
// Get max pages and current page out of the current query, if available.
$total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
// Append the format placeholder to the base URL.
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
// URL base depends on permalink settings.
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';