Acf.php
104 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Admin\Banner\Context; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Acf\FieldGroupCache; |
| 9 | use AC\Admin\Banner\BannerContext; |
| 10 | use AC\TableScreen; |
| 11 | use AC\Type\StartingPrice; |
| 12 | use AC\Type\Url\Site; |
| 13 | use AC\Type\Url\UtmTags; |
| 14 | |
| 15 | class Acf implements BannerContext |
| 16 | { |
| 17 | private FieldGroupCache $field_group_cache; |
| 18 | |
| 19 | public function __construct(FieldGroupCache $field_group_cache) |
| 20 | { |
| 21 | $this->field_group_cache = $field_group_cache; |
| 22 | } |
| 23 | |
| 24 | public function is_active(TableScreen $table_screen): bool |
| 25 | { |
| 26 | if (! AC\Acf::is_active()) { |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | return $this->field_group_cache->get_count_for_table_screen($table_screen) > 0; |
| 31 | } |
| 32 | |
| 33 | public function get_priority(): int |
| 34 | { |
| 35 | return 10; |
| 36 | } |
| 37 | |
| 38 | public function get_arguments(TableScreen $table_screen): array |
| 39 | { |
| 40 | $upgrade_url = new UtmTags(new Site(Site::PAGE_ADDON_ACF), 'banner-acf'); |
| 41 | |
| 42 | $field_count = $this->field_group_cache->get_count_for_table_screen($table_screen); |
| 43 | |
| 44 | return [ |
| 45 | 'badge' => __('Admin Columns Pro', 'codepress-admin-columns'), |
| 46 | 'title' => _n( |
| 47 | 'Your ACF field is hidden on this screen', |
| 48 | 'Your ACF fields are hidden on this screen', |
| 49 | $field_count, |
| 50 | 'codepress-admin-columns' |
| 51 | ), |
| 52 | 'description' => sprintf( |
| 53 | _n( |
| 54 | '%d ACF field is not visible here. Pro turns it into a column you can sort, filter, edit, and export - no code needed.', |
| 55 | '%d ACF fields are not visible here. Pro turns each one into a column you can sort, filter, edit, and export - no code needed.', |
| 56 | $field_count, |
| 57 | 'codepress-admin-columns' |
| 58 | ), |
| 59 | $field_count |
| 60 | ), |
| 61 | 'quote' => [ |
| 62 | 'text' => __('A super intuitive life saver!', 'codepress-admin-columns'), |
| 63 | 'cite' => __('Elliot Condon, creator of Advanced Custom Fields', 'codepress-admin-columns'), |
| 64 | ], |
| 65 | 'features_label' => __('With Pro, your ACF fields become:', 'codepress-admin-columns'), |
| 66 | 'features' => [ |
| 67 | [ |
| 68 | 'url' => $upgrade_url->with_content('usp-acf-columns')->get_url(), |
| 69 | 'label' => __('Visible as columns on this screen', 'codepress-admin-columns'), |
| 70 | ], |
| 71 | [ |
| 72 | 'url' => $upgrade_url->with_content('usp-acf-sorting')->get_url(), |
| 73 | 'label' => __('Filterable and sortable by any field', 'codepress-admin-columns'), |
| 74 | ], |
| 75 | [ |
| 76 | 'url' => $upgrade_url->with_content('usp-acf-editing')->get_url(), |
| 77 | 'label' => __('Editable directly in the table', 'codepress-admin-columns'), |
| 78 | ], |
| 79 | [ |
| 80 | 'url' => $upgrade_url->with_content('usp-acf-bulk-edit')->get_url(), |
| 81 | 'label' => __('Bulk editable across hundreds of posts', 'codepress-admin-columns'), |
| 82 | ], |
| 83 | [ |
| 84 | 'url' => $upgrade_url->with_content('usp-acf-export')->get_url(), |
| 85 | 'label' => __('Exportable to CSV', 'codepress-admin-columns'), |
| 86 | ], |
| 87 | ], |
| 88 | 'upgrade_cta' => __('Unlock ACF fields in your table', 'codepress-admin-columns'), |
| 89 | 'upgrade_cta_price' => sprintf( |
| 90 | '%s · %s', |
| 91 | sprintf( |
| 92 | /* translators: %s: price (e.g. $79) */ |
| 93 | __('from %s/year', 'codepress-admin-columns'), |
| 94 | StartingPrice::get() |
| 95 | ), |
| 96 | __('all features included', 'codepress-admin-columns') |
| 97 | ), |
| 98 | 'integrations' => [], |
| 99 | 'promo_url' => $upgrade_url->get_url(), |
| 100 | ]; |
| 101 | } |
| 102 | |
| 103 | } |
| 104 |