DateFormat
2 days ago
FieldTypeConfigurator
2 days ago
Media
2 days ago
Post
2 days ago
Pro
2 days ago
ActionIcons.php
2 days ago
AttachmentDisplay.php
2 days ago
BaseComponentFactory.php
2 days ago
BeforeAfter.php
2 days ago
BooleanValues.php
2 days ago
CharacterLimit.php
2 days ago
ColumnInfo.php
2 days ago
CommentDisplay.php
2 days ago
CommentLink.php
2 days ago
CommentStatus.php
2 days ago
CustomField.php
2 days ago
CustomFieldFactory.php
2 days ago
DateFormat.php
2 days ago
DateSaveFormat.php
2 days ago
ExifData.php
2 days ago
FieldType.php
2 days ago
FieldTypeFactory.php
2 days ago
FieldTypeFactoryBuilder.php
2 days ago
FileDisplay.php
2 days ago
FileLink.php
2 days ago
FilePreviewSize.php
2 days ago
HiddenInput.php
2 days ago
HiddenLabel.php
2 days ago
ImageSize.php
2 days ago
ImageSizeBase.php
2 days ago
IncludeMissingSizes.php
2 days ago
InputNameAware.php
2 days ago
IsLink.php
2 days ago
IsLinkable.php
2 days ago
IsMultiple.php
2 days ago
Label.php
2 days ago
LinkLabel.php
2 days ago
LinkToMenu.php
2 days ago
LinkablePostProperty.php
2 days ago
MediaLink.php
2 days ago
Message.php
2 days ago
ModalDisplay.php
2 days ago
Name.php
2 days ago
NumberFormat.php
2 days ago
NumberOfItems.php
2 days ago
Password.php
2 days ago
PathScope.php
2 days ago
PostExtendedProperty.php
2 days ago
PostLink.php
2 days ago
PostProperty.php
2 days ago
PostStatus.php
2 days ago
PostStatusIcon.php
2 days ago
PostType.php
2 days ago
PostTypeFactory.php
2 days ago
RelatedUserMetaField.php
2 days ago
SelectOptions.php
2 days ago
Separator.php
2 days ago
SerializedArrayKeys.php
2 days ago
SerializedDisplay.php
2 days ago
StringLimit.php
2 days ago
Taxonomy.php
2 days ago
TaxonomyFactory.php
2 days ago
TermLink.php
2 days ago
TermProperty.php
2 days ago
UseIcon.php
2 days ago
UserLink.php
2 days ago
UserLinkFactory.php
2 days ago
UserProperty.php
2 days ago
VideoDisplay.php
2 days ago
Width.php
2 days ago
WordLimit.php
2 days ago
WordsPerMinute.php
2 days ago
CustomField.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Setting\ComponentFactory; |
| 6 | |
| 7 | use AC\Setting\Config; |
| 8 | use AC\Setting\Control\Input; |
| 9 | use AC\Setting\Control\Input\OptionFactory; |
| 10 | use AC\Type\TableScreenContext; |
| 11 | |
| 12 | class CustomField extends BaseComponentFactory |
| 13 | { |
| 14 | private const NAME = 'field'; |
| 15 | |
| 16 | private TableScreenContext $table_screen_context; |
| 17 | |
| 18 | public function __construct(TableScreenContext $table_screen_context) |
| 19 | { |
| 20 | $this->table_screen_context = $table_screen_context; |
| 21 | } |
| 22 | |
| 23 | protected function get_label(Config $config): ?string |
| 24 | { |
| 25 | return __('Field', 'codepress-admin-columns'); |
| 26 | } |
| 27 | |
| 28 | protected function get_description(Config $config): ?string |
| 29 | { |
| 30 | return __('Custom field key', 'codepress-admin-columns'); |
| 31 | } |
| 32 | |
| 33 | private function use_text_field(): bool |
| 34 | { |
| 35 | return (bool)apply_filters('ac/column/custom_field/use_text_input', false); |
| 36 | } |
| 37 | |
| 38 | protected function get_input(Config $config): ?Input |
| 39 | { |
| 40 | if ($this->use_text_field()) { |
| 41 | return new Input\Open( |
| 42 | self::NAME, |
| 43 | 'text', |
| 44 | (string)$config->get('field', ''), |
| 45 | __('Custom field key', 'codepress-admin-columns') |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | return OptionFactory::create_select_remote( |
| 50 | self::NAME, |
| 51 | 'ac-custom-field-keys', |
| 52 | $config->get('field', ''), |
| 53 | [ |
| 54 | 'meta_type' => (string)$this->table_screen_context->get_meta_type(), |
| 55 | 'post_type' => $this->table_screen_context->has_post_type() |
| 56 | ? (string)$this->table_screen_context->get_post_type() |
| 57 | : '', |
| 58 | 'taxonomy' => $this->table_screen_context->has_taxonomy() |
| 59 | ? (string)$this->table_screen_context->get_taxonomy() |
| 60 | : '', |
| 61 | ], |
| 62 | __('Select', 'codepress-admin-columns') |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | } |
| 67 |