Update WordPress to 5.2

This commit is contained in:
Oliver Davies 2019-05-08 08:05:39 +01:00
parent 489b5a5914
commit e00f87f2f5
599 changed files with 119573 additions and 55990 deletions

View file

@ -458,6 +458,66 @@ class WP_Posts_List_Table extends WP_List_Table {
}
}
/**
* Displays a formats drop-down for filtering items.
*
* @since 5.2.0
* @access protected
*
* @param string $post_type Post type key.
*/
protected function formats_dropdown( $post_type ) {
/**
* Filters whether to remove the 'Formats' drop-down from the post list table.
*
* @since 5.2.0
*
* @param bool $disable Whether to disable the drop-down. Default false.
*/
if ( apply_filters( 'disable_formats_dropdown', false ) ) {
return;
}
// Make sure the dropdown shows only formats with a post count greater than 0.
$used_post_formats = get_terms(
array(
'taxonomy' => 'post_format',
'hide_empty' => true,
)
);
/*
* Return if the post type doesn't have post formats, or there are no posts using formats,
* or if we're in the trash.
*/
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) {
return;
}
$displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : '';
?>
<label for="filter-by-format" class="screen-reader-text"><?php _e( 'Filter by post format' ); ?></label>
<select name="post_format" id="filter-by-format">
<option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option>
<?php
foreach ( $used_post_formats as $used_post_format ) {
// Post format slug.
$slug = str_replace( 'post-format-', '', $used_post_format->slug );
// Pretty, translated version of the post format slug.
$pretty_name = get_post_format_string( $slug );
// Skip the standard post format.
if ( 'standard' === $slug ) {
continue;
}
?>
<option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option>
<?php
}
?>
</select>
<?php
}
/**
* @param string $which
*/
@ -470,6 +530,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$this->months_dropdown( $this->screen->post_type );
$this->categories_dropdown( $this->screen->post_type );
$this->formats_dropdown( $this->screen->post_type );
/**
* Fires before the Filter button on the Posts and Pages list tables.
@ -943,20 +1004,6 @@ class WP_Posts_List_Table extends WP_List_Table {
$pad = str_repeat( '&#8212; ', $this->current_level );
echo '<strong>';
$format = get_post_format( $post->ID );
if ( $format ) {
$label = get_post_format_string( $format );
$format_class = 'post-state-format post-format-icon post-format-' . $format;
$format_args = array(
'post_format' => $format,
'post_type' => $post->post_type,
);
echo $this->get_edit_link( $format_args, $label . ':', $format_class );
}
$title = _draft_or_post_title();
if ( $can_edit_post && $post->post_status != 'trash' ) {
@ -969,7 +1016,11 @@ class WP_Posts_List_Table extends WP_List_Table {
$title
);
} else {
echo $pad . $title;
printf(
'<span>%s%s</span>',
$pad,
$title
);
}
_post_states( $post );
@ -1126,7 +1177,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$taxonomy_object = get_taxonomy( $taxonomy );
$terms = get_the_terms( $post->ID, $taxonomy );
if ( is_array( $terms ) ) {
$out = array();
$term_links = array();
foreach ( $terms as $t ) {
$posts_in_term_qv = array();
if ( 'post' != $post->post_type ) {
@ -1140,10 +1191,23 @@ class WP_Posts_List_Table extends WP_List_Table {
}
$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) );
$out[] = $this->get_edit_link( $posts_in_term_qv, $label );
$term_links[] = $this->get_edit_link( $posts_in_term_qv, $label );
}
/**
* Filters the links in `$taxonomy` column of edit.php.
*
* @since 5.2.0
*
* @param array $term_links List of links to edit.php, filtered by the taxonomy term.
* @param string $taxonomy Taxonomy name.
* @param array $terms Array of terms appearing in the post row.
*/
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
/* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out );
echo join( __( ', ' ), $term_links );
} else {
echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
}