WPSEO_Bulk_List_Table::extra_tablenav
Outputs extra table navigation.
Метод класса: WPSEO_Bulk_List_Table{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WPSEO_Bulk_List_Table = new WPSEO_Bulk_List_Table(); $WPSEO_Bulk_List_Table->extra_tablenav( $which );
- $which(строка) (обязательный)
- Table nav location (such as top).
Код WPSEO_Bulk_List_Table::extra_tablenav() WPSEO Bulk List Table::extra tablenav Yoast 27.4
public function extra_tablenav( $which ) {
if ( $which === 'top' ) {
$post_types = get_post_types(
[
'public' => true,
'exclude_from_search' => false,
],
);
$instance_type = esc_attr( $this->page_type );
if ( is_array( $post_types ) && $post_types !== [] ) {
global $wpdb;
echo '<div class="alignleft actions">';
$post_types = esc_sql( $post_types );
$post_types = "'" . implode( "', '", $post_types ) . "'";
$states = get_post_stati( [ 'show_in_admin_all_list' => true ] );
$states['trash'] = 'trash';
$subquery = $this->get_base_subquery();
$post_types = $wpdb->get_results(
$wpdb->prepare(
"SELECT DISTINCT post_type FROM {$subquery}
WHERE post_status IN ("
. implode( ', ', array_fill( 0, count( $states ), '%s' ) )
. ') ORDER BY post_type ASC',
$states,
),
);
$post_type_filter = isset( $_GET['post_type_filter'] ) && is_string( $_GET['post_type_filter'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type_filter'] ) ) : '';
$selected = ( ! empty( $post_type_filter ) ) ? $post_type_filter : '-1';
$options = '<option value="-1">' . esc_html__( 'Show All Content Types', 'wordpress-seo' ) . '</option>';
if ( is_array( $post_types ) && $post_types !== [] ) {
foreach ( $post_types as $post_type ) {
$obj = get_post_type_object( $post_type->post_type );
$options .= sprintf(
'<option value="%2$s" %3$s>%1$s</option>',
esc_html( $obj->labels->name ),
esc_attr( $post_type->post_type ),
selected( $selected, $post_type->post_type, false ),
);
}
}
printf(
'<label for="%1$s" class="screen-reader-text">%2$s</label>',
esc_attr( 'post-type-filter-' . $instance_type ),
/* translators: Hidden accessibility text. */
esc_html__( 'Filter by content type', 'wordpress-seo' ),
);
printf(
'<select name="post_type_filter" id="%2$s">%1$s</select>',
// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: $options is properly escaped above.
$options,
esc_attr( 'post-type-filter-' . $instance_type ),
);
submit_button( esc_html__( 'Filter', 'wordpress-seo' ), 'button', false, false, [ 'id' => 'post-query-submit' ] );
echo '</div>';
}
}
}