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
CommentLink.php
89 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Settings\Column; |
| 4 | |
| 5 | use AC\Settings; |
| 6 | use AC\View; |
| 7 | |
| 8 | /** |
| 9 | * @since 3.4.6 |
| 10 | */ |
| 11 | class CommentLink extends Settings\Column |
| 12 | implements Settings\FormatValue { |
| 13 | |
| 14 | /** |
| 15 | * @var string |
| 16 | */ |
| 17 | protected $comment_link_to; |
| 18 | |
| 19 | protected function define_options() { |
| 20 | return [ |
| 21 | 'comment_link_to' => '', |
| 22 | ]; |
| 23 | } |
| 24 | |
| 25 | public function format( $value, $original_value ) { |
| 26 | $id = $original_value; |
| 27 | |
| 28 | switch ( $this->get_comment_link_to() ) { |
| 29 | case 'view_comment' : |
| 30 | $link = get_comment_link( $id ); |
| 31 | |
| 32 | break; |
| 33 | case 'edit_comment' : |
| 34 | $comment = get_comment( $id ); |
| 35 | |
| 36 | $link = $comment |
| 37 | ? get_edit_comment_link( $comment ) |
| 38 | : false; |
| 39 | |
| 40 | break; |
| 41 | default : |
| 42 | $link = false; |
| 43 | } |
| 44 | |
| 45 | if ( $link ) { |
| 46 | $value = ac_helper()->html->link( $link, $value ); |
| 47 | } |
| 48 | |
| 49 | return $value; |
| 50 | } |
| 51 | |
| 52 | public function create_view() { |
| 53 | $select = $this->create_element( 'select' )->set_options( $this->get_link_options() ); |
| 54 | |
| 55 | $view = new View( [ |
| 56 | 'label' => __( 'Link To', 'codepress-admin-columns' ), |
| 57 | 'setting' => $select, |
| 58 | ] ); |
| 59 | |
| 60 | return $view; |
| 61 | } |
| 62 | |
| 63 | protected function get_link_options() { |
| 64 | return [ |
| 65 | '' => __( 'None' ), |
| 66 | 'view_comment' => __( 'View Comment', 'codepress-admin-columns' ), |
| 67 | 'edit_comment' => __( 'Edit Comment', 'codepress-admin-columns' ), |
| 68 | ]; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @return string |
| 73 | */ |
| 74 | public function get_comment_link_to() { |
| 75 | return $this->comment_link_to; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @param string $comment_link_to |
| 80 | * |
| 81 | * @return bool |
| 82 | */ |
| 83 | public function set_comment_link_to( $comment_link_to ) { |
| 84 | $this->comment_link_to = $comment_link_to; |
| 85 | |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | } |