| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Addons; |
| 4 |
|
| 5 |
// Elementor Classes |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Group_Control_Typography; |
| 8 |
use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 |
use Elementor\Group_Control_Border; |
| 10 |
use Elementor\Group_Control_Background; |
| 11 |
|
| 12 |
use MasterAddons\Inc\Classes\Helper; |
| 13 |
use MasterAddons\Inc\Admin\Config; |
| 14 |
use MasterAddons\Inc\Classes\Base\Master_Widget; |
| 15 |
|
| 16 |
class Blockquote extends Master_Widget |
| 17 |
{ |
| 18 |
use \MasterAddons\Inc\Traits\Widget_Notice; |
| 19 |
use \MasterAddons\Inc\Traits\Widget_Assets_Trait; |
| 20 |
|
| 21 |
public function get_name() |
| 22 |
{ |
| 23 |
return "jltma-blockquote"; |
| 24 |
} |
| 25 |
public function get_title() |
| 26 |
{ |
| 27 |
return esc_html__('Blockquote', 'master-addons' ); |
| 28 |
} |
| 29 |
|
| 30 |
public function get_icon() |
| 31 |
{ |
| 32 |
return 'jltma-icon ' . Config::get_addon_icon($this->get_name()); |
| 33 |
} |
| 34 |
|
| 35 |
public function get_keywords() |
| 36 |
{ |
| 37 |
return ['blockquote', 'quotation', 'author said']; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
//Quote Blockquote |
| 42 |
protected function jltma_blockquote_content_section() |
| 43 |
{ |
| 44 |
$this->start_controls_section( |
| 45 |
'jltma_blockquote_display', |
| 46 |
[ |
| 47 |
'label' => esc_html__('Blockquote', 'master-addons' ), |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'jltma_blockquote_text', |
| 53 |
[ |
| 54 |
'label' => esc_html__('Content', 'master-addons' ), |
| 55 |
'type' => Controls_Manager::TEXTAREA, |
| 56 |
'label_block' => true, |
| 57 |
'default' => esc_html__('Architecture should speak of its time and place, but yearn for timelessness', 'master-addons' ), |
| 58 |
] |
| 59 |
); |
| 60 |
|
| 61 |
$this->add_control( |
| 62 |
'quote_author_show', |
| 63 |
[ |
| 64 |
'label' => __('Show Author', 'master-addons' ), |
| 65 |
'type' => Controls_Manager::SWITCHER, |
| 66 |
'label_on' => __('On', 'master-addons' ), |
| 67 |
'label_off' => __('Off', 'master-addons' ), |
| 68 |
'default' => 'yes' |
| 69 |
] |
| 70 |
); |
| 71 |
|
| 72 |
$this->add_control( |
| 73 |
'jltma_blockquote_author', |
| 74 |
[ |
| 75 |
'label' => esc_html__('Quote Author', 'master-addons' ), |
| 76 |
'type' => Controls_Manager::TEXT, |
| 77 |
'label_block' => true, |
| 78 |
'default' => esc_html__('Scott Adams', 'master-addons' ), |
| 79 |
'condition' => [ |
| 80 |
'quote_author_show' => 'yes' |
| 81 |
] |
| 82 |
] |
| 83 |
); |
| 84 |
|
| 85 |
$this->end_controls_section(); |
| 86 |
} |
| 87 |
|
| 88 |
protected function jltma_quote_text_section() |
| 89 |
{ |
| 90 |
|
| 91 |
$this->start_controls_section( |
| 92 |
'text_style_section', |
| 93 |
[ |
| 94 |
'label' => __('Content', 'master-addons' ), |
| 95 |
'tab' => Controls_Manager::TAB_STYLE |
| 96 |
] |
| 97 |
); |
| 98 |
|
| 99 |
$this->add_group_control( |
| 100 |
Group_Control_Background::get_type(), |
| 101 |
[ |
| 102 |
'name' => 'quote_background', |
| 103 |
'label' => __('Background', 'master-addons' ), |
| 104 |
'types' => ['classic', 'gradient'], |
| 105 |
'selector' => '{{WRAPPER}} .jltma-blockquote', |
| 106 |
'default' => '#404ace' |
| 107 |
] |
| 108 |
); |
| 109 |
|
| 110 |
$this->add_responsive_control( |
| 111 |
'text_align', |
| 112 |
[ |
| 113 |
'label' => __('Content Alignment', 'master-addons' ), |
| 114 |
'type' => Controls_Manager::CHOOSE, |
| 115 |
'default' => 'left', |
| 116 |
'options' => [ |
| 117 |
'left' => [ |
| 118 |
'title' => __('Left', 'master-addons'), |
| 119 |
'icon' => 'eicon-text-align-left', |
| 120 |
], |
| 121 |
'center' => [ |
| 122 |
'title' => __('Center', 'master-addons'), |
| 123 |
'icon' => 'eicon-text-align-center', |
| 124 |
], |
| 125 |
'right' => [ |
| 126 |
'title' => __('Right', 'master-addons'), |
| 127 |
'icon' => 'eicon-text-align-right', |
| 128 |
], |
| 129 |
], |
| 130 |
'selectors' => [ |
| 131 |
'{{WRAPPER}} .jltma-blockquote' => 'text-align: {{VALUE}};', |
| 132 |
'{{WRAPPER}} .jltma-blockquote cite' => 'justify-content: {{VALUE}};' |
| 133 |
] |
| 134 |
] |
| 135 |
); |
| 136 |
|
| 137 |
$this->add_control( |
| 138 |
'text_color', |
| 139 |
[ |
| 140 |
'label' => __('Quote Text Color', 'master-addons' ), |
| 141 |
'type' => Controls_Manager::COLOR, |
| 142 |
'selectors' => [ |
| 143 |
'{{WRAPPER}} .jltma-blockquote p' => 'color: {{VALUE}};' |
| 144 |
] |
| 145 |
] |
| 146 |
); |
| 147 |
|
| 148 |
$this->add_group_control( |
| 149 |
Group_Control_Typography::get_type(), |
| 150 |
[ |
| 151 |
'name' => 'text_typography', |
| 152 |
'global' => [ |
| 153 |
'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 154 |
], |
| 155 |
'selector' => '{{WRAPPER}} .jltma-blockquote p' |
| 156 |
] |
| 157 |
); |
| 158 |
|
| 159 |
$this->add_group_control( |
| 160 |
Group_Control_Border::get_type(), |
| 161 |
[ |
| 162 |
'name' => 'block_border', |
| 163 |
'selector' => '{{WRAPPER}} .jltma-blockquote', |
| 164 |
'separator' => 'before' |
| 165 |
] |
| 166 |
); |
| 167 |
|
| 168 |
$this->add_control( |
| 169 |
'width', |
| 170 |
[ |
| 171 |
'label' => esc_html__( 'Border Radius', 'master-addons' ), |
| 172 |
'type' => Controls_Manager::SLIDER, |
| 173 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 174 |
'range' => [ |
| 175 |
'px' => [ |
| 176 |
'min' => 0, |
| 177 |
'max' => 1000, |
| 178 |
'step' => 5, |
| 179 |
], |
| 180 |
'%' => [ |
| 181 |
'min' => 0, |
| 182 |
'max' => 100, |
| 183 |
], |
| 184 |
], |
| 185 |
'default' => [ |
| 186 |
'unit' => 'px', |
| 187 |
'size' => '20', |
| 188 |
], |
| 189 |
'selectors' => [ |
| 190 |
'{{WRAPPER}} .jltma-blockquote ' => 'border-radius: {{SIZE}}{{UNIT}};', |
| 191 |
], |
| 192 |
] |
| 193 |
); |
| 194 |
|
| 195 |
$this->add_responsive_control( |
| 196 |
'jltma_blockquote_padding', |
| 197 |
[ |
| 198 |
'label' => esc_html__('Padding', 'master-addons' ), |
| 199 |
'type' => Controls_Manager::DIMENSIONS, |
| 200 |
'size_units' => ['px', 'em', '%'], |
| 201 |
'selectors' => [ |
| 202 |
'{{WRAPPER}} .jltma-blockquote' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 203 |
] |
| 204 |
] |
| 205 |
); |
| 206 |
|
| 207 |
$this->add_control( |
| 208 |
'jltma_quote_author_styles', |
| 209 |
[ |
| 210 |
'label' => __('Authors', 'master-addons' ), |
| 211 |
'type' => Controls_Manager::HEADING, |
| 212 |
] |
| 213 |
); |
| 214 |
|
| 215 |
$this->add_control( |
| 216 |
'author_text_color', |
| 217 |
[ |
| 218 |
'label' => __('Author Text Color', 'master-addons' ), |
| 219 |
'type' => Controls_Manager::COLOR, |
| 220 |
'selectors' => [ |
| 221 |
'{{WRAPPER}} .jltma-blockquote cite' => 'color: {{VALUE}};' |
| 222 |
], |
| 223 |
'condition' => [ |
| 224 |
'quote_author_show' => 'yes' |
| 225 |
] |
| 226 |
] |
| 227 |
); |
| 228 |
|
| 229 |
$this->add_group_control( |
| 230 |
Group_Control_Typography::get_type(), |
| 231 |
[ |
| 232 |
'name' => 'author_typography', |
| 233 |
'global' => [ |
| 234 |
'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 235 |
], |
| 236 |
'selector' => '{{WRAPPER}} .jltma-blockquote cite', |
| 237 |
'condition' => [ |
| 238 |
'quote_author_show' => 'yes' |
| 239 |
] |
| 240 |
] |
| 241 |
); |
| 242 |
|
| 243 |
$this->end_controls_section(); |
| 244 |
} |
| 245 |
|
| 246 |
/*-------------- Quote Symbol Section ---------------*/ |
| 247 |
protected function jltma_quote_symbol_section() |
| 248 |
{ |
| 249 |
|
| 250 |
$this->start_controls_section( |
| 251 |
'quote_symbol_style_section', |
| 252 |
[ |
| 253 |
'label' => __('Quote Symbol', 'master-addons' ), |
| 254 |
'tab' => Controls_Manager::TAB_STYLE |
| 255 |
] |
| 256 |
); |
| 257 |
|
| 258 |
$this->add_control( |
| 259 |
'quote_symbol_color', |
| 260 |
[ |
| 261 |
'label' => __('Author Symbol Color', 'master-addons' ), |
| 262 |
'type' => Controls_Manager::COLOR, |
| 263 |
'selectors' => [ |
| 264 |
'{{WRAPPER}} .jltma-blockquote .jltma-quote-symbol' => 'background: {{VALUE}};' |
| 265 |
], |
| 266 |
'condition' => [ |
| 267 |
'quote_symbol_author' => 'yes' |
| 268 |
] |
| 269 |
] |
| 270 |
); |
| 271 |
|
| 272 |
$this->add_responsive_control( |
| 273 |
'quote_symbol_width', |
| 274 |
[ |
| 275 |
'label' => __('Width', 'master-addons' ), |
| 276 |
'type' => Controls_Manager::SLIDER, |
| 277 |
'size_units' => ['px'], |
| 278 |
'range' => [ |
| 279 |
'px' => [ |
| 280 |
'min' => 5, |
| 281 |
'max' => 50, |
| 282 |
], |
| 283 |
], |
| 284 |
'selectors' => [ |
| 285 |
'{{WRAPPER}} .jltma-blockquote .jltma-quote-symbol' => 'width: {{SIZE}}{{UNIT}};', |
| 286 |
], |
| 287 |
'condition' => [ |
| 288 |
'quote_symbol_author' => 'yes' |
| 289 |
] |
| 290 |
] |
| 291 |
); |
| 292 |
|
| 293 |
$this->add_responsive_control( |
| 294 |
'quote_symbol_height', |
| 295 |
[ |
| 296 |
'label' => __('Height', 'master-addons' ), |
| 297 |
'type' => Controls_Manager::SLIDER, |
| 298 |
'size_units' => ['px'], |
| 299 |
'range' => [ |
| 300 |
'px' => [ |
| 301 |
'min' => 2, |
| 302 |
'max' => 20, |
| 303 |
], |
| 304 |
], |
| 305 |
'default' => [ |
| 306 |
'unit' => 'px', |
| 307 |
'size' => 5, |
| 308 |
], |
| 309 |
'selectors' => [ |
| 310 |
'{{WRAPPER}} .jltma-blockquote .jltma-quote-symbol' => 'height: {{SIZE}}{{UNIT}};', |
| 311 |
], |
| 312 |
'condition' => [ |
| 313 |
'quote_symbol_author' => 'yes' |
| 314 |
] |
| 315 |
] |
| 316 |
); |
| 317 |
|
| 318 |
$this->add_responsive_control( |
| 319 |
'quote_symbol_margin', |
| 320 |
[ |
| 321 |
'label' => __('Margin', 'master-addons' ), |
| 322 |
'type' => Controls_Manager::DIMENSIONS, |
| 323 |
'size_units' => ['px', 'em', '%'], |
| 324 |
'selectors' => [ |
| 325 |
'{{WRAPPER}} .jltma-blockquote .jltma-quote-symbol' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 326 |
], |
| 327 |
'condition' => [ |
| 328 |
'quote_symbol_author' => 'yes' |
| 329 |
] |
| 330 |
] |
| 331 |
); |
| 332 |
|
| 333 |
$this->end_controls_section(); |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
protected function jltma_blockquote_symbols(){ |
| 338 |
|
| 339 |
$this->start_controls_section( |
| 340 |
'jltma_blockquote_symbols', |
| 341 |
[ |
| 342 |
'label' => esc_html__('Quote Symbols', 'master-addons' ), |
| 343 |
] |
| 344 |
); |
| 345 |
|
| 346 |
$this->add_control( |
| 347 |
'quote_symbol', |
| 348 |
[ |
| 349 |
'label' => __('Show Start Symbol', 'master-addons' ), |
| 350 |
'type' => Controls_Manager::SWITCHER, |
| 351 |
'label_on' => __('On', 'master-addons' ), |
| 352 |
'label_off' => __('Off', 'master-addons' ), |
| 353 |
'default' => 'yes' |
| 354 |
] |
| 355 |
); |
| 356 |
|
| 357 |
$this->add_control( |
| 358 |
'quote_symbol_end', |
| 359 |
[ |
| 360 |
'label' => __('Show End Symbol', 'master-addons' ), |
| 361 |
'type' => Controls_Manager::SWITCHER, |
| 362 |
'label_on' => __('On', 'master-addons' ), |
| 363 |
'label_off' => __('Off', 'master-addons' ), |
| 364 |
'default' => 'yes' |
| 365 |
] |
| 366 |
); |
| 367 |
|
| 368 |
$this->add_control( |
| 369 |
'quote_symbol_author', |
| 370 |
[ |
| 371 |
'label' => __('Show Author Symbol', 'master-addons' ), |
| 372 |
'type' => Controls_Manager::SWITCHER, |
| 373 |
'label_on' => __('On', 'master-addons' ), |
| 374 |
'label_off' => __('Off', 'master-addons' ), |
| 375 |
'default' => 'yes' |
| 376 |
] |
| 377 |
); |
| 378 |
|
| 379 |
$this->end_controls_section(); |
| 380 |
} |
| 381 |
|
| 382 |
protected function register_controls() |
| 383 |
{ |
| 384 |
|
| 385 |
$this->jltma_blockquote_content_section(); |
| 386 |
$this->jltma_blockquote_symbols(); |
| 387 |
$this->jltma_quote_text_section(); |
| 388 |
$this->jltma_quote_symbol_section(); |
| 389 |
|
| 390 |
// Help Docs section (links from config.php) |
| 391 |
$this->jltma_help_docs(); |
| 392 |
|
| 393 |
$this->upgrade_to_pro_message(); |
| 394 |
} |
| 395 |
|
| 396 |
protected function render() |
| 397 |
{ |
| 398 |
$settings = $this->get_settings_for_display(); |
| 399 |
|
| 400 |
$classes = ['wp-block-quote', 'jltma-blockquote']; |
| 401 |
|
| 402 |
if ($settings['quote_symbol'] === 'yes') { |
| 403 |
$classes[] = 'jltma-show-start-symbol'; |
| 404 |
} |
| 405 |
if ($settings['quote_symbol_end'] === 'yes') { |
| 406 |
$classes[] = 'jltma-show-end-symbol'; |
| 407 |
} |
| 408 |
|
| 409 |
$show_author = $settings['quote_author_show'] === 'yes'; |
| 410 |
$show_author_symbol = $settings['quote_symbol_author'] === 'yes'; |
| 411 |
?> |
| 412 |
|
| 413 |
<blockquote class="<?php echo esc_attr(implode(' ', $classes)); ?>"> |
| 414 |
<p class="jltma-text"> |
| 415 |
<?php echo wp_kses_post($this->parse_text_editor($settings['jltma_blockquote_text'])); ?> |
| 416 |
</p> |
| 417 |
<?php if ($show_author) : ?> |
| 418 |
<cite> |
| 419 |
<?php if ($show_author_symbol) : ?> |
| 420 |
<span class="jltma-quote-symbol"></span> |
| 421 |
<?php endif; ?> |
| 422 |
<?php echo esc_html($this->parse_text_editor($settings['jltma_blockquote_author'])); ?> |
| 423 |
</cite> |
| 424 |
<?php endif; ?> |
| 425 |
</blockquote> |
| 426 |
|
| 427 |
<?php } |
| 428 |
} |
| 429 |
|