PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 4.3.2
Admin Columns v4.3.2
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Settings / Column / Post.php
codepress-admin-columns / classes / Settings / Column Last commit date
BeforeAfter 5 years ago Pro 5 years ago ActionIcons.php 5 years ago AttachmentDisplay.php 5 years ago BeforeAfter.php 5 years ago CharacterLimit.php 5 years ago Comment.php 5 years ago CommentCount.php 5 years ago CommentLink.php 5 years ago CustomField.php 5 years ago CustomFieldType.php 5 years ago Date.php 5 years ago DateTimeFormat.php 5 years ago ExifData.php 5 years ago Image.php 5 years ago Images.php 5 years ago Label.php 5 years ago LinkLabel.php 5 years ago LinkToMenu.php 5 years ago MediaLink.php 5 years ago Message.php 5 years ago Meta.php 5 years ago MissingImageSize.php 5 years ago NumberFormat.php 5 years ago NumberOfItems.php 5 years ago Password.php 5 years ago PathScope.php 5 years ago Post.php 5 years ago PostFormatIcon.php 5 years ago PostLink.php 5 years ago PostStatus.php 5 years ago PostType.php 5 years ago Pro.php 5 years ago Separator.php 5 years ago StatusIcon.php 5 years ago StringLimit.php 5 years ago Taxonomy.php 5 years ago Term.php 5 years ago TermLink.php 5 years ago Time.php 5 years ago Toggle.php 5 years ago Type.php 5 years ago User.php 5 years ago UserLink.php 5 years ago Width.php 5 years ago WordLimit.php 5 years ago WordsPerMinute.php 5 years ago
Post.php
129 lines
1 <?php
2
3 namespace AC\Settings\Column;
4
5 use AC\Settings;
6 use AC\View;
7
8 class Post extends Settings\Column
9 implements Settings\FormatValue {
10
11 const NAME = 'post';
12
13 const PROPERTY_AUTHOR = 'author';
14 const PROPERTY_FEATURED_IMAGE = 'thumbnail';
15 const PROPERTY_ID = 'id';
16 const PROPERTY_TITLE = 'title';
17 const PROPERTY_DATE = 'date';
18
19 /**
20 * @var string
21 */
22 private $post_property;
23
24 protected function set_name() {
25 $this->name = self::NAME;
26 }
27
28 protected function define_options() {
29 return [
30 'post_property_display' => self::PROPERTY_TITLE,
31 ];
32 }
33
34 public function get_dependent_settings() {
35 $setting = [];
36
37 switch ( $this->get_post_property_display() ) {
38 case self::PROPERTY_FEATURED_IMAGE :
39 $setting[] = new Settings\Column\Image( $this->column );
40 break;
41 case self::PROPERTY_DATE :
42 $setting[] = new Settings\Column\Date( $this->column );
43 break;
44 }
45
46 $setting[] = new Settings\Column\PostLink( $this->column );
47
48 return $setting;
49 }
50
51 /**
52 * @param int $id
53 * @param mixed $original_value
54 *
55 * @return string|int
56 */
57 public function format( $id, $original_value ) {
58
59 switch ( $this->get_post_property_display() ) {
60
61 case self::PROPERTY_AUTHOR :
62 $value = ac_helper()->user->get_display_name( ac_helper()->post->get_raw_field( 'post_author', $id ) );
63
64 break;
65 case self::PROPERTY_FEATURED_IMAGE :
66 $value = get_post_thumbnail_id( $id );
67
68 break;
69 case self::PROPERTY_TITLE :
70 $value = ac_helper()->post->get_title( $id );
71
72 break;
73 case self::PROPERTY_DATE :
74 $value = ac_helper()->post->get_raw_field( 'post_date', $id );
75
76 break;
77 default :
78 $value = $id;
79 }
80
81 return $value;
82 }
83
84 public function create_view() {
85 $select = $this->create_element( 'select' )
86 ->set_attribute( 'data-refresh', 'column' )
87 ->set_options( $this->get_display_options() );
88
89 $view = new View( [
90 'label' => __( 'Display', 'codepress-admin-columns' ),
91 'setting' => $select,
92 ] );
93
94 return $view;
95 }
96
97 protected function get_display_options() {
98 $options = [
99 self::PROPERTY_TITLE => __( 'Title' ),
100 self::PROPERTY_ID => __( 'ID' ),
101 self::PROPERTY_AUTHOR => __( 'Author' ),
102 self::PROPERTY_FEATURED_IMAGE => _x( 'Featured Image', 'post' ),
103 self::PROPERTY_DATE => __( 'Date' ),
104 ];
105
106 asort( $options );
107
108 return $options;
109 }
110
111 /**
112 * @return string
113 */
114 public function get_post_property_display() {
115 return $this->post_property;
116 }
117
118 /**
119 * @param string $post_property
120 *
121 * @return bool
122 */
123 public function set_post_property_display( $post_property ) {
124 $this->post_property = $post_property;
125
126 return true;
127 }
128
129 }