Embedpress_Elementor_Integration.php
56 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress\Elementor; |
| 4 | |
| 5 | |
| 6 | (defined( 'ABSPATH' )) or die( "No direct script access allowed." ); |
| 7 | |
| 8 | class Embedpress_Elementor_Integration { |
| 9 | |
| 10 | /** |
| 11 | * @since 2.4.2 |
| 12 | */ |
| 13 | public function init() { |
| 14 | add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'embedpress_enqueue_style' ] ); |
| 15 | add_action( 'elementor/elements/categories_registered', array( $this, 'register_widget_categories' ) ); |
| 16 | add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widget' ) ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Add elementor category |
| 21 | * |
| 22 | * @since 2.4.3 |
| 23 | */ |
| 24 | public function register_widget_categories( $elements_manager ) { |
| 25 | $elements_manager->add_category( |
| 26 | 'embedpress', |
| 27 | [ |
| 28 | 'title' => __( 'EmbedPress', 'embedpress' ), |
| 29 | 'icon' => 'font', |
| 30 | ], 1 ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Load elementor widget |
| 35 | * |
| 36 | * @since 2.4.2 |
| 37 | */ |
| 38 | public function register_widget( $widgets_manager ) { |
| 39 | $widgets_manager->register_widget_type( new \EmbedPress\Elementor\Widgets\Embedpress_Elementor ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Enqueue elementor assets |
| 44 | * @since 2.4.3 |
| 45 | */ |
| 46 | public function embedpress_enqueue_style(){ |
| 47 | wp_enqueue_style( |
| 48 | 'embedpress-elementor-css', |
| 49 | EMBEDPRESS_URL_ASSETS . 'css/embedpress-elementor.css', |
| 50 | false, |
| 51 | EMBEDPRESS_VERSION |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | } |
| 56 |