ID.php
12 years ago
actions.php
12 years ago
attachment-count.php
12 years ago
attachment.php
12 years ago
author-name.php
12 years ago
before-moretag.php
12 years ago
comment-count.php
12 years ago
comment-status.php
12 years ago
excerpt.php
12 years ago
featured-image.php
12 years ago
formats.php
12 years ago
modified.php
12 years ago
order.php
12 years ago
page-template.php
12 years ago
parent.php
12 years ago
ping-status.php
12 years ago
roles.php
12 years ago
slug.php
12 years ago
status.php
12 years ago
sticky.php
12 years ago
taxonomy.php
12 years ago
word-count.php
12 years ago
attachment-count.php
33 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CPAC_Column_Post_Attachment_Count |
| 4 | * |
| 5 | * @since 2.0.0 |
| 6 | */ |
| 7 | class CPAC_Column_Post_Attachment_Count extends CPAC_Column { |
| 8 | |
| 9 | function __construct( $storage_model ) { |
| 10 | |
| 11 | $this->properties['type'] = 'column-attachment_count'; |
| 12 | $this->properties['label'] = __( 'No. of Attachments', 'cpac' ); |
| 13 | |
| 14 | parent::__construct( $storage_model ); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @see CPAC_Column::get_value() |
| 19 | * @since 2.0.0 |
| 20 | */ |
| 21 | function get_value( $post_id ) { |
| 22 | |
| 23 | $attachment_ids = get_posts( array( |
| 24 | 'post_type' => 'attachment', |
| 25 | 'numberposts' => -1, |
| 26 | 'post_status' => null, |
| 27 | 'post_parent' => $post_id, |
| 28 | 'fields' => 'ids' |
| 29 | )); |
| 30 | |
| 31 | return count( $attachment_ids ); |
| 32 | } |
| 33 | } |