| @@ -1,81 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace AcyMailing\WpInit; | |
| 4 | - | |
| 5 | -defined('ABSPATH') || die('Restricted Access'); | |
| 6 | - | |
| 7 | -class Elementor | |
| 8 | -{ | |
| 9 | - public function __construct() | |
| 10 | - { | |
| 11 | - add_action('elementor/editor/before_enqueue_scripts', [$this, 'addAcyScriptElementor']); | |
| 12 | - add_action('elementor/widgets/register', [$this, 'registerWidgets']); | |
| 13 | - add_action('elementor/elements/categories_registered', [$this, 'addWidgetCategories']); | |
| 14 | - add_action('elementor_pro/init', [$this, 'addAcyFormAction']); | |
| 15 | - } | |
| 16 | - | |
| 17 | - public function addAcyScriptElementor() | |
| 18 | - { | |
| 19 | - wp_enqueue_script( | |
| 20 | - 'select2lib', | |
| 21 | - ACYM_JS.'libraries/select2-full.min.js?v='.filemtime(ACYM_MEDIA.'js'.DS.'libraries'.DS.'select2-full.min.js'), | |
| 22 | - ['jquery'], | |
| 23 | - '11.1.0', | |
| 24 | - [ | |
| 25 | - 'in_footer' => false, | |
| 26 | - ] | |
| 27 | - ); | |
| 28 | - wp_enqueue_script( | |
| 29 | - 'acym_script_widget_article_elementor', | |
| 30 | - ACYM_JS.'widget.min.js?v='.time(), | |
| 31 | - ['jquery', 'select2lib'], | |
| 32 | - '11.1.0', | |
| 33 | - [ | |
| 34 | - 'in_footer' => true, | |
| 35 | - ] | |
| 36 | - ); | |
| 37 | - // CSRF token for the article-search AJAX (dynamics/trigger requires acym_checkToken) | |
| 38 | - wp_add_inline_script( | |
| 39 | - 'acym_script_widget_article_elementor', | |
| 40 | - 'var acym_widget_nonce = '.json_encode(wp_create_nonce('acymnonce')).';', | |
| 41 | - 'before' | |
| 42 | - ); | |
| 43 | - wp_enqueue_script( | |
| 44 | - 'acymailing-compatibility-elementor', | |
| 45 | - ACYM_JS.'libraries/elementor.min.js', | |
| 46 | - [], | |
| 47 | - '11.1.0', | |
| 48 | - [ | |
| 49 | - 'in_footer' => true, | |
| 50 | - ] | |
| 51 | - ); | |
| 52 | - wp_enqueue_style( | |
| 53 | - 'acym_style_widget_article_elementor', | |
| 54 | - ACYM_CSS.'libraries/elementor.min.css?v='.time(), | |
| 55 | - [], | |
| 56 | - '11.1.0', | |
| 57 | - [ | |
| 58 | - 'in_footer' => true, | |
| 59 | - ] | |
| 60 | - ); | |
| 61 | - } | |
| 62 | - | |
| 63 | - public function registerWidgets() | |
| 64 | - { | |
| 65 | - include_once ACYM_WIDGETS.'subscriptionform'.DS.'elementor.php'; | |
| 66 | - \Elementor\Plugin::instance()->widgets_manager->register(new \acySubscriptionFormWidget()); | |
| 67 | - } | |
| 68 | - | |
| 69 | - public function addWidgetCategories($elements_manager) | |
| 70 | - { | |
| 71 | - $elements_manager->add_category('acymailing', [ | |
| 72 | - 'title' => 'AcyMailing', | |
| 73 | - ]); | |
| 74 | - } | |
| 75 | - | |
| 76 | - public function addAcyFormAction() | |
| 77 | - { | |
| 78 | - $acymailing = new ElementorForm(); | |
| 79 | - \ElementorPro\Plugin::instance()->modules_manager->get_modules('forms')->add_form_action($acymailing->get_name(), $acymailing); | |
| 80 | - } | |
| 81 | -} | |