strong-testimonials
/
includes
/
elementor
/
class-strong-testimonials-elementor-widget-activation.php
class-strong-testimonials-elementor-check.php
1 year ago
class-strong-testimonials-elementor-widget-activation.php
1 year ago
class-strong-testimonials-elementor-widget.php
1 year ago
class-strong-testimonials-elementor-widget-activation.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ElementorStrongTestimonials; |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; |
| 6 | } // Exit if accessed directly |
| 7 | |
| 8 | class Strong_Testimonials_Elementor_Widget_Activation { |
| 9 | |
| 10 | private static $_instance = null; |
| 11 | |
| 12 | public static function instance() { |
| 13 | if ( is_null( self::$_instance ) ) { |
| 14 | self::$_instance = new self(); |
| 15 | } |
| 16 | |
| 17 | return self::$_instance; |
| 18 | } |
| 19 | |
| 20 | private function include_widgets_files() { |
| 21 | require_once WPMTST_INC . 'elementor/class-strong-testimonials-elementor-widget.php'; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Register Widgets |
| 26 | * |
| 27 | * Register new Elementor widgets. |
| 28 | * |
| 29 | * @since 1.2.0 |
| 30 | * @access public |
| 31 | */ |
| 32 | public function register_widgets() { |
| 33 | $this->include_widgets_files(); |
| 34 | // Register Widgets |
| 35 | if ( method_exists( \Elementor\Plugin::instance()->widgets_manager, 'register' ) ) { |
| 36 | \Elementor\Plugin::instance()->widgets_manager->register( new Widgets\Strong_Testimonials_Elementor_Widget() ); |
| 37 | } else { |
| 38 | \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\Strong_Testimonials_Elementor_Widget() ); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | public function __construct() { |
| 43 | |
| 44 | // Register widgets |
| 45 | if ( has_action( 'elementor/widgets/register' ) ) { |
| 46 | add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); |
| 47 | } else { |
| 48 | add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) ); |
| 49 | } |
| 50 | |
| 51 | // Enqueue needed scripts for elementor Editor |
| 52 | add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'strong_testimonials_elementor_enqueue_editor_scripts' ) ); |
| 53 | |
| 54 | // Enqueue needed scripts and styles in Elementor preview |
| 55 | add_action( 'elementor/preview/enqueue_scripts', array( $this, 'strong_testimonials_elementor_enqueue_scripts' ) ); |
| 56 | add_action( 'wp_ajax_strong_testimonials_elementor_ajax_search', array( $this, 'strong_testimonials_elementor_ajax_search' ) ); |
| 57 | } |
| 58 | |
| 59 | public function strong_testimonials_elementor_enqueue_editor_scripts() { |
| 60 | |
| 61 | wp_enqueue_script( 'strong-testimonials-elementor-editor', WPMTST_URL . 'admin/js/strong-testimonials-elementor-editor.js', null, WPMTST_VERSION, true ); |
| 62 | wp_localize_script( |
| 63 | 'strong-testimonials-elementor-editor', |
| 64 | 'strongAjax', |
| 65 | array( |
| 66 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 67 | ) |
| 68 | ); |
| 69 | |
| 70 | wp_enqueue_script( 'st-selectize', WPMTST_URL . 'admin/js/selectize.js', null, WPMTST_VERSION, true ); |
| 71 | wp_enqueue_style( 'st-selectize-css', WPMTST_URL . 'admin/css/selectize.default.css' ); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Enqueue scripts in Elementor preview |
| 76 | */ |
| 77 | public function strong_testimonials_elementor_enqueue_scripts() { |
| 78 | } |
| 79 | |
| 80 | public function strong_testimonials_elementor_ajax_search() { |
| 81 | |
| 82 | if ( isset( $_POST['action'] ) && 'strong_testimonials_elementor_ajax_search' === $_POST['action'] ) { |
| 83 | $galleries = wpmtst_unserialize_views( wpmtst_get_views() ); |
| 84 | |
| 85 | wp_send_json_success( $galleries ); |
| 86 | } else { |
| 87 | wp_send_json_error(); |
| 88 | } |
| 89 | die(); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Instantiate Plugin Class |
| 94 | Strong_Testimonials_Elementor_Widget_Activation::instance(); |
| 95 |