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
parent.php
59 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CPAC_Column_Post_Parent |
| 4 | * |
| 5 | * @since 2.0.0 |
| 6 | */ |
| 7 | class CPAC_Column_Post_Parent extends CPAC_Column { |
| 8 | |
| 9 | function __construct( $storage_model ) { |
| 10 | |
| 11 | $this->properties['type'] = 'column-parent'; |
| 12 | $this->properties['label'] = __( 'Parent', 'cpac' ); |
| 13 | $this->properties['object_property'] = 'post_parent'; |
| 14 | |
| 15 | parent::__construct( $storage_model ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @see CPAC_Column::get_value() |
| 20 | * @since 2.0.0 |
| 21 | */ |
| 22 | function get_value( $post_id ) { |
| 23 | |
| 24 | if ( !( $parent_id = $this->get_raw_value( $post_id ) ) ) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | $title = get_the_title( $parent_id ); |
| 29 | $link = get_edit_post_link( $parent_id ); |
| 30 | |
| 31 | return $link ? "<a href='{$link}'>{$title}</a>" : $title; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @see CPAC_Column::get_raw_value() |
| 36 | * @since 2.0.3 |
| 37 | */ |
| 38 | function get_raw_value( $post_id ) { |
| 39 | |
| 40 | $parent_id = get_post_field( 'post_parent', $post_id ); |
| 41 | |
| 42 | if ( !$parent_id || !is_numeric( $parent_id ) ) |
| 43 | return false; |
| 44 | |
| 45 | return $parent_id; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @see CPAC_Column::apply_conditional() |
| 50 | * @since 2.0.0 |
| 51 | */ |
| 52 | function apply_conditional() { |
| 53 | |
| 54 | if ( post_type_supports( $this->storage_model->key, 'page-attributes' ) ) |
| 55 | return true; |
| 56 | |
| 57 | return false; |
| 58 | } |
| 59 | } |