| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 4 |
|
| 5 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 6 |
|
| 7 |
use Elementor\Controls_Manager; |
| 8 |
use Elementor\Group_Control_Background; |
| 9 |
use Elementor\Group_Control_Typography; |
| 10 |
use Elementor\Group_Control_Border; |
| 11 |
|
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly |
| 15 |
} |
| 16 |
|
| 17 |
class DocAuthor extends BaseWidget { |
| 18 |
|
| 19 |
public function get_name() { |
| 20 |
return 'doc-author'; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_title() { |
| 24 |
return __( 'Doc Author', 'betterdocs' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_icon() { |
| 28 |
return 'betterdocs-icon-Doc-Author'; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_categories() { |
| 32 |
return [ 'betterdocs-elements-single' ]; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_keywords() { |
| 36 |
return [ 'betterdocs-elements', 'date', 'docs', 'betterdocs', 'author', 'doc-author' ]; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_style_depends() { |
| 40 |
return [ 'betterdocs-author' ]; |
| 41 |
} |
| 42 |
|
| 43 |
protected function register_controls() { |
| 44 |
$this->wrapper_box(); |
| 45 |
$this->author_styles(); |
| 46 |
$this->updated_time_styles(); |
| 47 |
} |
| 48 |
|
| 49 |
public function wrapper_box() { |
| 50 |
$this->start_controls_section( |
| 51 |
'author_updated_time_wrapper', |
| 52 |
[ |
| 53 |
'label' => __( 'Header Wrapper', 'betterdocs' ), |
| 54 |
'tab' => Controls_Manager::TAB_STYLE |
| 55 |
] |
| 56 |
); |
| 57 |
|
| 58 |
$this->add_group_control( |
| 59 |
Group_Control_Background::get_type(), |
| 60 |
[ |
| 61 |
'name' => 'author_updated_time_wrapper_background_color', |
| 62 |
'types' => [ 'classic', 'gradient' ], |
| 63 |
'label' => esc_html__( 'Background Color', 'betterdocs' ), |
| 64 |
'selector' => '{{WRAPPER}} .betterdocs-author-date' |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->add_group_control( |
| 69 |
Group_Control_Background::get_type(), |
| 70 |
[ |
| 71 |
'name' => 'author_updated_time_wrapper_background_hover_color', |
| 72 |
'types' => [ 'classic', 'gradient' ], |
| 73 |
'label' => esc_html__( 'Background Hover Color', 'betterdocs' ), |
| 74 |
'selector' => '{{WRAPPER}} .betterdocs-author-date:hover' |
| 75 |
] |
| 76 |
); |
| 77 |
|
| 78 |
$this->add_group_control( |
| 79 |
Group_Control_Border::get_type(), |
| 80 |
[ |
| 81 |
'name' => 'author_updated_time_wrapper_border', |
| 82 |
'label' => esc_html__( 'Border', 'betterdocs' ), |
| 83 |
'selector' => '{{WRAPPER}} .betterdocs-author-date' |
| 84 |
] |
| 85 |
); |
| 86 |
|
| 87 |
$this->add_responsive_control( |
| 88 |
'author_updated_time_wrapper_padding', |
| 89 |
[ |
| 90 |
'label' => __( 'Padding', 'betterdocs' ), |
| 91 |
'type' => Controls_Manager::DIMENSIONS, |
| 92 |
'size_units' => [ 'px', 'em', '%' ], |
| 93 |
'selectors' => [ |
| 94 |
'{{WRAPPER}} .betterdocs-author-date' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 95 |
] |
| 96 |
] |
| 97 |
); |
| 98 |
|
| 99 |
$this->add_responsive_control( |
| 100 |
'author_updated_time_wrapper_margin', |
| 101 |
[ |
| 102 |
'label' => __( 'Margin', 'betterdocs' ), |
| 103 |
'type' => Controls_Manager::DIMENSIONS, |
| 104 |
'size_units' => [ 'px', 'em', '%' ], |
| 105 |
'selectors' => [ |
| 106 |
'{{WRAPPER}} .betterdocs-author-date' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 107 |
] |
| 108 |
] |
| 109 |
); |
| 110 |
|
| 111 |
$this->end_controls_section(); |
| 112 |
} |
| 113 |
|
| 114 |
public function author_styles() { |
| 115 |
$this->start_controls_section( |
| 116 |
'author_updated_time_author_section', |
| 117 |
[ |
| 118 |
'label' => __( 'Author', 'betterdocs' ), |
| 119 |
'tab' => Controls_Manager::TAB_STYLE |
| 120 |
] |
| 121 |
); |
| 122 |
|
| 123 |
$this->add_group_control( |
| 124 |
Group_Control_Typography::get_type(), |
| 125 |
[ |
| 126 |
'name' => 'author_updated_time_author_typography', |
| 127 |
'selector' => '{{WRAPPER}} .betterdocs-author-date .betterdocs-author > span' |
| 128 |
] |
| 129 |
); |
| 130 |
|
| 131 |
$this->add_control( |
| 132 |
'author_updated_time_author_color', |
| 133 |
[ |
| 134 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 135 |
'type' => Controls_Manager::COLOR, |
| 136 |
'selectors' => [ |
| 137 |
'{{WRAPPER}} .betterdocs-author-date .betterdocs-author > span' => 'color: {{VALUE}};' |
| 138 |
] |
| 139 |
] |
| 140 |
); |
| 141 |
|
| 142 |
$this->add_control( |
| 143 |
'author_updated_time_author_icon_size', |
| 144 |
[ |
| 145 |
'label' => __( 'Author Icon Size', 'betterdocs' ), |
| 146 |
'type' => Controls_Manager::SLIDER, |
| 147 |
'size_units' => [ 'px', 'em' ], |
| 148 |
'range' => [ |
| 149 |
'px' => [ |
| 150 |
'min' => 0, |
| 151 |
'max' => 1000 |
| 152 |
] |
| 153 |
], |
| 154 |
'selectors' => [ |
| 155 |
'{{WRAPPER}} .betterdocs-author-date .betterdocs-author .author-avatar img' => 'height:{{SIZE}}{{UNIT}}; width:{{SIZE}}{{UNIT}};' |
| 156 |
] |
| 157 |
] |
| 158 |
); |
| 159 |
|
| 160 |
$this->end_controls_section(); |
| 161 |
} |
| 162 |
|
| 163 |
public function updated_time_styles() { |
| 164 |
$this->start_controls_section( |
| 165 |
'updated_time_section', |
| 166 |
[ |
| 167 |
'label' => __( 'Updated Time', 'betterdocs' ), |
| 168 |
'tab' => Controls_Manager::TAB_STYLE |
| 169 |
] |
| 170 |
); |
| 171 |
|
| 172 |
$this->add_group_control( |
| 173 |
Group_Control_Typography::get_type(), |
| 174 |
[ |
| 175 |
'name' => 'updated_time_typography', |
| 176 |
'selector' => '{{WRAPPER}} .betterdocs-author-date .update-date' |
| 177 |
] |
| 178 |
); |
| 179 |
|
| 180 |
$this->add_control( |
| 181 |
'updated_time_color', |
| 182 |
[ |
| 183 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 184 |
'type' => Controls_Manager::COLOR, |
| 185 |
'selectors' => [ |
| 186 |
'{{WRAPPER}} .betterdocs-author-date .update-date' => 'color: {{VALUE}};' |
| 187 |
] |
| 188 |
] |
| 189 |
); |
| 190 |
|
| 191 |
$this->end_controls_section(); |
| 192 |
} |
| 193 |
|
| 194 |
public function get_custom_help_url() { |
| 195 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
protected function render_callback() { |
| 200 |
$this->views( 'widgets/author' ); |
| 201 |
} |
| 202 |
} |
| 203 |
|