PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.0.13
Admin Columns v7.0.13
7.1.4 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 / Formatter / Post / PostStatusIcon.php
codepress-admin-columns / classes / Formatter / Post Last commit date
Attachments.php 5 months ago Author.php 5 months ago BeforeMoreContent.php 5 months ago CommentCount.php 5 months ago CommentsForPostLink.php 5 months ago ContentExcerpt.php 5 months ago DatePublishFormatted.php 5 months ago Depth.php 5 months ago DescriptivePostStatus.php 5 months ago DiscussionStatus.php 5 months ago Excerpt.php 5 months ago ExcerptMissingMessage.php 5 months ago ExcerptRaw.php 5 months ago FeaturedImage.php 5 months ago HasCommentStatus.php 5 months ago IsPasswordProtected.php 5 months ago IsSticky.php 5 months ago LastModifiedAuthor.php 5 months ago Meta.php 5 months ago ModifiedDate.php 5 months ago Order.php 5 months ago PageTemplate.php 5 months ago Path.php 5 months ago Permalink.php 5 months ago PingStatus.php 5 months ago PostContent.php 5 months ago PostDate.php 5 months ago PostDateTimestamp.php 5 months ago PostFormat.php 5 months ago PostFormatIcon.php 5 months ago PostFormatLabel.php 5 months ago PostLink.php 5 months ago PostParentId.php 5 months ago PostReferences.php 5 months ago PostStatus.php 5 months ago PostStatusIcon.php 5 months ago PostTerms.php 5 months ago PostTermsOriginal.php 5 months ago PostTitle.php 5 months ago Property.php 5 months ago ShortLink.php 5 months ago Shortcodes.php 5 months ago Slug.php 5 months ago
PostStatusIcon.php
115 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Formatter\Post;
6
7 use AC\Formatter;
8 use AC\Helper;
9 use AC\Helper\Date;
10 use AC\Type\Value;
11 use DateTimeZone;
12 use WP_Post;
13
14 class PostStatusIcon implements Formatter
15 {
16
17 public function format(Value $value): Value
18 {
19 $post = $this->get_post_from_value($value);
20
21 if ( ! $post instanceof WP_Post) {
22 return $value;
23 }
24
25 return $value->with_value($this->get_status_icon($post));
26 }
27
28 private function get_post_from_value(Value $value): ?WP_Post
29 {
30 $post_value = $value->get_value();
31
32 if ($post_value instanceof WP_Post) {
33 return $post_value;
34 }
35
36 return get_post($value->get_id());
37 }
38
39 private function get_status_icon(WP_Post $post): ?string
40 {
41 switch ($post->post_status) {
42 case 'private' :
43 return Helper\Html::create()->tooltip(
44 Helper\Icon::create()->dashicon(['icon' => 'hidden', 'class' => 'gray']),
45 sprintf(
46 '%s <br><em>%s</em>',
47 __('Private'),
48 $this->format_date($post->post_date)
49 )
50 );
51
52 case 'publish' :
53 return Helper\Html::create()->tooltip(
54 Helper\Icon::create()->dashicon(['icon' => 'yes', 'class' => 'blue large']),
55 sprintf(
56 '%s <br><em>%s</em>',
57 __('Published'),
58 $this->format_date($post->post_date)
59 )
60 );
61
62 case 'draft' :
63 return Helper\Html::create()->tooltip(
64 Helper\Icon::create()->dashicon(['icon' => 'edit', 'class' => 'green']),
65 sprintf(
66 '%s <br><em>%s</em>',
67 __('Draft'),
68 $this->format_date($post->post_date)
69 )
70 );
71
72 case 'pending' :
73 return Helper\Html::create()->tooltip(
74 Helper\Icon::create()->dashicon(['icon' => 'backup', 'class' => 'orange']),
75 sprintf(
76 '%s <br><em>%s</em>',
77 __('Pending for review'),
78 $this->format_date($post->post_date)
79 )
80 );
81
82 case 'future' :
83 $icon = Helper\Html::create()->tooltip(
84 Helper\Icon::create()->dashicon(['icon' => 'clock']),
85 sprintf(
86 '%s <br><em>%s</em>',
87 __('Scheduled'),
88 $this->format_date($post->post_date)
89 )
90 );
91
92 // Missed schedule
93 if ((time() - mysql2date('G', $post->post_date_gmt)) > 0) {
94 $icon .= Helper\Html::create()->tooltip(
95 Helper\Icon::create()->dashicon(['icon' => 'flag', 'class' => 'gray']),
96 __('Missed schedule')
97 );
98 }
99
100 return $icon;
101 default:
102 return null;
103 }
104 }
105
106 private function format_date(string $date): string
107 {
108 return wp_date(
109 Date::create()->get_date_time_format(),
110 strtotime($date),
111 new DateTimeZone('UTC')
112 ) ?: '';
113 }
114
115 }