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
permalink.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
word-count.php
12 years ago
attachment-count.php
42 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 | return $this->get_raw_value( $post_id ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @see CPAC_Column::get_raw_value() |
| 28 | * @since 2.0.3 |
| 29 | */ |
| 30 | function get_raw_value( $post_id ) { |
| 31 | |
| 32 | $attachment_ids = get_posts( array( |
| 33 | 'post_type' => 'attachment', |
| 34 | 'numberposts' => -1, |
| 35 | 'post_status' => null, |
| 36 | 'post_parent' => $post_id, |
| 37 | 'fields' => 'ids' |
| 38 | )); |
| 39 | |
| 40 | return count( $attachment_ids ); |
| 41 | } |
| 42 | } |