| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
use Elementor\Controls_Manager; |
| 9 |
use Elementor\Group_Control_Background; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 12 |
use Elementor\Group_Control_Border as Group_Control_Border; |
| 13 |
use WPDeveloper\BetterDocs\Traits\SocialShare as SocialShareTrait; |
| 14 |
use Elementor\Group_Control_Box_Shadow as Group_Control_Box_Shadow; |
| 15 |
|
| 16 |
class DocShare extends BaseWidget { |
| 17 |
use SocialShareTrait; |
| 18 |
|
| 19 |
protected $map_view_vars = [ |
| 20 |
'share_title' => 'title' |
| 21 |
]; |
| 22 |
|
| 23 |
public function get_name() { |
| 24 |
return 'betterdocs-doc-share'; |
| 25 |
} |
| 26 |
|
| 27 |
public function get_title() { |
| 28 |
return __( 'Doc Share', 'betterdocs' ); |
| 29 |
} |
| 30 |
|
| 31 |
public function get_icon() { |
| 32 |
return 'betterdocs-icon-Social-Share'; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_categories() { |
| 36 |
return ['betterdocs-elements-single']; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_keywords() { |
| 40 |
return ['betterdocs-elements', 'share', 'betterdocs', 'heading', 'docs']; |
| 41 |
} |
| 42 |
|
| 43 |
public function get_style_depends() { |
| 44 |
return ['betterdocs-social-share']; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_custom_help_url() { |
| 48 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 49 |
} |
| 50 |
|
| 51 |
protected function register_controls() { |
| 52 |
$this->share_controls(); |
| 53 |
|
| 54 |
$this->start_controls_section( |
| 55 |
'section_column_settings', |
| 56 |
[ |
| 57 |
'label' => __( 'Box Style', 'betterdocs' ), |
| 58 |
'tab' => Controls_Manager::TAB_STYLE |
| 59 |
] |
| 60 |
); |
| 61 |
|
| 62 |
$this->add_control( |
| 63 |
'share_box_width', |
| 64 |
[ |
| 65 |
'label' => __( 'Width', 'betterdocs' ), |
| 66 |
'type' => Controls_Manager::SLIDER, |
| 67 |
'size_units' => ['px', '%', 'em'], |
| 68 |
'range' => [ |
| 69 |
'px' => [ |
| 70 |
'min' => 0, |
| 71 |
'max' => 2000, |
| 72 |
'step' => 1 |
| 73 |
], |
| 74 |
'%' => [ |
| 75 |
'min' => 0, |
| 76 |
'max' => 100, |
| 77 |
'step' => 1 |
| 78 |
], |
| 79 |
'em' => [ |
| 80 |
'min' => 100, |
| 81 |
'max' => 100, |
| 82 |
'step' => 1 |
| 83 |
] |
| 84 |
], |
| 85 |
'default' => [ |
| 86 |
'unit' => '%', |
| 87 |
'size' => 100 |
| 88 |
], |
| 89 |
'selectors' => [ |
| 90 |
'{{WRAPPER}} .betterdocs-social-share' => 'width: {{SIZE}}{{UNIT}};' |
| 91 |
] |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->add_control( |
| 96 |
'share_box_height', |
| 97 |
[ |
| 98 |
'label' => __( 'Height', 'betterdocs' ), |
| 99 |
'type' => Controls_Manager::SLIDER, |
| 100 |
'size_units' => ['px'], |
| 101 |
'range' => [ |
| 102 |
'px' => [ |
| 103 |
'max' => 500, |
| 104 |
'step' => 1 |
| 105 |
] |
| 106 |
], |
| 107 |
'selectors' => [ |
| 108 |
'{{WRAPPER}} .betterdocs-social-share' => 'height: {{SIZE}}px;' |
| 109 |
] |
| 110 |
] |
| 111 |
); |
| 112 |
|
| 113 |
$this->add_group_control( |
| 114 |
Group_Control_Background::get_type(), |
| 115 |
[ |
| 116 |
'name' => 'share_box_background', |
| 117 |
'types' => ['classic', 'gradient'], |
| 118 |
'selector' => '{{WRAPPER}} .betterdocs-social-share' |
| 119 |
] |
| 120 |
); |
| 121 |
|
| 122 |
$this->add_responsive_control( |
| 123 |
'share_box_space', // Legacy control id but new control |
| 124 |
[ |
| 125 |
'label' => __( 'Box Spacing', 'betterdocs' ), |
| 126 |
'type' => Controls_Manager::DIMENSIONS, |
| 127 |
'size_units' => ['px', '%', 'em'], |
| 128 |
'selectors' => [ |
| 129 |
'{{WRAPPER}} .betterdocs-social-share' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 130 |
] |
| 131 |
] |
| 132 |
); |
| 133 |
|
| 134 |
$this->add_responsive_control( |
| 135 |
'share_box_padding', |
| 136 |
[ |
| 137 |
'label' => __( 'Box Padding', 'betterdocs' ), |
| 138 |
'type' => Controls_Manager::DIMENSIONS, |
| 139 |
'size_units' => ['px', 'em', '%'], |
| 140 |
'selectors' => [ |
| 141 |
'{{WRAPPER}} .betterdocs-social-share' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 142 |
] |
| 143 |
] |
| 144 |
); |
| 145 |
|
| 146 |
$this->add_group_control( |
| 147 |
Group_Control_Border::get_type(), |
| 148 |
[ |
| 149 |
'name' => 'share_box_border_normal', |
| 150 |
'label' => esc_html__( 'Border', 'betterdocs' ), |
| 151 |
'selector' => '{{WRAPPER}} .betterdocs-social-share' |
| 152 |
] |
| 153 |
); |
| 154 |
|
| 155 |
$this->add_responsive_control( |
| 156 |
'share_box_radius_normal', |
| 157 |
[ |
| 158 |
'label' => esc_html__( 'Border Radius', 'betterdocs' ), |
| 159 |
'type' => Controls_Manager::DIMENSIONS, |
| 160 |
'size_units' => ['px', 'em', '%'], |
| 161 |
'selectors' => [ |
| 162 |
'{{WRAPPER}} .betterdocs-social-share' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 163 |
] |
| 164 |
] |
| 165 |
); |
| 166 |
|
| 167 |
$this->add_group_control( |
| 168 |
Group_Control_Box_Shadow::get_type(), |
| 169 |
[ |
| 170 |
'name' => 'share_box_shadow_normal', |
| 171 |
'selector' => '{{WRAPPER}} .betterdocs-social-share' |
| 172 |
] |
| 173 |
); |
| 174 |
|
| 175 |
$this->end_controls_section(); |
| 176 |
|
| 177 |
$this->start_controls_section( |
| 178 |
'section_title_settings', |
| 179 |
[ |
| 180 |
'label' => __( 'Title', 'betterdocs' ), |
| 181 |
'tab' => Controls_Manager::TAB_STYLE |
| 182 |
] |
| 183 |
); |
| 184 |
|
| 185 |
$this->add_control( |
| 186 |
'share_box_title_color', |
| 187 |
[ |
| 188 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 189 |
'type' => Controls_Manager::COLOR, |
| 190 |
'selectors' => [ |
| 191 |
'{{WRAPPER}} .betterdocs-social-share-heading h5' => 'color: {{VALUE}};' |
| 192 |
] |
| 193 |
] |
| 194 |
); |
| 195 |
|
| 196 |
$this->add_group_control( |
| 197 |
Group_Control_Typography::get_type(), |
| 198 |
[ |
| 199 |
'name' => 'share_box_title_typography', |
| 200 |
'selector' => '{{WRAPPER}} .betterdocs-social-share-heading h5' |
| 201 |
] |
| 202 |
); |
| 203 |
|
| 204 |
$this->end_controls_section(); |
| 205 |
|
| 206 |
$this->icon_style(); |
| 207 |
} |
| 208 |
|
| 209 |
public function share_controls() { |
| 210 |
$this->start_controls_section( |
| 211 |
'section_options', |
| 212 |
[ |
| 213 |
'label' => __( 'Controls', 'betterdocs' ) |
| 214 |
] |
| 215 |
); |
| 216 |
|
| 217 |
$this->add_control( |
| 218 |
'share_title', |
| 219 |
[ |
| 220 |
'label' => __( 'Title', 'betterdocs' ), |
| 221 |
'type' => Controls_Manager::TEXT, |
| 222 |
'default' => __( 'Share This Article :', 'betterdocs' ), |
| 223 |
'placeholder' => __( 'Type share title here', 'betterdocs' ) |
| 224 |
] |
| 225 |
); |
| 226 |
|
| 227 |
$this->add_control( |
| 228 |
'facebook', |
| 229 |
[ |
| 230 |
'label' => __( 'Facebook', 'betterdocs' ), |
| 231 |
'type' => Controls_Manager::SWITCHER, |
| 232 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 233 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 234 |
'return_value' => '1', |
| 235 |
'default' => '1' |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->add_control( |
| 240 |
'twitter', |
| 241 |
[ |
| 242 |
'label' => __( 'Twitter', 'betterdocs' ), |
| 243 |
'type' => Controls_Manager::SWITCHER, |
| 244 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 245 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 246 |
'return_value' => '1', |
| 247 |
'default' => '1' |
| 248 |
] |
| 249 |
); |
| 250 |
|
| 251 |
$this->add_control( |
| 252 |
'linkedin', |
| 253 |
[ |
| 254 |
'label' => __( 'Linkedin', 'betterdocs' ), |
| 255 |
'type' => Controls_Manager::SWITCHER, |
| 256 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 257 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 258 |
'return_value' => '1', |
| 259 |
'default' => '1' |
| 260 |
] |
| 261 |
); |
| 262 |
|
| 263 |
$this->add_control( |
| 264 |
'pinterest', |
| 265 |
[ |
| 266 |
'label' => __( 'Pinterest', 'betterdocs' ), |
| 267 |
'type' => Controls_Manager::SWITCHER, |
| 268 |
'label_on' => __( 'Show', 'betterdocs' ), |
| 269 |
'label_off' => __( 'Hide', 'betterdocs' ), |
| 270 |
'return_value' => '1', |
| 271 |
'default' => '1' |
| 272 |
] |
| 273 |
); |
| 274 |
|
| 275 |
$this->end_controls_section(); |
| 276 |
} |
| 277 |
|
| 278 |
public function icon_style() { |
| 279 |
$this->start_controls_section( |
| 280 |
'section_icon_settings', |
| 281 |
[ |
| 282 |
'label' => __( 'Icon', 'betterdocs' ), |
| 283 |
'tab' => Controls_Manager::TAB_STYLE |
| 284 |
] |
| 285 |
); |
| 286 |
|
| 287 |
$this->add_responsive_control( |
| 288 |
'share_icon_space', // Legacy control id but new control |
| 289 |
[ |
| 290 |
'label' => __( 'Spacing', 'betterdocs' ), |
| 291 |
'type' => Controls_Manager::DIMENSIONS, |
| 292 |
'size_units' => ['px', '%', 'em'], |
| 293 |
'selectors' => [ |
| 294 |
'{{WRAPPER}} .betterdocs-social-share-links li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 295 |
] |
| 296 |
] |
| 297 |
); |
| 298 |
|
| 299 |
$this->add_responsive_control( |
| 300 |
'share_icon_padding', |
| 301 |
[ |
| 302 |
'label' => __( 'Padding', 'betterdocs' ), |
| 303 |
'type' => Controls_Manager::DIMENSIONS, |
| 304 |
'size_units' => ['px', 'em', '%'], |
| 305 |
'selectors' => [ |
| 306 |
'{{WRAPPER}} .betterdocs-social-share-links li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 307 |
] |
| 308 |
] |
| 309 |
); |
| 310 |
|
| 311 |
$this->add_control( |
| 312 |
'share_share_icon_area', |
| 313 |
[ |
| 314 |
'label' => __( 'Size', 'betterdocs' ), |
| 315 |
'type' => Controls_Manager::SLIDER, |
| 316 |
'size_units' => ['px'], |
| 317 |
'range' => [ |
| 318 |
'px' => [ |
| 319 |
'max' => 500, |
| 320 |
'step' => 1 |
| 321 |
] |
| 322 |
], |
| 323 |
'selectors' => [ |
| 324 |
'{{WRAPPER}} .betterdocs-social-share-links li a img' => 'height: {{SIZE}}px;width: {{SIZE}}px;' |
| 325 |
] |
| 326 |
] |
| 327 |
); |
| 328 |
|
| 329 |
$this->end_controls_section(); |
| 330 |
} |
| 331 |
|
| 332 |
protected function render_callback() { |
| 333 |
$this->views( 'widgets/social' ); |
| 334 |
} |
| 335 |
} |
| 336 |
|