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
BeforeAfter.php
118 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_Settings_Column_BeforeAfter extends AC_Settings_Column |
| 8 | implements AC_Settings_FormatValueInterface { |
| 9 | |
| 10 | /** |
| 11 | * @var string |
| 12 | */ |
| 13 | private $before; |
| 14 | |
| 15 | /** |
| 16 | * @var string |
| 17 | */ |
| 18 | private $after; |
| 19 | |
| 20 | protected function set_name() { |
| 21 | $this->name = 'before_after'; |
| 22 | } |
| 23 | |
| 24 | protected function define_options() { |
| 25 | return array( 'before', 'after' ); |
| 26 | } |
| 27 | |
| 28 | public function format( $value, $original_value ) { |
| 29 | if ( ac_helper()->string->is_empty( $value ) ) { |
| 30 | return $value; |
| 31 | } |
| 32 | |
| 33 | if ( $this->get_before() || $this->get_after() ) { |
| 34 | $value = $this->get_before() . $value . $this->get_after(); |
| 35 | } |
| 36 | |
| 37 | return $value; |
| 38 | } |
| 39 | |
| 40 | protected function get_before_element() { |
| 41 | $text = $this->create_element( 'text', 'before' ); |
| 42 | $text->set_attribute( 'placeholder', $this->get_default( 'before' ) ); |
| 43 | |
| 44 | return $text; |
| 45 | } |
| 46 | |
| 47 | protected function get_after_element() { |
| 48 | $text = $this->create_element( 'text', 'after' ); |
| 49 | $text->set_attribute( 'placeholder', $this->get_default( 'after' ) ); |
| 50 | |
| 51 | return $text; |
| 52 | } |
| 53 | |
| 54 | public function create_view() { |
| 55 | $setting = $this->get_before_element(); |
| 56 | |
| 57 | $before = new AC_View( array( |
| 58 | 'label' => __( 'Before', 'codepress-admin-columns' ), |
| 59 | 'description' => __( 'This text will appear before the column value.', 'codepress-admin-columns' ), |
| 60 | 'setting' => $setting, |
| 61 | 'for' => $setting->get_id(), |
| 62 | ) ); |
| 63 | |
| 64 | $setting = $this->get_after_element(); |
| 65 | |
| 66 | $after = new AC_View( array( |
| 67 | 'label' => __( 'After', 'codepress-admin-columns' ), |
| 68 | 'description' => __( 'This text will appear after the column value.', 'codepress-admin-columns' ), |
| 69 | 'setting' => $setting, |
| 70 | 'for' => $setting->get_id(), |
| 71 | ) ); |
| 72 | |
| 73 | $view = new AC_View( array( |
| 74 | 'label' => __( 'Display Options', 'codepress-admin-columns' ), |
| 75 | 'sections' => array( $before, $after ), |
| 76 | ) ); |
| 77 | |
| 78 | return $view; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return string |
| 83 | */ |
| 84 | public function get_before() { |
| 85 | return $this->before; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @param $before |
| 90 | * |
| 91 | * @return bool |
| 92 | */ |
| 93 | public function set_before( $before ) { |
| 94 | $this->before = $before; |
| 95 | |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return string |
| 101 | */ |
| 102 | public function get_after() { |
| 103 | return $this->after; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @param $after |
| 108 | * |
| 109 | * @return bool |
| 110 | */ |
| 111 | public function set_after( $after ) { |
| 112 | $this->after = $after; |
| 113 | |
| 114 | return true; |
| 115 | } |
| 116 | |
| 117 | } |
| 118 |