Addons.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Admin\Asset; |
| 6 | |
| 7 | use AC\Asset\Location; |
| 8 | use AC\Asset\Script; |
| 9 | use AC\Nonce; |
| 10 | use AC\Type\Url\Site; |
| 11 | use AC\Type\Url\UtmTags; |
| 12 | |
| 13 | class Addons extends Script |
| 14 | { |
| 15 | private Nonce\Ajax $nonce; |
| 16 | |
| 17 | private Location $asset_location; |
| 18 | |
| 19 | private bool $is_pro; |
| 20 | |
| 21 | public function __construct( |
| 22 | string $handle, |
| 23 | Nonce\Ajax $nonce, |
| 24 | Location $location, |
| 25 | Location $asset_location, |
| 26 | bool $is_pro |
| 27 | ) { |
| 28 | parent::__construct($handle, $location, ['jquery']); |
| 29 | |
| 30 | $this->nonce = $nonce; |
| 31 | $this->asset_location = $asset_location; |
| 32 | $this->location = $location; |
| 33 | $this->is_pro = $is_pro; |
| 34 | } |
| 35 | |
| 36 | public function register(): void |
| 37 | { |
| 38 | parent::register(); |
| 39 | |
| 40 | $translation = new Script\Localize\Translation([ |
| 41 | 'plugin_installed' => __('The Add-on %s is activated.', 'codepress-admin-columns'), |
| 42 | 'plugin_not_detected' => __('Plugin not detected', 'codepress-admin-columns'), |
| 43 | 'plugin_detected' => __('Detected on your site', 'codepress-admin-columns'), |
| 44 | 'enable_integration' => __('Enable Integration', 'codepress-admin-columns'), |
| 45 | 'buy_now' => __('Unlock with Pro →', 'codepress-admin-columns'), |
| 46 | 'learn_more' => __('Learn more', 'codepress-admin-columns'), |
| 47 | 'subtitle' => __('Connect Admin Columns with the plugins you already use. Display, edit, filter, sort, and export their data - all from the list table.', 'codepress-admin-columns'), |
| 48 | 'title' => [ |
| 49 | 'enabled' => __('Enabled Integrations', 'codepress-admin-columns'), |
| 50 | 'recommended' => __('Recommended Integrations', 'codepress-admin-columns'), |
| 51 | 'available' => __('More Integrations', 'codepress-admin-columns'), |
| 52 | ], |
| 53 | ]); |
| 54 | |
| 55 | $this |
| 56 | ->localize('ac_addons_i18n', $translation) |
| 57 | ->add_inline_variable( |
| 58 | 'ac_addons', |
| 59 | [ |
| 60 | $this->nonce->get_name() => $this->nonce->create(), |
| 61 | 'is_network_admin' => is_network_admin(), |
| 62 | 'asset_location' => $this->asset_location->get_url(), |
| 63 | 'pro_installed' => $this->is_pro, |
| 64 | 'buy_url' => (new UtmTags(new Site(Site::PAGE_PRICING), 'integration'))->get_url(), |
| 65 | ] |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | } |
| 70 |