| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 12 |
|
| 13 |
class ReadingTime extends BaseWidget { |
| 14 |
|
| 15 |
public function get_name() { |
| 16 |
return 'betterdocs-reading-time'; |
| 17 |
} |
| 18 |
|
| 19 |
public function get_style_depends() { |
| 20 |
return ['reading-time']; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_title() { |
| 24 |
return __( 'Reading Time', 'betterdocs' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_icon() { |
| 28 |
return 'eicon-post-list betterdocs-eicon-post-list'; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_categories() { |
| 32 |
return ['betterdocs-elements', 'single-doc']; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_keywords() { |
| 36 |
return ['betterdocs-elements', 'betterdocs', 'docs', 'single-doc']; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_custom_help_url() { |
| 40 |
return 'https://betterdocs.co/docs/docs-archive-in-elementor/'; |
| 41 |
} |
| 42 |
|
| 43 |
protected function register_controls() { |
| 44 |
|
| 45 |
$this->start_controls_section( |
| 46 |
'section_reading_style', |
| 47 |
[ |
| 48 |
'label' => __( 'Style', 'betterdocs' ), |
| 49 |
'tab' => Controls_Manager::TAB_STYLE |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
$this->add_responsive_control( |
| 54 |
'reading_background_color', |
| 55 |
[ |
| 56 |
'label' => esc_html__( 'Background Color', 'betterdocs' ), |
| 57 |
'type' => Controls_Manager::COLOR, |
| 58 |
'selectors' => [ |
| 59 |
'{{WRAPPER}} .reading-time' => 'background-color: {{VALUE}};' |
| 60 |
] |
| 61 |
] |
| 62 |
); |
| 63 |
|
| 64 |
$this->add_control( |
| 65 |
'reading_text_color', |
| 66 |
[ |
| 67 |
'label' => __( 'Text Color', 'plugin-domain' ), |
| 68 |
'type' => Controls_Manager::COLOR, |
| 69 |
'selectors' => [ |
| 70 |
'{{WRAPPER}} .reading-time p' => 'color: {{VALUE}}' |
| 71 |
] |
| 72 |
] |
| 73 |
); |
| 74 |
|
| 75 |
$this->add_group_control( |
| 76 |
Group_Control_Typography::get_type(), |
| 77 |
[ |
| 78 |
'name' => 'reading_text_typo', |
| 79 |
'selector' => '{{WRAPPER}} .reading-time p' |
| 80 |
] |
| 81 |
); |
| 82 |
|
| 83 |
$this->add_control( |
| 84 |
'reading_box_width', |
| 85 |
[ |
| 86 |
'label' => __( 'Width', 'betterdocs' ), |
| 87 |
'type' => Controls_Manager::SLIDER, |
| 88 |
'size_units' => ['px', '%'], |
| 89 |
'range' => [ |
| 90 |
'px' => [ |
| 91 |
'max' => 500, |
| 92 |
'step' => 1 |
| 93 |
], |
| 94 |
'%' => [ |
| 95 |
'max' => 100, |
| 96 |
'step' => 1 |
| 97 |
] |
| 98 |
], |
| 99 |
'selectors' => [ |
| 100 |
'{{WRAPPER}} .reading-time' => 'width: {{SIZE}}px;' |
| 101 |
] |
| 102 |
] |
| 103 |
); |
| 104 |
|
| 105 |
$this->add_responsive_control( |
| 106 |
'reading_padding', |
| 107 |
[ |
| 108 |
'label' => __( 'Padding', 'betterdocs' ), |
| 109 |
'type' => Controls_Manager::DIMENSIONS, |
| 110 |
'size_units' => ['px', 'em', '%'], |
| 111 |
'selectors' => [ |
| 112 |
'{{WRAPPER}} .reading-time' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 113 |
] |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->add_responsive_control( |
| 118 |
'reading_margin', |
| 119 |
[ |
| 120 |
'label' => __( 'Margin', 'betterdocs' ), |
| 121 |
'type' => Controls_Manager::DIMENSIONS, |
| 122 |
'size_units' => ['px', 'em', '%'], |
| 123 |
'selectors' => [ |
| 124 |
'{{WRAPPER}} .reading-time' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 125 |
] |
| 126 |
] |
| 127 |
); |
| 128 |
|
| 129 |
$this->end_controls_section(); |
| 130 |
} |
| 131 |
|
| 132 |
protected function render_callback() { |
| 133 |
$this->views( 'widgets/reading-time' ); |
| 134 |
} |
| 135 |
} |
| 136 |
|