DateFormat
3 days ago
FieldTypeConfigurator
3 days ago
Media
3 days ago
Post
3 days ago
Pro
3 days ago
ActionIcons.php
3 days ago
AttachmentDisplay.php
3 days ago
BaseComponentFactory.php
3 days ago
BeforeAfter.php
3 days ago
BooleanValues.php
3 days ago
CharacterLimit.php
3 days ago
ColumnInfo.php
3 days ago
CommentDisplay.php
3 days ago
CommentLink.php
3 days ago
CommentStatus.php
3 days ago
CustomField.php
3 days ago
CustomFieldFactory.php
3 days ago
DateFormat.php
3 days ago
DateSaveFormat.php
3 days ago
ExifData.php
3 days ago
FieldType.php
3 days ago
FieldTypeFactory.php
3 days ago
FieldTypeFactoryBuilder.php
3 days ago
FileDisplay.php
3 days ago
FileLink.php
3 days ago
FilePreviewSize.php
3 days ago
HiddenInput.php
3 days ago
HiddenLabel.php
3 days ago
ImageSize.php
3 days ago
ImageSizeBase.php
3 days ago
IncludeMissingSizes.php
3 days ago
InputNameAware.php
3 days ago
IsLink.php
3 days ago
IsLinkable.php
3 days ago
IsMultiple.php
3 days ago
Label.php
3 days ago
LinkLabel.php
3 days ago
LinkToMenu.php
3 days ago
LinkablePostProperty.php
3 days ago
MediaLink.php
3 days ago
Message.php
3 days ago
ModalDisplay.php
3 days ago
Name.php
3 days ago
NumberFormat.php
3 days ago
NumberOfItems.php
3 days ago
Password.php
3 days ago
PathScope.php
3 days ago
PostExtendedProperty.php
3 days ago
PostLink.php
3 days ago
PostProperty.php
3 days ago
PostStatus.php
3 days ago
PostStatusIcon.php
3 days ago
PostType.php
3 days ago
PostTypeFactory.php
3 days ago
RelatedUserMetaField.php
3 days ago
SelectOptions.php
3 days ago
Separator.php
3 days ago
SerializedArrayKeys.php
3 days ago
SerializedDisplay.php
3 days ago
StringLimit.php
3 days ago
Taxonomy.php
3 days ago
TaxonomyFactory.php
3 days ago
TermLink.php
3 days ago
TermProperty.php
3 days ago
UseIcon.php
3 days ago
UserLink.php
3 days ago
UserLinkFactory.php
3 days ago
UserProperty.php
3 days ago
VideoDisplay.php
3 days ago
Width.php
3 days ago
WordLimit.php
3 days ago
WordsPerMinute.php
3 days ago
TermLink.php
61 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Setting\ComponentFactory; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\FormatterCollection; |
| 9 | use AC\Setting\Config; |
| 10 | use AC\Setting\Control\Input; |
| 11 | use AC\Setting\Control\Input\OptionFactory; |
| 12 | use AC\Setting\Control\OptionCollection; |
| 13 | use AC\Type\PostTypeSlug; |
| 14 | |
| 15 | final class TermLink extends BaseComponentFactory |
| 16 | { |
| 17 | private ?PostTypeSlug $post_type; |
| 18 | |
| 19 | public function __construct(?PostTypeSlug $post_type = null) |
| 20 | { |
| 21 | $this->post_type = $post_type; |
| 22 | } |
| 23 | |
| 24 | protected function get_label(Config $config): ?string |
| 25 | { |
| 26 | return __('Link To', 'codepress-admin-columns'); |
| 27 | } |
| 28 | |
| 29 | public function with_post_type(PostTypeSlug $post_type): self |
| 30 | { |
| 31 | $clone = clone $this; |
| 32 | $clone->post_type = $post_type; |
| 33 | |
| 34 | return $clone; |
| 35 | } |
| 36 | |
| 37 | protected function get_input(Config $config): ?Input |
| 38 | { |
| 39 | return OptionFactory::create_select( |
| 40 | 'term_link_to', |
| 41 | OptionCollection::from_array($this->get_input_options()), |
| 42 | (string)$config->get('term_link_to') |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | protected function add_formatters(Config $config, FormatterCollection $formatters): void |
| 47 | { |
| 48 | $formatters->add(new AC\Formatter\Term\TermLink((string)$config->get('term_link_to'), $this->post_type)); |
| 49 | } |
| 50 | |
| 51 | protected function get_input_options(): array |
| 52 | { |
| 53 | return [ |
| 54 | '' => __('None'), |
| 55 | 'filter' => __('Filter by Term', 'codepress-admin-columns'), |
| 56 | 'edit' => __('Edit Term', 'codepress-admin-columns'), |
| 57 | ]; |
| 58 | } |
| 59 | |
| 60 | } |
| 61 |