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
Separator.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_Settings_Column_Separator extends AC_Settings_Column |
| 8 | implements AC_Settings_FormatCollectionInterface { |
| 9 | |
| 10 | /** |
| 11 | * @var string |
| 12 | */ |
| 13 | private $separator; |
| 14 | |
| 15 | protected function define_options() { |
| 16 | return array( 'separator' => 'comma' ); |
| 17 | } |
| 18 | |
| 19 | public function create_view() { |
| 20 | $element = $this |
| 21 | ->create_element( 'select' ) |
| 22 | ->set_options( array( |
| 23 | '' => __( 'Default', 'codepress-admin-columns' ), |
| 24 | 'comma' => __( 'Comma Separated', 'codepress-admin-columns' ), |
| 25 | 'newline' => __( 'New line', 'codepress-admin-columns' ), |
| 26 | 'none' => __( 'None', 'codepress-admin-columns' ), |
| 27 | 'white_space' => __( 'Whitespace', 'codepress-admin-columns' ), |
| 28 | ) ); |
| 29 | |
| 30 | $view = new AC_View( array( |
| 31 | 'label' => __( 'Separator', 'codepress-admin-columns' ), |
| 32 | 'tooltip' => __( 'Select a repeater sub field.', 'codepress-admin-columns' ), |
| 33 | 'setting' => $element, |
| 34 | ) ); |
| 35 | |
| 36 | return $view; |
| 37 | } |
| 38 | |
| 39 | public function get_separator() { |
| 40 | return $this->separator; |
| 41 | } |
| 42 | |
| 43 | public function set_separator( $separator ) { |
| 44 | $this->separator = $separator; |
| 45 | |
| 46 | return $this; |
| 47 | } |
| 48 | |
| 49 | public function format( AC_Collection $collection, $original_value ) { |
| 50 | switch ( $this->separator ) { |
| 51 | case 'comma' : |
| 52 | $separator = ', '; |
| 53 | |
| 54 | break; |
| 55 | case 'newline' : |
| 56 | $separator = "<br/>"; |
| 57 | |
| 58 | break; |
| 59 | case 'none' : |
| 60 | $separator = ''; |
| 61 | |
| 62 | break; |
| 63 | case 'white_space' : |
| 64 | $separator = ' '; |
| 65 | |
| 66 | break; |
| 67 | default : |
| 68 | $separator = $this->column->get_separator(); |
| 69 | } |
| 70 | |
| 71 | return $collection->filter()->implode( $separator ); |
| 72 | } |
| 73 | |
| 74 | } |
| 75 |