activation-actions.php
4 years ago
build-inline-scripts.php
3 weeks ago
build-modules.php
4 months ago
build-widgets.php
4 months ago
config-list.php
4 months ago
editor-promotion.php
3 weeks ago
handler-api.php
6 months ago
handler-widget.php
4 years ago
plugin-unsubscribe.php
3 weeks ago
editor-promotion.php
84 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Core; |
| 3 | |
| 4 | defined('ABSPATH') || exit; |
| 5 | |
| 6 | class Editor_Promotion { |
| 7 | |
| 8 | use \ElementsKit_Lite\Traits\Singleton; |
| 9 | |
| 10 | public function init() { |
| 11 | // Enqueue promotion scripts |
| 12 | add_action('elementor/editor/before_enqueue_scripts', [$this, 'enqueue_editor_scripts']); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Get promotion widgets data |
| 17 | */ |
| 18 | private function get_promotion_widgets_data() { |
| 19 | $widget_list = \ElementsKit_Lite\Config\Widget_List::instance()->get_list('all'); |
| 20 | $promotion_data = []; |
| 21 | |
| 22 | foreach ($widget_list as $slug => $widget) { |
| 23 | if (isset($widget['package']) && $widget['package'] === 'pro-disabled') { |
| 24 | $promotion_data[] = [ |
| 25 | 'name' => 'ekit-' . $slug, |
| 26 | 'title' => isset($widget['title']) ? $widget['title'] : ucwords(str_replace('-', ' ', $slug)), |
| 27 | 'icon' => isset($widget['icon']) ? $widget['icon'] : 'eicon-star', |
| 28 | 'categories' => ['elementskit'], |
| 29 | 'promotion' => [ |
| 30 | /* translators: %s: Widget name. */ |
| 31 | 'title' => sprintf(__('%s Widget', 'elementskit-lite'), isset($widget['title']) ? $widget['title'] : ucwords(str_replace('-', ' ', $slug))), |
| 32 | 'description' => sprintf( |
| 33 | /* translators: %s: Widget name. */ |
| 34 | __( 'Unlock the %s widget and dozens of powerful ElementsKit Pro features to design faster, smarter, and more flexible websites.', 'elementskit-lite'), |
| 35 | isset($widget['title']) ? $widget['title'] : ucwords(str_replace('-', ' ', $slug)) |
| 36 | ), |
| 37 | 'upgrade_url' => 'https://wpmet.com/plugin/elementskit/pricing/', |
| 38 | 'upgrade_text' => __('Upgrade Now', 'elementskit-lite'), |
| 39 | ], |
| 40 | ]; |
| 41 | } |
| 42 | } |
| 43 | return $promotion_data; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Enqueue editor scripts for promotion |
| 48 | */ |
| 49 | public function enqueue_editor_scripts() { |
| 50 | $promotion_widgets = $this->get_promotion_widgets_data(); |
| 51 | |
| 52 | wp_enqueue_script( |
| 53 | 'elementskit-editor-promotion', |
| 54 | \ElementsKit_Lite::widget_url() . 'init/assets/js/editor-promotion.js', |
| 55 | ['elementor-editor', 'elementor-common'], |
| 56 | \ElementsKit_Lite::version(), |
| 57 | true |
| 58 | ); |
| 59 | |
| 60 | wp_localize_script( |
| 61 | 'elementskit-editor-promotion', |
| 62 | 'ekitPromotion', |
| 63 | [ |
| 64 | 'promotionWidgets' => $promotion_widgets, |
| 65 | 'upgradeUrl' => 'https://wpmet.com/plugin/elementskit/pricing/', |
| 66 | 'debug' => true, |
| 67 | 'i18n' => [ |
| 68 | 'proFeature' => __('Pro Feature', 'elementskit-lite'), |
| 69 | 'upgradeNow' => __('Upgrade Now', 'elementskit-lite'), |
| 70 | 'learnMore' => __('Learn More', 'elementskit-lite'), |
| 71 | ], |
| 72 | ] |
| 73 | ); |
| 74 | |
| 75 | // Enqueue styles |
| 76 | wp_enqueue_style( |
| 77 | 'elementskit-editor-promotion', |
| 78 | \ElementsKit_Lite::widget_url() . 'init/assets/css/editor-promotion.css', |
| 79 | [], |
| 80 | \ElementsKit_Lite::version() |
| 81 | ); |
| 82 | } |
| 83 | } |
| 84 |