ACF_Admin_Post_Types::render_admin_table_column_num_posts
Renders the number of posts created for the post type in the list table.
Метод класса: ACF_Admin_Post_Types{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$ACF_Admin_Post_Types = new ACF_Admin_Post_Types(); $ACF_Admin_Post_Types->render_admin_table_column_num_posts( $post_type );
- $post_type(массив) (обязательный)
- The main post type array.
Список изменений
| С версии 6.1 | Введена. |
Код ACF_Admin_Post_Types::render_admin_table_column_num_posts() ACF Admin Post Types::render admin table column num posts ACF 6.8.8
public function render_admin_table_column_num_posts( $post_type ) {
$no_posts = '<span class="acf-emdash" aria-hidden="true">—</span>';
$no_posts .= '<span class="screen-reader-text">' . esc_html__( 'No posts', 'acf' ) . '</span>';
// WP doesn't count posts for post types that don't exist.
if ( empty( $post_type['active'] ) || 'trash' === get_post_status( $post_type['ID'] ) ) {
echo acf_esc_html( $no_posts );
return;
}
$num_posts = wp_count_posts( $post_type['post_type'] );
if ( is_object( $num_posts ) && property_exists( $num_posts, 'publish' ) ) {
$num_posts = $num_posts->publish;
}
if ( ! $num_posts || ! is_numeric( $num_posts ) ) {
echo acf_esc_html( $no_posts );
return;
}
printf(
'<a href="%s">%s</a>',
esc_url( admin_url( 'edit.php?post_type=' . $post_type['post_type'] ) ),
esc_html( number_format_i18n( $num_posts ) )
);
}