BeforeAfter
8 years ago
ActionIcons.php
8 years ago
AttachmentDisplay.php
8 years ago
BeforeAfter.php
8 years ago
CharacterLimit.php
8 years ago
CommentCount.php
8 years ago
CustomField.php
8 years ago
CustomFieldType.php
8 years ago
Date.php
8 years ago
ExifData.php
8 years ago
Image.php
8 years ago
Images.php
8 years ago
Label.php
8 years ago
LinkLabel.php
8 years ago
LinkToMenu.php
8 years ago
Message.php
8 years ago
Meta.php
8 years ago
MissingImageSize.php
8 years ago
NumberOfItems.php
8 years ago
Password.php
8 years ago
PathScope.php
8 years ago
Post.php
8 years ago
PostFormatIcon.php
8 years ago
PostLink.php
8 years ago
PostType.php
8 years ago
Separator.php
8 years ago
StatusIcon.php
8 years ago
StringLimit.php
8 years ago
Taxonomy.php
8 years ago
Term.php
8 years ago
Toggle.php
8 years ago
Type.php
8 years ago
User.php
8 years ago
Width.php
8 years ago
WordLimit.php
8 years ago
WordsPerMinute.php
8 years ago
PostType.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_Settings_Column_PostType extends AC_Settings_Column { |
| 8 | |
| 9 | /** |
| 10 | * @var string |
| 11 | */ |
| 12 | private $post_type; |
| 13 | |
| 14 | protected function define_options() { |
| 15 | return array( 'post_type' ); |
| 16 | } |
| 17 | |
| 18 | public function create_view() { |
| 19 | $setting = $this->create_element( 'select' ) |
| 20 | ->set_options( $this->get_post_type_labels() ); |
| 21 | |
| 22 | $view = new AC_View( array( |
| 23 | 'label' => __( 'Post Type', 'codepress-admin-columns' ), |
| 24 | 'setting' => $setting, |
| 25 | ) ); |
| 26 | |
| 27 | return $view; |
| 28 | } |
| 29 | |
| 30 | private function get_post_type_labels() { |
| 31 | $options = array(); |
| 32 | $post_types = AC()->get_post_types(); |
| 33 | |
| 34 | if ( ! is_array( $post_types ) ) { |
| 35 | return $options; |
| 36 | } |
| 37 | |
| 38 | foreach ( $post_types as $post_type ) { |
| 39 | $post_type_object = get_post_type_object( $post_type ); |
| 40 | $options[ $post_type ] = $post_type_object->labels->name; |
| 41 | } |
| 42 | |
| 43 | return $options; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @return string |
| 48 | */ |
| 49 | public function get_post_type() { |
| 50 | return $this->post_type; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @param string $post_type |
| 55 | * |
| 56 | * @return true |
| 57 | */ |
| 58 | public function set_post_type( $post_type ) { |
| 59 | $this->post_type = $post_type; |
| 60 | |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | } |
| 65 |