| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -namespace Easyel\EasyElements\Widgets; | |
| 3 | 2 | use Elementor\Controls_Manager; |
| 4 | 3 | use Elementor\Group_Control_Typography; |
| 5 | 4 | use Elementor\Group_Control_Text_Stroke; |
| 6 | 5 | |
| @@ -7,9 +6,34 @@ | ||
| 7 | 6 | defined('ABSPATH') || die(); |
| 8 | 7 | |
| 9 | 8 | class Easyel_Counter_Widget extends \Elementor\Widget_Base { |
| 10 | 9 | |
| 10 | + public function get_style_depends() { | |
| 11 | + $handles = []; | |
| 12 | + // Counter CSS | |
| 13 | + $counter_handle = 'eel-counter-style'; | |
| 14 | + $counter_css_path = plugin_dir_path( __FILE__ ) . 'css/counter.css'; | |
| 15 | + if ( file_exists( $counter_css_path ) && ! wp_style_is( $counter_handle, 'registered' ) ) { | |
| 16 | + wp_register_style( | |
| 17 | + $counter_handle, | |
| 18 | + plugins_url( 'css/counter.css', __FILE__ ), | |
| 19 | + [], | |
| 20 | + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $counter_css_path ) : EASYELEMENTS_VER | |
| 21 | + ); | |
| 22 | + $handles[] = $counter_handle; | |
| 23 | + } | |
| 24 | + return $handles; | |
| 25 | + } | |
| 11 | 26 | |
| 27 | + public function get_script_depends() { | |
| 28 | + $handle = 'eel-cnt-script'; | |
| 29 | + $js_path = plugin_dir_path( __FILE__ ) . 'js/counter.js'; | |
| 30 | + if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) { | |
| 31 | + wp_register_script( $handle, plugins_url( 'js/counter.js', __FILE__ ), [ 'jquery' ], filemtime( $js_path ), true ); | |
| 32 | + } | |
| 33 | + return [ $handle ]; | |
| 34 | + } | |
| 35 | + | |
| 12 | 36 | public function get_name() { |
| 13 | 37 | return 'eel-counter'; |
| 14 | 38 | } |
| 15 | 39 | |
| @@ -17,9 +41,9 @@ | ||
| 17 | 41 | return __( 'Counter', 'easy-elements' ); |
| 18 | 42 | } |
| 19 | 43 | |
| 20 | 44 | public function get_icon() { |
| 21 | - return 'easyicon easyelIcon-counter'; | |
| 45 | + return 'easyicon eicon-counter'; | |
| 22 | 46 | } |
| 23 | 47 | |
| 24 | 48 | public function get_categories() { |
| 25 | 49 | return [ 'easyelements_category' ]; |
| @@ -25,23 +49,11 @@ | ||
| 25 | 49 | return [ 'easyelements_category' ]; |
| 26 | 50 | } |
| 27 | 51 | |
| 28 | 52 | public function get_keywords() { |
| 29 | - return [ 'counter', 'funfact', 'counterup', 'count', 'text' ]; | |
| 53 | + return [ 'counter', 'funfact', 'Countdown' ]; | |
| 30 | 54 | } |
| 31 | 55 | |
| 32 | - public function get_style_depends() { | |
| 33 | - return [ | |
| 34 | - 'eel-counter', | |
| 35 | - ]; | |
| 36 | - } | |
| 37 | - | |
| 38 | - public function get_script_depends() { | |
| 39 | - return [ | |
| 40 | - 'eel-counter', | |
| 41 | - ]; | |
| 42 | - } | |
| 43 | - | |
| 44 | 56 | protected function register_controls() |
| 45 | 57 | { |
| 46 | 58 | $this->start_controls_section( |
| 47 | 59 | 'section_counter', |
| @@ -417,9 +429,8 @@ | ||
| 417 | 429 | 'cnt-icon-enable' => 'yes', |
| 418 | 430 | ] |
| 419 | 431 | ] |
| 420 | 432 | ); |
| 421 | - | |
| 422 | 433 | $this->end_controls_section(); |
| 423 | 434 | |
| 424 | 435 | $this->start_controls_section( |
| 425 | 436 | 'section_number', |
| @@ -455,9 +466,9 @@ | ||
| 455 | 466 | $this->add_group_control( |
| 456 | 467 | \Elementor\Group_Control_Text_Stroke::get_type(), |
| 457 | 468 | [ |
| 458 | 469 | 'name' => 'number_stroke', |
| 459 | - 'selector' => '{{WRAPPER}} .eel-cnt-number-wrap', | |
| 470 | + 'selector' => '{{WRAPPER}} .eel-cnt-number', | |
| 460 | 471 | ] |
| 461 | 472 | ); |
| 462 | 473 | |
| 463 | 474 | $this->add_group_control( |
| @@ -464,9 +475,9 @@ | ||
| 464 | 475 | \Elementor\Group_Control_Text_Shadow::get_type(), |
| 465 | 476 | [ |
| 466 | 477 | 'name' => 'number_text_shadow', |
| 467 | 478 | 'label' => esc_html__('Text Shadow', 'easy-elements'), |
| 468 | - 'selector' => '{{WRAPPER}} .eel-cnt-number-wrap', | |
| 479 | + 'selector' => '{{WRAPPER}} .eel-cnt-number', | |
| 469 | 480 | ] |
| 470 | 481 | ); |
| 471 | 482 | $this->end_controls_section(); |
| 472 | 483 | |