Update WordPress to 5.2
This commit is contained in:
parent
489b5a5914
commit
e00f87f2f5
599 changed files with 119573 additions and 55990 deletions
|
@ -154,6 +154,17 @@ function get_template_part( $slug, $name = null ) {
|
|||
|
||||
$templates[] = "{$slug}.php";
|
||||
|
||||
/**
|
||||
* Fires before a template part is loaded.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $slug The slug name for the generic template.
|
||||
* @param string $name The name of the specialized template.
|
||||
* @param string[] $templates Array of template files to search for, in order.
|
||||
*/
|
||||
do_action( 'get_template_part', $slug, $name, $templates );
|
||||
|
||||
locate_template( $templates, true, false );
|
||||
}
|
||||
|
||||
|
@ -175,11 +186,19 @@ function get_template_part( $slug, $name = null ) {
|
|||
* search. To give a few examples of what it can be used for.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @since 5.2.0 The $args array parameter was added in place of an $echo boolean flag.
|
||||
*
|
||||
* @param bool $echo Default to echo and not return the form.
|
||||
* @return string|void String when $echo is false.
|
||||
* @param array $args {
|
||||
* Optional. Array of display arguments.
|
||||
*
|
||||
* @type bool $echo Whether to echo or return the form. Default true.
|
||||
* @type string $aria_label ARIA label for the search form. Useful to distinguish
|
||||
* multiple search forms on the same page and improve
|
||||
* accessibility. Default empty.
|
||||
* }
|
||||
* @return string|void String when the $echo param is false.
|
||||
*/
|
||||
function get_search_form( $echo = true ) {
|
||||
function get_search_form( $args = array() ) {
|
||||
/**
|
||||
* Fires before the search form is retrieved, at the start of get_search_form().
|
||||
*
|
||||
|
@ -192,6 +211,38 @@ function get_search_form( $echo = true ) {
|
|||
|
||||
$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
|
||||
|
||||
/*
|
||||
* Back compat: to ensure previous uses of get_search_form continue to
|
||||
* function as expected, we handle a value for the boolean $echo param removed
|
||||
* in 5.2.0. Then we deal with the $args array and cast its defaults.
|
||||
*/
|
||||
$echo = true;
|
||||
if ( false === $args ) {
|
||||
$echo = false;
|
||||
}
|
||||
|
||||
if ( ! is_array( $args ) ) {
|
||||
// Set an empty array and allow default arguments to take over.
|
||||
$args = array();
|
||||
}
|
||||
|
||||
// Defaults are to echo and to output no custom label on the form.
|
||||
$defaults = array(
|
||||
'echo' => $echo,
|
||||
'aria_label' => '',
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
/**
|
||||
* Filters the array of arguments used when generating the search form.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $args The array of arguments for building the search form.
|
||||
*/
|
||||
$args = apply_filters( 'search_form_args', $args );
|
||||
|
||||
/**
|
||||
* Filters the HTML format of the search form.
|
||||
*
|
||||
|
@ -208,8 +259,18 @@ function get_search_form( $echo = true ) {
|
|||
require( $search_form_template );
|
||||
$form = ob_get_clean();
|
||||
} else {
|
||||
// Build a string containing an aria-label to use for the search form.
|
||||
if ( isset( $args['aria_label'] ) && $args['aria_label'] ) {
|
||||
$aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" ';
|
||||
} else {
|
||||
/*
|
||||
* If there's no custom aria-label, we can set a default here. At the
|
||||
* moment it's empty as there's uncertainty about what the default should be.
|
||||
*/
|
||||
$aria_label = '';
|
||||
}
|
||||
if ( 'html5' == $format ) {
|
||||
$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
$form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<label>
|
||||
<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
|
||||
<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
|
||||
|
@ -217,7 +278,7 @@ function get_search_form( $echo = true ) {
|
|||
<input type="submit" class="search-submit" value="' . esc_attr_x( 'Search', 'submit button' ) . '" />
|
||||
</form>';
|
||||
} else {
|
||||
$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
$form = '<form role="search" ' . $aria_label . 'method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<div>
|
||||
<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
|
||||
<input type="text" value="' . get_search_query() . '" name="s" id="s" />
|
||||
|
@ -240,7 +301,7 @@ function get_search_form( $echo = true ) {
|
|||
$result = $form;
|
||||
}
|
||||
|
||||
if ( $echo ) {
|
||||
if ( isset( $args['echo'] ) && $args['echo'] ) {
|
||||
echo $result;
|
||||
} else {
|
||||
return $result;
|
||||
|
@ -898,8 +959,7 @@ function get_custom_logo( $blog_id = 0 ) {
|
|||
// We have a logo. Logo is go.
|
||||
if ( $custom_logo_id ) {
|
||||
$custom_logo_attr = array(
|
||||
'class' => 'custom-logo',
|
||||
'itemprop' => 'logo',
|
||||
'class' => 'custom-logo',
|
||||
);
|
||||
|
||||
/*
|
||||
|
@ -916,7 +976,7 @@ function get_custom_logo( $blog_id = 0 ) {
|
|||
* it because wp_get_attachment_image() already adds the alt attribute.
|
||||
*/
|
||||
$html = sprintf(
|
||||
'<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
|
||||
'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
|
||||
esc_url( home_url( '/' ) ),
|
||||
wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
|
||||
);
|
||||
|
@ -1659,22 +1719,25 @@ function get_the_post_type_description() {
|
|||
* three values for the format are not used, then custom format is assumed.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 5.2.0 Added the `$selected` parameter.
|
||||
*
|
||||
* @param string $url URL to archive.
|
||||
* @param string $text Archive text description.
|
||||
* @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
|
||||
* @param string $before Optional. Content to prepend to the description. Default empty.
|
||||
* @param string $after Optional. Content to append to the description. Default empty.
|
||||
* @param string $url URL to archive.
|
||||
* @param string $text Archive text description.
|
||||
* @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
|
||||
* @param string $before Optional. Content to prepend to the description. Default empty.
|
||||
* @param string $after Optional. Content to append to the description. Default empty.
|
||||
* @param bool $selected Optional. Set to true if the current page is the selected archive page.
|
||||
* @return string HTML link content for archive.
|
||||
*/
|
||||
function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '' ) {
|
||||
function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) {
|
||||
$text = wptexturize( $text );
|
||||
$url = esc_url( $url );
|
||||
|
||||
if ( 'link' == $format ) {
|
||||
$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
|
||||
} elseif ( 'option' == $format ) {
|
||||
$link_html = "\t<option value='$url'>$before $text $after</option>\n";
|
||||
$selected_attr = $selected ? " selected='selected'" : '';
|
||||
$link_html = "\t<option value='$url'$selected_attr>$before $text $after</option>\n";
|
||||
} elseif ( 'html' == $format ) {
|
||||
$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
|
||||
} else { // custom
|
||||
|
@ -1686,6 +1749,7 @@ function get_archives_link( $url, $text, $format = 'html', $before = '', $after
|
|||
*
|
||||
* @since 2.6.0
|
||||
* @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
|
||||
* @since 5.2.0 Added the `$selected` parameter.
|
||||
*
|
||||
* @param string $link_html The archive HTML link content.
|
||||
* @param string $url URL to archive.
|
||||
|
@ -1693,15 +1757,17 @@ function get_archives_link( $url, $text, $format = 'html', $before = '', $after
|
|||
* @param string $format Link format. Can be 'link', 'option', 'html', or custom.
|
||||
* @param string $before Content to prepend to the description.
|
||||
* @param string $after Content to append to the description.
|
||||
* @param bool $selected True if the current page is the selected archive.
|
||||
*/
|
||||
return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after );
|
||||
return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display archive links based on type and format.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @since 4.4.0 $post_type arg was added.
|
||||
* @since 4.4.0 The `$post_type` argument was added.
|
||||
* @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added.
|
||||
*
|
||||
* @see get_archives_link()
|
||||
*
|
||||
|
@ -1729,6 +1795,10 @@ function get_archives_link( $url, $text, $format = 'html', $before = '', $after
|
|||
* @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
|
||||
* Default 'DESC'.
|
||||
* @type string $post_type Post type. Default 'post'.
|
||||
* @type string $year Year. Default current year.
|
||||
* @type string $monthnum Month number. Default current month number.
|
||||
* @type string $day Day. Default current day.
|
||||
* @type string $w Week. Default current week.
|
||||
* }
|
||||
* @return string|void String when retrieving.
|
||||
*/
|
||||
|
@ -1745,6 +1815,10 @@ function wp_get_archives( $args = '' ) {
|
|||
'echo' => 1,
|
||||
'order' => 'DESC',
|
||||
'post_type' => 'post',
|
||||
'year' => get_query_var( 'year' ),
|
||||
'monthnum' => get_query_var( 'monthnum' ),
|
||||
'day' => get_query_var( 'day' ),
|
||||
'w' => get_query_var( 'w' ),
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
|
@ -1820,7 +1894,8 @@ function wp_get_archives( $args = '' ) {
|
|||
if ( $r['show_post_count'] ) {
|
||||
$r['after'] = ' (' . $result->posts . ')' . $after;
|
||||
}
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
|
||||
$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month;
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
|
||||
}
|
||||
}
|
||||
} elseif ( 'yearly' == $r['type'] ) {
|
||||
|
@ -1842,7 +1917,8 @@ function wp_get_archives( $args = '' ) {
|
|||
if ( $r['show_post_count'] ) {
|
||||
$r['after'] = ' (' . $result->posts . ')' . $after;
|
||||
}
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
|
||||
$selected = is_archive() && (string) $r['year'] === $result->year;
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
|
||||
}
|
||||
}
|
||||
} elseif ( 'daily' == $r['type'] ) {
|
||||
|
@ -1865,7 +1941,8 @@ function wp_get_archives( $args = '' ) {
|
|||
if ( $r['show_post_count'] ) {
|
||||
$r['after'] = ' (' . $result->posts . ')' . $after;
|
||||
}
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
|
||||
$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month && (string) $r['day'] === $result->dayofmonth;
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
|
||||
}
|
||||
}
|
||||
} elseif ( 'weekly' == $r['type'] ) {
|
||||
|
@ -1901,7 +1978,8 @@ function wp_get_archives( $args = '' ) {
|
|||
if ( $r['show_post_count'] ) {
|
||||
$r['after'] = ' (' . $result->posts . ')' . $after;
|
||||
}
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
|
||||
$selected = is_archive() && (string) $r['year'] === $result->yr && (string) $r['w'] === $result->week;
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1924,7 +2002,8 @@ function wp_get_archives( $args = '' ) {
|
|||
} else {
|
||||
$text = $result->ID;
|
||||
}
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
|
||||
$selected = $result->ID === get_the_ID();
|
||||
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2005,7 +2084,6 @@ function get_calendar( $initial = true, $echo = true ) {
|
|||
}
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = (int) get_option( 'start_of_week' );
|
||||
$ts = current_time( 'timestamp' );
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( ! empty( $monthnum ) && ! empty( $year ) ) {
|
||||
|
@ -2025,8 +2103,8 @@ function get_calendar( $initial = true, $echo = true ) {
|
|||
$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
|
||||
}
|
||||
} else {
|
||||
$thisyear = gmdate( 'Y', $ts );
|
||||
$thismonth = gmdate( 'm', $ts );
|
||||
$thisyear = current_time( 'Y' );
|
||||
$thismonth = current_time( 'm' );
|
||||
}
|
||||
|
||||
$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
|
||||
|
@ -2136,9 +2214,9 @@ function get_calendar( $initial = true, $echo = true ) {
|
|||
}
|
||||
$newrow = false;
|
||||
|
||||
if ( $day == gmdate( 'j', $ts ) &&
|
||||
$thismonth == gmdate( 'm', $ts ) &&
|
||||
$thisyear == gmdate( 'Y', $ts ) ) {
|
||||
if ( $day == current_time( 'j' ) &&
|
||||
$thismonth == current_time( 'm' ) &&
|
||||
$thisyear == current_time( 'Y' ) ) {
|
||||
$calendar_output .= '<td id="today">';
|
||||
} else {
|
||||
$calendar_output .= '<td>';
|
||||
|
@ -2684,6 +2762,22 @@ function wp_footer() {
|
|||
do_action( 'wp_footer' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the wp_body_open action.
|
||||
*
|
||||
* * See {@see 'wp_body_open'}.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_body_open() {
|
||||
/**
|
||||
* Triggered after the opening <body> tag.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
do_action( 'wp_body_open' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the links to the general feeds.
|
||||
*
|
||||
|
@ -2962,7 +3056,7 @@ function wp_resource_hints() {
|
|||
* The path is removed in the foreach loop below.
|
||||
*/
|
||||
/** This filter is documented in wp-includes/formatting.php */
|
||||
$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/11.2.0/svg/' );
|
||||
$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/12.0.0-1/svg/' );
|
||||
|
||||
foreach ( $hints as $relation_type => $urls ) {
|
||||
$unique_urls = array();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue