| @@ -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 | |
| 6 | 5 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -8,9 +7,39 @@ | ||
| 8 | 7 | } |
| 9 | 8 | |
| 10 | 9 | class Easyel_Scroll_To_Top_Widget extends \Elementor\Widget_Base { |
| 11 | 10 | |
| 11 | + public function get_style_depends() { | |
| 12 | + $handle = 'eel-scroll-style'; | |
| 13 | + $css_path = plugin_dir_path( __FILE__ ) . 'css/scroll.css'; | |
| 12 | 14 | |
| 15 | + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) { | |
| 16 | + wp_register_style( | |
| 17 | + $handle, | |
| 18 | + plugins_url( 'css/scroll.css', __FILE__ ), | |
| 19 | + [], | |
| 20 | + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0' | |
| 21 | + ); | |
| 22 | + } | |
| 23 | + return [ $handle ]; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function get_script_depends() { | |
| 27 | + $handle = 'eel-scroll-script'; | |
| 28 | + $js_path = plugin_dir_path( __FILE__ ) . 'js/scroll.js'; | |
| 29 | + | |
| 30 | + if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) { | |
| 31 | + wp_register_script( | |
| 32 | + $handle, | |
| 33 | + plugins_url( 'js/scroll.js', __FILE__ ), | |
| 34 | + [ 'jquery' ], | |
| 35 | + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $js_path ) : '1.0.0', | |
| 36 | + true | |
| 37 | + ); | |
| 38 | + } | |
| 39 | + return [ $handle ]; | |
| 40 | + } | |
| 41 | + | |
| 13 | 42 | public function get_name() { |
| 14 | 43 | return 'eel-scroll-to-top'; |
| 15 | 44 | } |
| 16 | 45 | |
| @@ -29,20 +58,8 @@ | ||
| 29 | 58 | public function get_keywords() { |
| 30 | 59 | return [ 'scroll', 'top', 'back', 'to', 'text' ]; |
| 31 | 60 | } |
| 32 | 61 | |
| 33 | - public function get_style_depends() { | |
| 34 | - return [ | |
| 35 | - 'eel-scroll-to-top', | |
| 36 | - ]; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function get_script_depends() { | |
| 40 | - return [ | |
| 41 | - 'eel-scroll-to-top', | |
| 42 | - ]; | |
| 43 | - } | |
| 44 | - | |
| 45 | 62 | protected function register_controls() { |
| 46 | 63 | // Example: Style section for button |
| 47 | 64 | $this->start_controls_section( |
| 48 | 65 | 'section_scroll_setting', |
| @@ -113,5 +130,6 @@ | ||
| 113 | 130 | ?> |
| 114 | 131 | </div> |
| 115 | 132 | <?php |
| 116 | 133 | } |
| 117 | -} | |
| 134 | +} | |
| 135 | +?> | |