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
LinkLabel.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_Settings_Column_LinkLabel extends AC_Settings_Column |
| 8 | implements AC_Settings_FormatValueInterface { |
| 9 | |
| 10 | /** |
| 11 | * @var string |
| 12 | */ |
| 13 | private $link_label; |
| 14 | |
| 15 | protected function define_options() { |
| 16 | return array( 'link_label' ); |
| 17 | } |
| 18 | |
| 19 | public function create_view() { |
| 20 | $view = new AC_View( array( |
| 21 | 'setting' => $this->create_element( 'text' ), |
| 22 | 'label' => __( 'Link Label', 'codepress-admin-columns' ), |
| 23 | 'tooltip' => __( 'Leave blank to display the url', 'codepress-admin-columns' ), |
| 24 | ) ); |
| 25 | |
| 26 | return $view; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @return string |
| 31 | */ |
| 32 | public function get_link_label() { |
| 33 | return $this->link_label; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @param string $link_label |
| 38 | * |
| 39 | * @return bool |
| 40 | */ |
| 41 | public function set_link_label( $link_label ) { |
| 42 | $this->link_label = $link_label; |
| 43 | |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | public function format( $value, $original_value ) { |
| 48 | $url = $value; |
| 49 | |
| 50 | if ( filter_var( $url, FILTER_VALIDATE_URL ) && preg_match( '/[^\w.-]/', $url ) ) { |
| 51 | $label = $this->get_value(); |
| 52 | |
| 53 | if ( ! $label ) { |
| 54 | $label = $url; |
| 55 | } |
| 56 | |
| 57 | $value = ac_helper()->html->link( $url, $label ); |
| 58 | } |
| 59 | |
| 60 | return $value; |
| 61 | } |
| 62 | |
| 63 | } |
| 64 |