| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -namespace Easyel\EasyElements\Widgets; | |
| 3 | 2 | use Elementor\Controls_Manager; |
| 4 | 3 | use Elementor\Widget_Base; |
| 5 | 4 | use Elementor\Group_Control_Typography; |
| 6 | 5 | use Elementor\Group_Control_Background; |
| @@ -10,8 +9,33 @@ | ||
| 10 | 9 | } |
| 11 | 10 | |
| 12 | 11 | class Easyel_Offcanvas_Widget extends Widget_Base { |
| 13 | 12 | |
| 13 | + public function get_style_depends() { | |
| 14 | + $handle = 'eel-offcanvas-style'; | |
| 15 | + $css_path = plugin_dir_path( __FILE__ ) . 'css/offcanvas.css'; | |
| 16 | + | |
| 17 | + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) { | |
| 18 | + wp_register_style( | |
| 19 | + $handle, | |
| 20 | + plugins_url( 'css/offcanvas.css', __FILE__ ), | |
| 21 | + [], | |
| 22 | + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0' | |
| 23 | + ); | |
| 24 | + } | |
| 25 | + return [ $handle ]; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public function get_script_depends() { | |
| 29 | + $handle = 'eel-offcanvas-script'; | |
| 30 | + $js_path = plugin_dir_path( __FILE__ ) . 'js/offcanvas.js'; | |
| 31 | + | |
| 32 | + if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) { | |
| 33 | + wp_register_script( $handle, plugins_url( 'js/offcanvas.js', __FILE__ ), [ 'jquery' ], filemtime( $js_path ), true ); | |
| 34 | + } | |
| 35 | + | |
| 36 | + return [ $handle ]; | |
| 37 | + } | |
| 14 | 38 | public function get_name() { |
| 15 | 39 | return 'eel-offcanvas'; |
| 16 | 40 | } |
| 17 | 41 | |
| @@ -29,21 +53,8 @@ | ||
| 29 | 53 | |
| 30 | 54 | public function get_keywords() { |
| 31 | 55 | return [ 'offcanvas', 'text', 'link', 'image' ]; |
| 32 | 56 | } |
| 33 | - | |
| 34 | - public function get_style_depends() { | |
| 35 | - return [ | |
| 36 | - 'eel-offcanvas', | |
| 37 | - ]; | |
| 38 | - } | |
| 39 | - | |
| 40 | - public function get_script_depends() { | |
| 41 | - return [ | |
| 42 | - 'eel-offcanvas', | |
| 43 | - ]; | |
| 44 | - } | |
| 45 | - | |
| 46 | 57 | protected function register_controls() { |
| 47 | 58 | $this->start_controls_section( |
| 48 | 59 | 'section_offcanvas', |
| 49 | 60 | [ |
| @@ -450,5 +461,6 @@ | ||
| 450 | 461 | ?> |
| 451 | 462 | </div> |
| 452 | 463 | <?php |
| 453 | 464 | } |
| 454 | -} | |
| 465 | +} | |
| 466 | +?> | |