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
StatusIcon.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Settings\Column; |
| 4 | |
| 5 | use AC\Settings; |
| 6 | use AC\View; |
| 7 | |
| 8 | class StatusIcon extends Settings\Column |
| 9 | implements Settings\FormatValue { |
| 10 | |
| 11 | /** |
| 12 | * @var bool |
| 13 | */ |
| 14 | private $use_icon; |
| 15 | |
| 16 | protected function define_options() { |
| 17 | return [ 'use_icon' => '' ]; |
| 18 | } |
| 19 | |
| 20 | public function create_view() { |
| 21 | |
| 22 | $setting = $this->create_element( 'radio' ) |
| 23 | ->set_options( [ |
| 24 | '1' => __( 'Yes' ), |
| 25 | '' => __( 'No' ), |
| 26 | ] ); |
| 27 | |
| 28 | $view = new View( [ |
| 29 | 'label' => __( 'Use an icon?', 'codepress-admin-columns' ), |
| 30 | 'tooltip' => __( 'Use an icon instead of text for displaying the status.', 'codepress-admin-columns' ), |
| 31 | 'setting' => $setting, |
| 32 | ] ); |
| 33 | |
| 34 | return $view; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @return int |
| 39 | */ |
| 40 | public function get_use_icon() { |
| 41 | return $this->use_icon; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @param $use_icon |
| 46 | * |
| 47 | * @return bool |
| 48 | */ |
| 49 | public function set_use_icon( $use_icon ) { |
| 50 | $this->use_icon = $use_icon; |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @param string $status |
| 57 | * @param int $post_id |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | public function format( $status, $post_id ) { |
| 62 | global $wp_post_statuses; |
| 63 | |
| 64 | $value = $status; |
| 65 | |
| 66 | $post = get_post( $post_id ); |
| 67 | |
| 68 | if ( $this->get_use_icon() ) { |
| 69 | $value = ac_helper()->post->get_status_icon( $post ); |
| 70 | |
| 71 | if ( $post->post_password ) { |
| 72 | $value .= ac_helper()->html->tooltip( ac_helper()->icon->dashicon( [ 'icon' => 'lock', 'class' => 'gray' ] ), __( 'Password protected' ) ); |
| 73 | } |
| 74 | } else if ( isset( $wp_post_statuses[ $status ] ) ) { |
| 75 | $value = $wp_post_statuses[ $status ]->label; |
| 76 | |
| 77 | if ( 'future' === $status ) { |
| 78 | $value .= " <p class='description'>" . ac_helper()->date->date( $post->post_date, 'wp_date_time' ) . "</p>"; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return $value; |
| 83 | } |
| 84 | |
| 85 | } |