WPSEO_Bulk_List_Table::get_views()
Gets the views.
Метод класса: WPSEO_Bulk_List_Table{}
Хуков нет.
Возвращает
Массив
. The views.
Использование
$WPSEO_Bulk_List_Table = new WPSEO_Bulk_List_Table(); $WPSEO_Bulk_List_Table->get_views();
Код WPSEO_Bulk_List_Table::get_views() WPSEO Bulk List Table::get views Yoast 24.7
public function get_views() { global $wpdb; $status_links = []; $states = get_post_stati( [ 'show_in_admin_all_list' => true ] ); $subquery = $this->get_base_subquery(); $total_posts = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$subquery} WHERE post_status IN (" . implode( ', ', array_fill( 0, count( $states ), '%s' ) ) . ')', $states ) ); $post_status = isset( $_GET['post_status'] ) && is_string( $_GET['post_status'] ) ? sanitize_text_field( wp_unslash( $_GET['post_status'] ) ) : ''; $current_link_attributes = empty( $post_status ) ? ' class="current" aria-current="page"' : ''; $localized_text = sprintf( /* translators: %s expands to the number of posts in localized format. */ _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'wordpress-seo' ), number_format_i18n( $total_posts ) ); $status_links['all'] = '<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=bulk-editor' . $this->page_url ) ) . '"' . $current_link_attributes . '>' . $localized_text . '</a>'; $post_stati = get_post_stati( [ 'show_in_admin_all_list' => true ], 'objects' ); if ( is_array( $post_stati ) && $post_stati !== [] ) { foreach ( $post_stati as $status ) { $status_name = esc_sql( $status->name ); $total = (int) $wpdb->get_var( $wpdb->prepare( " SELECT COUNT(ID) FROM {$subquery} WHERE post_status = %s ", $status_name ) ); if ( $total === 0 ) { continue; } $current_link_attributes = ''; if ( $status_name === $post_status ) { $current_link_attributes = ' class="current" aria-current="page"'; } $status_links[ $status_name ] = '<a href="' . esc_url( add_query_arg( [ 'post_status' => $status_name ], admin_url( 'admin.php?page=wpseo_tools&tool=bulk-editor' . $this->page_url ) ) ) . '"' . $current_link_attributes . '>' . sprintf( translate_nooped_plural( $status->label_count, $total ), number_format_i18n( $total ) ) . '</a>'; } } unset( $post_stati, $status, $status_name, $total, $current_link_attributes ); $trashed_posts = $wpdb->get_var( "SELECT COUNT(ID) FROM {$subquery} WHERE post_status IN ('trash') " ); $current_link_attributes = ''; if ( $post_status === 'trash' ) { $current_link_attributes = 'class="current" aria-current="page"'; } $localized_text = sprintf( /* translators: %s expands to the number of trashed posts in localized format. */ _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $trashed_posts, 'posts', 'wordpress-seo' ), number_format_i18n( $trashed_posts ) ); $status_links['trash'] = '<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=bulk-editor&post_status=trash' . $this->page_url ) ) . '"' . $current_link_attributes . '>' . $localized_text . '</a>'; return $status_links; }