display-conditions.php
2 weeks ago
equal-height.php
2 weeks ago
floating-effects.php
2 weeks ago
liquid-glass.php
2 weeks ago
shape-divider.php
2 weeks ago
shapes.php
2 weeks ago
tooltips.php
2 days ago
wrapper-link.php
2 weeks ago
shape-divider.php
1116 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class: Shape_Divider |
| 4 | * Name: Shape Divider |
| 5 | * Slug: shape-divider |
| 6 | */ |
| 7 | |
| 8 | namespace PremiumAddons\Addons; |
| 9 | |
| 10 | // Elementor Classes. |
| 11 | use Elementor\Controls_Manager; |
| 12 | |
| 13 | // Premium Addons Classes. |
| 14 | use PremiumAddons\Includes\Helper_Functions; |
| 15 | use PremiumAddons\Admin\Includes\Admin_Helper; |
| 16 | use PremiumAddons\Includes\Controls\Premium_Image_Choose; |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit; // If this file is called directly, abort. |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Class Shape_Divider |
| 24 | * |
| 25 | * @since 4.11.58 |
| 26 | * @access public |
| 27 | * @package PremiumAddons\Addons |
| 28 | */ |
| 29 | class Shape_Divider { |
| 30 | |
| 31 | /** |
| 32 | * Check whether the scripts should be loaded. |
| 33 | * |
| 34 | * @var boolean|null $load_script, initialized as null. |
| 35 | */ |
| 36 | private static $load_script = null; |
| 37 | |
| 38 | /** |
| 39 | * Holds the singleton instance of this class. |
| 40 | * |
| 41 | * @var self|null |
| 42 | */ |
| 43 | private static $instance = null; |
| 44 | |
| 45 | /** |
| 46 | * Check if Premium Addons Pro is activated. |
| 47 | * |
| 48 | * @var boolean $papro_activated, initialized as false. |
| 49 | */ |
| 50 | private $papro_activated = false; |
| 51 | |
| 52 | /** |
| 53 | * Class Constructor Function. |
| 54 | */ |
| 55 | public function __construct() { |
| 56 | |
| 57 | $this->papro_activated = Helper_Functions::check_papro_version(); |
| 58 | |
| 59 | // Enqueue the required JS file. |
| 60 | add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 61 | add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_styles' ) ); |
| 62 | |
| 63 | // Creates Premium Global Divider tab at the end of layout/content tab. |
| 64 | add_action( 'elementor/element/section/section_advanced/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 65 | add_action( 'elementor/element/column/section_advanced/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 66 | |
| 67 | // Editor Hooks. |
| 68 | add_action( 'elementor/section/print_template', array( $this, 'print_template' ), 10, 1 ); |
| 69 | add_action( 'elementor/column/print_template', array( $this, 'print_template' ), 10, 1 ); |
| 70 | |
| 71 | // Frontend Hooks. |
| 72 | add_action( 'elementor/frontend/section/before_render', array( $this, 'before_render' ) ); |
| 73 | add_action( 'elementor/frontend/column/before_render', array( $this, 'before_render' ) ); |
| 74 | |
| 75 | add_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) ); |
| 76 | |
| 77 | add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'register_controls' ), 10 ); |
| 78 | add_action( 'elementor/container/print_template', array( $this, 'print_template' ), 10, 1 ); |
| 79 | add_action( 'elementor/frontend/container/before_render', array( $this, 'before_render' ) ); |
| 80 | |
| 81 | add_action( 'wp_ajax_get_shape_divider_svg', array( $this, 'get_shape_divider_svg' ) ); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Enqueue scripts. |
| 86 | * |
| 87 | * Registers required dependencies for the extension and enqueues them. |
| 88 | * |
| 89 | * @since 1.6.5 |
| 90 | * @access public |
| 91 | */ |
| 92 | public function enqueue_scripts() { |
| 93 | |
| 94 | if ( ! wp_script_is( 'pa-anime', 'enqueued' ) ) { |
| 95 | wp_enqueue_script( 'pa-anime' ); |
| 96 | } |
| 97 | |
| 98 | if ( ! wp_script_is( 'pa-shape-divider', 'enqueued' ) ) { |
| 99 | wp_enqueue_script( 'pa-shape-divider' ); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Enqueue styles. |
| 105 | * |
| 106 | * Registers required dependencies for the extension and enqueues them. |
| 107 | * |
| 108 | * @since 2.6.5 |
| 109 | * @access public |
| 110 | */ |
| 111 | public function enqueue_styles() { |
| 112 | |
| 113 | if ( ! wp_style_is( 'pa-shape-divider', 'enqueued' ) ) { |
| 114 | wp_enqueue_style( 'pa-shape-divider' ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Register Shape Divider controls. |
| 120 | * |
| 121 | * @since 1.0.0 |
| 122 | * @access public |
| 123 | * @param object $element for current element. |
| 124 | */ |
| 125 | public function register_controls( $element ) { |
| 126 | |
| 127 | $element->start_controls_section( |
| 128 | 'section_premium_global_divider', |
| 129 | array( |
| 130 | 'label' => sprintf( '<i class="pa-extension-icon pa-dash-icon"></i> %s', __( 'Animated Shape Divider', 'premium-addons-for-elementor' ) ), |
| 131 | 'tab' => Controls_Manager::TAB_STYLE, |
| 132 | ) |
| 133 | ); |
| 134 | |
| 135 | $element->add_control( |
| 136 | 'premium_global_divider_sw', |
| 137 | array( |
| 138 | 'label' => __( 'Enable Animated Shape Divider', 'premium-addons-for-elementor' ), |
| 139 | 'type' => Controls_Manager::SWITCHER, |
| 140 | 'render_type' => 'template', |
| 141 | 'prefix_class' => 'premium-shape-divider-', |
| 142 | ) |
| 143 | ); |
| 144 | |
| 145 | $element->start_controls_tabs( |
| 146 | 'premium_gdivider_tabs' |
| 147 | ); |
| 148 | |
| 149 | $this->add_divider_content_controls( $element ); |
| 150 | |
| 151 | $this->add_divider_style_controls( $element ); |
| 152 | |
| 153 | $element->end_controls_tabs(); |
| 154 | |
| 155 | $element->end_controls_section(); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Add divider content controls. |
| 160 | * |
| 161 | * @access private |
| 162 | * @since 4.10.4 |
| 163 | * |
| 164 | * @param object $element for current element. |
| 165 | */ |
| 166 | private function add_divider_content_controls( $element ) { |
| 167 | |
| 168 | $element->start_controls_tab( |
| 169 | 'premium_divider_content_tab', |
| 170 | array( |
| 171 | 'label' => __( 'Content', 'premium-addons-for-elementor' ), |
| 172 | 'condition' => array( |
| 173 | 'premium_global_divider_sw' => 'yes', |
| 174 | ), |
| 175 | ) |
| 176 | ); |
| 177 | |
| 178 | $element->add_control( |
| 179 | 'premium_gdivider_source', |
| 180 | array( |
| 181 | 'label' => __( 'Source', 'premium-addons-for-elementor' ), |
| 182 | 'type' => Controls_Manager::SELECT, |
| 183 | 'render_type' => 'template', |
| 184 | 'prefix_class' => 'premium-shape-divider__', |
| 185 | 'options' => array( |
| 186 | 'default' => __( 'Default', 'premium-addons-for-elementor' ), |
| 187 | 'custom' => __( 'Custom SVG', 'premium-addons-for-elementor' ), |
| 188 | ), |
| 189 | 'default' => 'default', |
| 190 | 'condition' => array( |
| 191 | 'premium_global_divider_sw' => 'yes', |
| 192 | ), |
| 193 | ) |
| 194 | ); |
| 195 | |
| 196 | $element->add_control( |
| 197 | 'premium_gdivider_defaults', |
| 198 | array( |
| 199 | 'label' => __( 'Shapes', 'premium-addons-for-elementor' ), |
| 200 | 'type' => Premium_Image_Choose::TYPE, |
| 201 | 'options' => Helper_Functions::get_svg_shapes(), |
| 202 | 'render_type' => 'template', |
| 203 | 'prefix_class' => 'premium-', |
| 204 | 'default' => 'shape22', |
| 205 | 'condition' => array( |
| 206 | 'premium_global_divider_sw' => 'yes', |
| 207 | 'premium_gdivider_source' => 'default', |
| 208 | ), |
| 209 | ) |
| 210 | ); |
| 211 | |
| 212 | $element->add_responsive_control( |
| 213 | 'premium_gdivider_pos', |
| 214 | array( |
| 215 | 'label' => __( 'Position', 'premium-addons-for-elementor' ), |
| 216 | 'type' => Controls_Manager::CHOOSE, |
| 217 | 'render_type' => 'template', |
| 218 | 'options' => array( |
| 219 | 'top' => array( |
| 220 | 'title' => __( 'Top', 'premium-addons-for-elementor' ), |
| 221 | 'icon' => 'eicon-arrow-up', |
| 222 | ), |
| 223 | 'bottom' => array( |
| 224 | 'title' => __( 'Bottom', 'premium-addons-for-elementor' ), |
| 225 | 'icon' => 'eicon-arrow-down', |
| 226 | ), |
| 227 | 'left' => array( |
| 228 | 'title' => __( 'Left', 'premium-addons-for-elementor' ), |
| 229 | 'icon' => 'eicon-arrow-left', |
| 230 | ), |
| 231 | 'right' => array( |
| 232 | 'title' => __( 'Right', 'premium-addons-for-elementor' ), |
| 233 | 'icon' => 'eicon-arrow-right', |
| 234 | ), |
| 235 | ), |
| 236 | 'default' => 'bottom', |
| 237 | 'toggle' => false, |
| 238 | 'condition' => array( |
| 239 | 'premium_global_divider_sw' => 'yes', |
| 240 | ), |
| 241 | 'selectors' => array( |
| 242 | '{{WRAPPER}}' => '--pa-sh-divider-pos:{{VALUE}}', |
| 243 | ), |
| 244 | ) |
| 245 | ); |
| 246 | |
| 247 | if ( ! $this->papro_activated ) { |
| 248 | |
| 249 | $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'shape-addon', 'wp-editor', 'get-pro' ); |
| 250 | |
| 251 | $pro_shapes = array(); |
| 252 | |
| 253 | for ( $x = 26; $x <= 55; $x++ ) { |
| 254 | $pro_shapes[] = 'shape' . $x; |
| 255 | } |
| 256 | |
| 257 | $element->add_control( |
| 258 | 'pro_options_notice', |
| 259 | array( |
| 260 | 'type' => Controls_Manager::RAW_HTML, |
| 261 | 'raw' => __( 'This option is available in Premium Addons Pro. ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>', |
| 262 | 'content_classes' => 'papro-upgrade-notice', |
| 263 | 'conditions' => array( |
| 264 | 'terms' => array( |
| 265 | array( |
| 266 | 'name' => 'premium_global_divider_sw', |
| 267 | 'value' => 'yes', |
| 268 | ), |
| 269 | array( |
| 270 | 'relation' => 'or', |
| 271 | 'terms' => array( |
| 272 | array( |
| 273 | 'terms' => array( |
| 274 | array( |
| 275 | 'name' => 'premium_gdivider_source', |
| 276 | 'value' => 'default', |
| 277 | ), |
| 278 | array( |
| 279 | 'name' => 'premium_gdivider_defaults', |
| 280 | 'operator' => 'in', |
| 281 | 'value' => $pro_shapes, |
| 282 | ), |
| 283 | ), |
| 284 | ), |
| 285 | array( |
| 286 | 'terms' => array( |
| 287 | array( |
| 288 | 'name' => 'premium_gdivider_pos', |
| 289 | 'operator' => 'in', |
| 290 | 'value' => array( 'left', 'right' ), |
| 291 | ), |
| 292 | ), |
| 293 | ), |
| 294 | array( |
| 295 | 'terms' => array( |
| 296 | array( |
| 297 | 'name' => 'premium_gdivider_source', |
| 298 | 'operator' => '===', |
| 299 | 'value' => 'custom', |
| 300 | ), |
| 301 | ), |
| 302 | ), |
| 303 | |
| 304 | ), |
| 305 | ), |
| 306 | ), |
| 307 | ), |
| 308 | ) |
| 309 | ); |
| 310 | |
| 311 | } else { |
| 312 | do_action( 'pa_divider_custom_svg', $element ); |
| 313 | } |
| 314 | |
| 315 | $element->add_responsive_control( |
| 316 | 'premium_gdivider_height', |
| 317 | array( |
| 318 | 'label' => __( 'Short Axis (PX)', 'premium-addons-for-elementor' ), |
| 319 | 'type' => Controls_Manager::SLIDER, |
| 320 | 'description' => __( 'Use this option to change the height of the divider', 'premium-addons-for-elementor' ), |
| 321 | 'range' => array( |
| 322 | 'px' => array( |
| 323 | 'min' => 0, |
| 324 | 'max' => 2000, |
| 325 | 'step' => 1, |
| 326 | ), |
| 327 | ), |
| 328 | 'default' => array( |
| 329 | 'unit' => 'px', |
| 330 | 'size' => 150, |
| 331 | ), |
| 332 | 'selectors' => array( |
| 333 | '{{WRAPPER}} #premium-shape-divider-{{ID}} svg' => 'height:{{SIZE}}px', |
| 334 | ), |
| 335 | 'condition' => array( |
| 336 | 'premium_global_divider_sw' => 'yes', |
| 337 | ), |
| 338 | ) |
| 339 | ); |
| 340 | |
| 341 | $element->add_responsive_control( |
| 342 | 'premium_gdivider_width', |
| 343 | array( |
| 344 | 'label' => __( 'Long Axis', 'premium-addons-for-elementor' ), |
| 345 | 'type' => Controls_Manager::SLIDER, |
| 346 | 'description' => __( 'Use this option to change the width of the divider.', 'premium-addons-for-elementor' ), |
| 347 | 'range' => array( |
| 348 | 'px' => array( |
| 349 | 'min' => 100, |
| 350 | 'max' => 1000, |
| 351 | 'step' => 1, |
| 352 | ), |
| 353 | ), |
| 354 | 'default' => array( |
| 355 | 'unit' => 'px', |
| 356 | 'size' => 100, |
| 357 | ), |
| 358 | 'selectors' => array( |
| 359 | '{{WRAPPER}}.premium-shape-divider__top #premium-shape-divider-{{ID}} svg, {{WRAPPER}}.premium-shape-divider__bottom #premium-shape-divider-{{ID}} svg' => 'width: calc( {{SIZE}}% + 2px );', |
| 360 | '{{WRAPPER}}.premium-shape-divider__right #premium-shape-divider-{{ID}} svg, {{WRAPPER}}.premium-shape-divider__left #premium-shape-divider-{{ID}} svg' => 'width: calc( var(--premium-shape-divider-h) + {{SIZE}}px ) !important;', |
| 361 | ), |
| 362 | 'condition' => array( |
| 363 | 'premium_global_divider_sw' => 'yes', |
| 364 | 'premium_gdivider_animate!' => 'yes', |
| 365 | ), |
| 366 | ) |
| 367 | ); |
| 368 | |
| 369 | $element->add_responsive_control( |
| 370 | 'premium_gdivider_scale', |
| 371 | array( |
| 372 | 'label' => __( 'Long Axis', 'premium-addons-for-elementor' ), |
| 373 | 'type' => Controls_Manager::SLIDER, |
| 374 | 'description' => __( 'Use this option to change the width of the divider.', 'premium-addons-for-elementor' ), |
| 375 | 'range' => array( |
| 376 | 'px' => array( |
| 377 | 'min' => 1.1, |
| 378 | 'max' => 20, |
| 379 | 'step' => 1, |
| 380 | ), |
| 381 | ), |
| 382 | 'default' => array( |
| 383 | 'unit' => 'px', |
| 384 | 'size' => 4, |
| 385 | ), |
| 386 | 'selectors' => array( |
| 387 | '{{WRAPPER}}.premium-shape-divider__bottom:not(.premium-sh-no-stretch-yes) #premium-shape-divider-{{ID}}' => 'transform: scaleX({{SIZE}}); --pa-divider-scale: {{SIZE}}', |
| 388 | '{{WRAPPER}}.premium-shape-divider__top:not(.premium-sh-no-stretch-yes) #premium-shape-divider-{{ID}}' => 'transform: scaleX({{SIZE}}) rotateX(180deg); --pa-divider-scale: {{SIZE}}', |
| 389 | |
| 390 | '{{WRAPPER}}.premium-shape-divider__bottom.premium-sh-no-stretch-yes #premium-shape-divider-{{ID}}' => 'transform: scale({{SIZE}}); --pa-divider-scale: {{SIZE}}', |
| 391 | '{{WRAPPER}}.premium-shape-divider__top.premium-sh-no-stretch-yes #premium-shape-divider-{{ID}}' => 'transform: scale({{SIZE}}) rotateX(180deg); --pa-divider-scale: {{SIZE}}', |
| 392 | |
| 393 | '{{WRAPPER}}.premium-shape-divider__right:not(.premium-sh-no-stretch-yes) #premium-shape-divider-{{ID}}, {{WRAPPER}}.premium-shape-divider__left:not(.premium-sh-no-stretch-yes) #premium-shape-divider-{{ID}}' => 'transform: scaleY({{SIZE}}); --pa-divider-scale: {{SIZE}}', |
| 394 | |
| 395 | '{{WRAPPER}}.premium-shape-divider__right.premium-sh-no-stretch-yes #premium-shape-divider-{{ID}}, {{WRAPPER}}.premium-shape-divider__left.premium-sh-no-stretch-yes #premium-shape-divider-{{ID}}' => 'transform: scale({{SIZE}}); --pa-divider-scale: {{SIZE}}', |
| 396 | ), |
| 397 | 'condition' => array( |
| 398 | 'premium_global_divider_sw' => 'yes', |
| 399 | 'premium_gdivider_animate' => 'yes', |
| 400 | ), |
| 401 | ) |
| 402 | ); |
| 403 | |
| 404 | $element->add_responsive_control( |
| 405 | 'premium_gdivider_offset', |
| 406 | array( |
| 407 | 'label' => __( 'Offset', 'premium-addons-for-elementor' ), |
| 408 | 'type' => Controls_Manager::SLIDER, |
| 409 | 'range' => array( |
| 410 | 'px' => array( |
| 411 | 'min' => -200, |
| 412 | 'max' => 200, |
| 413 | 'step' => 1, |
| 414 | ), |
| 415 | ), |
| 416 | 'selectors' => array( |
| 417 | '{{WRAPPER}} #premium-shape-divider-{{ID}}' => '{{premium_gdivider_pos.VALUE}}: {{SIZE}}px;', |
| 418 | ), |
| 419 | 'condition' => array( |
| 420 | 'premium_global_divider_sw' => 'yes', |
| 421 | ), |
| 422 | ) |
| 423 | ); |
| 424 | |
| 425 | $element->add_control( |
| 426 | 'premium_gdivider_animate', |
| 427 | array( |
| 428 | 'label' => __( 'Animate', 'premium-addons-for-elementor' ), |
| 429 | 'type' => Controls_Manager::SWITCHER, |
| 430 | 'prefix_class' => 'premium-shape-divider-anime-', |
| 431 | 'render_type' => 'template', |
| 432 | 'default' => 'yes', |
| 433 | 'condition' => array( |
| 434 | 'premium_global_divider_sw' => 'yes', |
| 435 | ), |
| 436 | ) |
| 437 | ); |
| 438 | |
| 439 | $element->add_control( |
| 440 | 'premium_gdivider_no_stretch', |
| 441 | array( |
| 442 | 'label' => __( 'Prevent Stretch', 'premium-addons-for-elementor' ), |
| 443 | 'type' => Controls_Manager::SWITCHER, |
| 444 | 'description' => __( 'This option is used if you want to animate the divider without stretching the SVG.', 'premium-addons-for-elementor' ), |
| 445 | 'prefix_class' => 'premium-sh-no-stretch-', |
| 446 | 'default' => 'yes', |
| 447 | 'render_type' => 'template', |
| 448 | 'condition' => array( |
| 449 | 'premium_global_divider_sw' => 'yes', |
| 450 | 'premium_gdivider_animate' => 'yes', |
| 451 | 'premium_gdivider_defaults!' => 'shape22', |
| 452 | ), |
| 453 | ) |
| 454 | ); |
| 455 | |
| 456 | $element->add_control( |
| 457 | 'animation_notice', |
| 458 | array( |
| 459 | 'raw' => __( 'Important: You may need to change Long Axis option value to fit your needs.', 'premium-addons-for-elementor' ), |
| 460 | 'type' => Controls_Manager::RAW_HTML, |
| 461 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning', |
| 462 | 'condition' => array( |
| 463 | 'premium_global_divider_sw' => 'yes', |
| 464 | 'premium_gdivider_animate' => 'yes', |
| 465 | ), |
| 466 | ) |
| 467 | ); |
| 468 | |
| 469 | $element->add_responsive_control( |
| 470 | 'premium_gdivider_anime_speed', |
| 471 | array( |
| 472 | 'label' => __( 'Animation Speed (sec)', 'premium-addons-for-elementor' ), |
| 473 | 'type' => Controls_Manager::SLIDER, |
| 474 | 'range' => array( |
| 475 | 'px' => array( |
| 476 | 'min' => 0, |
| 477 | 'max' => 20, |
| 478 | 'step' => 0.1, |
| 479 | ), |
| 480 | ), |
| 481 | 'default' => array( |
| 482 | 'size' => 10, |
| 483 | 'unit' => 'px', |
| 484 | ), |
| 485 | 'selectors' => array( |
| 486 | '{{WRAPPER}}.premium-shape-divider-anime-yes:not(.premium-shape22) #premium-shape-divider-{{ID}}' => 'animation-duration: {{SIZE}}s;', |
| 487 | ), |
| 488 | 'condition' => array( |
| 489 | 'premium_global_divider_sw' => 'yes', |
| 490 | 'premium_gdivider_animate' => 'yes', |
| 491 | 'premium_gdivider_defaults!' => 'shape22', |
| 492 | ), |
| 493 | ) |
| 494 | ); |
| 495 | |
| 496 | $element->add_control( |
| 497 | 'premium_gdivider_anime_dir', |
| 498 | array( |
| 499 | 'label' => __( 'Animation Direction', 'premium-addons-for-elementor' ), |
| 500 | 'type' => Controls_Manager::SELECT, |
| 501 | 'options' => array( |
| 502 | 'normal' => __( 'Normal', 'premium-addons-for-elementor' ), |
| 503 | 'reverse' => __( 'Reverse', 'premium-addons-for-elementor' ), |
| 504 | 'alternate' => __( 'Alternate', 'premium-addons-for-elementor' ), |
| 505 | ), |
| 506 | 'default' => 'alternate', |
| 507 | 'condition' => array( |
| 508 | 'premium_global_divider_sw' => 'yes', |
| 509 | 'premium_gdivider_animate' => 'yes', |
| 510 | 'premium_gdivider_defaults!' => 'shape22', |
| 511 | ), |
| 512 | 'selectors' => array( |
| 513 | '{{WRAPPER}}.premium-shape-divider-anime-yes:not(.premium-shape22) #premium-shape-divider-{{ID}}' => 'animation-direction: {{VALUE}};', |
| 514 | ), |
| 515 | ) |
| 516 | ); |
| 517 | |
| 518 | $element->add_control( |
| 519 | 'premium_gdivider_flip', |
| 520 | array( |
| 521 | 'label' => __( 'Horizontal Flip', 'premium-addons-for-elementor' ), |
| 522 | 'type' => Controls_Manager::SWITCHER, |
| 523 | 'render_type' => 'template', |
| 524 | 'prefix_class' => 'premium-sh-divider-hflip-', |
| 525 | 'condition' => array( |
| 526 | 'premium_global_divider_sw' => 'yes', |
| 527 | 'premium_gdivider_animate!' => 'yes', |
| 528 | 'premium_gdivider_pos' => array( 'top', 'bottom' ), |
| 529 | ), |
| 530 | ) |
| 531 | ); |
| 532 | |
| 533 | $element->add_control( |
| 534 | 'premium_gdivider_flip_x', |
| 535 | array( |
| 536 | 'label' => __( 'Vertical Flip', 'premium-addons-for-elementor' ), |
| 537 | 'type' => Controls_Manager::SWITCHER, |
| 538 | 'prefix_class' => 'premium-sh-divider-vflip-', |
| 539 | 'render_type' => 'template', |
| 540 | 'condition' => array( |
| 541 | 'premium_global_divider_sw' => 'yes', |
| 542 | 'premium_gdivider_animate!' => 'yes', |
| 543 | ), |
| 544 | ) |
| 545 | ); |
| 546 | |
| 547 | $element->add_control( |
| 548 | 'premium_gdivider_hide', |
| 549 | array( |
| 550 | 'label' => __( 'Hide Shape On', 'premium-addons-for-elementor' ), |
| 551 | 'type' => Controls_Manager::SELECT2, |
| 552 | 'options' => Helper_Functions::get_all_breakpoints(), |
| 553 | 'separator' => 'after', |
| 554 | 'multiple' => true, |
| 555 | 'label_block' => true, |
| 556 | 'default' => array(), |
| 557 | 'condition' => array( |
| 558 | 'premium_global_divider_sw' => 'yes', |
| 559 | ), |
| 560 | ) |
| 561 | ); |
| 562 | |
| 563 | $element->end_controls_tab(); |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Add tooltips style controls. |
| 568 | * |
| 569 | * @access private |
| 570 | * @since 4.10.4 |
| 571 | * |
| 572 | * @param object $element for current element. |
| 573 | */ |
| 574 | private function add_divider_style_controls( $element ) { |
| 575 | |
| 576 | $element->start_controls_tab( |
| 577 | 'premium_gdivider_style_tab', |
| 578 | array( |
| 579 | 'label' => __( 'Style', 'premium-addons-for-elementor' ), |
| 580 | 'condition' => array( |
| 581 | 'premium_global_divider_sw' => 'yes', |
| 582 | ), |
| 583 | ) |
| 584 | ); |
| 585 | |
| 586 | $element->add_control( |
| 587 | 'premium_gdivider_bg_type', |
| 588 | array( |
| 589 | 'label' => __( 'Fill', 'premium-addons-for-elementor' ), |
| 590 | 'type' => Controls_Manager::SELECT, |
| 591 | 'render_type' => 'template', |
| 592 | 'default' => 'color', |
| 593 | 'options' => array( |
| 594 | 'color' => __( 'Color', 'premium-addons-for-elementor' ), |
| 595 | 'image' => __( 'Image', 'premium-addons-for-elementor' ), |
| 596 | 'gradient' => __( 'Gradient', 'premium-addons-for-elementor' ), |
| 597 | ), |
| 598 | 'condition' => array( |
| 599 | 'premium_global_divider_sw' => 'yes', |
| 600 | ), |
| 601 | ) |
| 602 | ); |
| 603 | |
| 604 | $element->add_control( |
| 605 | 'premium_gdivider_fill', |
| 606 | array( |
| 607 | 'label' => __( 'Color', 'premium-addons-for-elementor' ), |
| 608 | 'type' => Controls_Manager::COLOR, |
| 609 | 'default' => '#afafaf', |
| 610 | 'selectors' => array( |
| 611 | '{{WRAPPER}} #premium-shape-divider-{{ID}} svg, |
| 612 | {{WRAPPER}} #premium-shape-divider-{{ID}} svg *' => 'fill: {{VALUE}};', |
| 613 | ), |
| 614 | 'condition' => array( |
| 615 | 'premium_global_divider_sw' => 'yes', |
| 616 | 'premium_gdivider_bg_type' => 'color', |
| 617 | ), |
| 618 | ) |
| 619 | ); |
| 620 | |
| 621 | if ( ! $this->papro_activated ) { |
| 622 | |
| 623 | $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'shape-addon', 'wp-editor', 'get-pro' ); |
| 624 | |
| 625 | $element->add_control( |
| 626 | 'divider_fill_notice', |
| 627 | array( |
| 628 | 'type' => Controls_Manager::RAW_HTML, |
| 629 | 'raw' => __( 'This option is available in Premium Addons Pro. ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>', |
| 630 | 'content_classes' => 'papro-upgrade-notice', |
| 631 | 'condition' => array( |
| 632 | 'premium_global_divider_sw' => 'yes', |
| 633 | 'premium_gdivider_bg_type!' => 'color', |
| 634 | ), |
| 635 | ) |
| 636 | ); |
| 637 | |
| 638 | } else { |
| 639 | do_action( 'pa_divider_fill_controls', $element ); |
| 640 | } |
| 641 | |
| 642 | $element->add_responsive_control( |
| 643 | 'premium_gdivider_stroke_width', |
| 644 | array( |
| 645 | 'label' => __( 'Stroke Width', 'premium-addons-for-elementor' ), |
| 646 | 'type' => Controls_Manager::SLIDER, |
| 647 | 'range' => array( |
| 648 | 'px' => array( |
| 649 | 'min' => 0, |
| 650 | 'max' => 10, |
| 651 | 'step' => 0.1, |
| 652 | ), |
| 653 | ), |
| 654 | 'separator' => 'before', |
| 655 | 'selectors' => array( |
| 656 | '{{WRAPPER}} #premium-shape-divider-{{ID}} svg' => 'stroke-width: {{SIZE}}px;', |
| 657 | ), |
| 658 | 'condition' => array( |
| 659 | 'premium_global_divider_sw' => 'yes', |
| 660 | ), |
| 661 | ) |
| 662 | ); |
| 663 | |
| 664 | $element->add_control( |
| 665 | 'premium_gdivider_stroke', |
| 666 | array( |
| 667 | 'label' => __( 'Stroke Color', 'premium-addons-for-elementor' ), |
| 668 | 'type' => Controls_Manager::COLOR, |
| 669 | 'selectors' => array( |
| 670 | '{{WRAPPER}} #premium-shape-divider-{{ID}} svg' => 'stroke: {{VALUE}};', |
| 671 | ), |
| 672 | 'condition' => array( |
| 673 | 'premium_global_divider_sw' => 'yes', |
| 674 | ), |
| 675 | ) |
| 676 | ); |
| 677 | |
| 678 | $element->add_control( |
| 679 | 'premium_gdivider_opacity', |
| 680 | array( |
| 681 | 'label' => __( 'Opacity', 'premium-addons-for-elementor' ), |
| 682 | 'type' => Controls_Manager::SLIDER, |
| 683 | 'range' => array( |
| 684 | 'px' => array( |
| 685 | 'min' => 0, |
| 686 | 'max' => 1, |
| 687 | 'step' => 0.1, |
| 688 | ), |
| 689 | ), |
| 690 | 'default' => array( |
| 691 | 'unit' => 'px', |
| 692 | 'size' => 0.3, |
| 693 | ), |
| 694 | 'selectors' => array( |
| 695 | '{{WRAPPER}} #premium-shape-divider-{{ID}} svg' => 'opacity: {{SIZE}};', |
| 696 | ), |
| 697 | 'condition' => array( |
| 698 | 'premium_global_divider_sw' => 'yes', |
| 699 | ), |
| 700 | ) |
| 701 | ); |
| 702 | |
| 703 | $element->add_control( |
| 704 | 'premium_gdivider_zindex', |
| 705 | array( |
| 706 | 'label' => __( 'Z-Index', 'premium-addons-for-elementor' ), |
| 707 | 'type' => Controls_Manager::NUMBER, |
| 708 | 'selectors' => array( |
| 709 | '{{WRAPPER}} #premium-shape-divider-{{ID}}, {{WRAPPER}} #premium-shape-divider-{{ID}} svg' => 'z-index: {{VALUE}};', |
| 710 | ), |
| 711 | 'condition' => array( |
| 712 | 'premium_global_divider_sw' => 'yes', |
| 713 | ), |
| 714 | ) |
| 715 | ); |
| 716 | |
| 717 | $element->end_controls_tab(); |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * Render Global divider output in the editor. |
| 722 | * |
| 723 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| 724 | * |
| 725 | * @since 2.2.8 |
| 726 | * @access public |
| 727 | * |
| 728 | * @param string $template for current template. |
| 729 | */ |
| 730 | public function print_template( $template ) { |
| 731 | |
| 732 | $old_template = $template; |
| 733 | ob_start(); |
| 734 | |
| 735 | $papro_activated = $this->papro_activated ? 'yes' : 'no'; |
| 736 | |
| 737 | ?> |
| 738 | <# |
| 739 | var isEnabled = 'yes' === settings.premium_global_divider_sw ? true : false; |
| 740 | |
| 741 | if ( isEnabled ) { |
| 742 | |
| 743 | var source = settings.premium_gdivider_source, |
| 744 | shapeHTML = '', |
| 745 | customFill = 'color' !== settings.premium_gdivider_bg_type; |
| 746 | |
| 747 | if ( customFill ) { |
| 748 | var imgFill = 'image' === settings.premium_gdivider_bg_type; |
| 749 | |
| 750 | view.addRenderAttribute( 'fill_data', { |
| 751 | 'xmlns': 'http://www.w3.org/2000/svg', |
| 752 | 'id': 'premium-shape-divider-fill-' + view.getID(), |
| 753 | 'width': '0px', |
| 754 | 'height': '0px', |
| 755 | 'preserveAspectRatio': 'none', |
| 756 | 'aria-hidden': 'true' |
| 757 | }); |
| 758 | |
| 759 | if ( imgFill && settings.premium_gdivider_image ) { |
| 760 | |
| 761 | var fillHtml = "", |
| 762 | imgSrc = settings.premium_gdivider_image.url, |
| 763 | imgOptions = { |
| 764 | 'width': '100%', |
| 765 | 'height': '100%', |
| 766 | 'xpos': 0, |
| 767 | 'ypos': 0 , |
| 768 | 'aspect': ' preserveAspectRatio="none"' |
| 769 | }; |
| 770 | |
| 771 | view.addRenderAttribute( 'pattern', { |
| 772 | 'id': 'pa-shape-divider-fill-' + view.getID(), |
| 773 | 'width': '100%', |
| 774 | 'height': '100%', |
| 775 | 'patternUnits': 'userSpaceOnUse' |
| 776 | }); |
| 777 | |
| 778 | view.addRenderAttribute( 'pattern_img', { |
| 779 | 'href': imgSrc, |
| 780 | 'width': imgOptions.width, |
| 781 | 'height': imgOptions.height, |
| 782 | 'x': imgOptions.xpos, |
| 783 | 'y': imgOptions.ypos |
| 784 | }); |
| 785 | |
| 786 | #> |
| 787 | <svg {{{ view.getRenderAttributeString( 'fill_data' ) }}} > |
| 788 | <defs> |
| 789 | <pattern {{{view.getRenderAttributeString( 'pattern' ) }}} > |
| 790 | <image {{{view.getRenderAttributeString( 'pattern_img' ) }}} {{{imgOptions.aspect}}}/> |
| 791 | </pattern> |
| 792 | </defs> |
| 793 | </svg> |
| 794 | <# |
| 795 | } else if( settings.premium_gdivider_grad_xpos ) { |
| 796 | var gradType = settings.premium_gdivider_grad_type, |
| 797 | gradPos = 'linear' === gradType ? settings.premium_gdivider_grad_angle.size : [settings.premium_gdivider_grad_xpos.size, settings.premium_gdivider_grad_ypos.size ], |
| 798 | gradUnit = 'linear' === gradType ? 'deg' : '', |
| 799 | gradOptions = { |
| 800 | 'gradType' : gradType, |
| 801 | 'firstColor': settings.premium_gdivider_grad_firstcolor, |
| 802 | 'secColor' : settings.premium_gdivider_grad_secondcolor, |
| 803 | 'firstLoc' : settings.premium_gdivider_grad_firstloc.size, |
| 804 | 'secLoc' : settings.premium_gdivider_grad_secondloc.size, |
| 805 | 'pos' : gradPos |
| 806 | }; |
| 807 | |
| 808 | view.addRenderAttribute( 'grad_data', { |
| 809 | 'id': 'pa-shape-divider-fill-' + view.getID(), |
| 810 | 'gradientUnits': 'objectBoundingBox' |
| 811 | }); |
| 812 | |
| 813 | view.addRenderAttribute( 'grad_color', { |
| 814 | 'offset': gradOptions.firstLoc + '%', |
| 815 | 'stop-color': gradOptions.firstColor |
| 816 | }); |
| 817 | |
| 818 | view.addRenderAttribute( 'grad_color_sec', { |
| 819 | 'offset': gradOptions.secLoc + '%', |
| 820 | 'stop-color': gradOptions.secColor |
| 821 | }); |
| 822 | |
| 823 | #> |
| 824 | <svg {{{ view.getRenderAttributeString( 'fill_data' ) }}} > |
| 825 | <defs> |
| 826 | <# |
| 827 | if ( 'linear' === gradOptions.gradType ) { |
| 828 | view.addRenderAttribute( 'grad_data', { |
| 829 | 'gradientTransform': 'rotate(' + gradOptions.pos + gradUnit + ')' |
| 830 | }); |
| 831 | #> |
| 832 | <linearGradient {{{view.getRenderAttributeString( 'grad_data' ) }}}> |
| 833 | <stop {{{view.getRenderAttributeString( 'grad_color' ) }}} ></stop> |
| 834 | <stop {{{view.getRenderAttributeString( 'grad_color_sec' ) }}} ></stop> |
| 835 | </linearGradient> |
| 836 | <# |
| 837 | } else { |
| 838 | view.addRenderAttribute( 'grad_data', { |
| 839 | 'cx': gradOptions.pos[0] + '%', |
| 840 | 'cy': gradOptions.pos[1] + '%' |
| 841 | }); |
| 842 | #> |
| 843 | <radialGradient {{{view.getRenderAttributeString( 'grad_data' ) }}}> |
| 844 | <stop {{{view.getRenderAttributeString( 'grad_color' ) }}} ></stop> |
| 845 | <stop {{{view.getRenderAttributeString( 'grad_color_sec' ) }}} ></stop> |
| 846 | </radialGradient> |
| 847 | <# |
| 848 | } |
| 849 | #> |
| 850 | </defs> |
| 851 | </svg> |
| 852 | <# |
| 853 | } |
| 854 | |
| 855 | } |
| 856 | |
| 857 | if ( 'default' !== source ) { |
| 858 | shapeHTML = settings.premium_gdivider_custom; |
| 859 | } else { |
| 860 | |
| 861 | var isProVersionActive = '<?php echo esc_html( $papro_activated ); ?>' === 'yes' |
| 862 | selectedShapeIndex = parseInt(settings.premium_gdivider_defaults.replace(/[^\d]/g, ''), 10); |
| 863 | |
| 864 | shapeHTML = (selectedShapeIndex <= 25 || isProVersionActive) ? '' : 'pro'; |
| 865 | |
| 866 | view.addRenderAttribute( 'paShapeDivider', 'data-shape', selectedShapeIndex ); |
| 867 | |
| 868 | } |
| 869 | |
| 870 | function getContainerClasses() { |
| 871 | var classes = 'premium-shape-divider__shape-container', |
| 872 | hiddenDevices = settings.premium_gdivider_hide; |
| 873 | |
| 874 | if ( hiddenDevices.length ) { |
| 875 | hiddenDevices.forEach(function(device) { |
| 876 | classes += ' elementor-hidden-' + device; |
| 877 | }); |
| 878 | |
| 879 | classes += ' premium-addons-element'; |
| 880 | } |
| 881 | |
| 882 | return classes; |
| 883 | } |
| 884 | |
| 885 | if ( 'pro' !== shapeHTML ) { |
| 886 | view.addRenderAttribute( 'paShapeDivider', { |
| 887 | 'id': 'premium-shape-divider-' + view.getID(), |
| 888 | 'class': getContainerClasses(), |
| 889 | 'style': 'visibility:hidden; opacity:0;' |
| 890 | }); |
| 891 | #> |
| 892 | <div {{{ view.getRenderAttributeString( 'paShapeDivider' ) }}} >{{{shapeHTML}}}</div> |
| 893 | <# } else { #> |
| 894 | <div class="premium-error-notice"> |
| 895 | <?php echo wp_kses_post( __( 'This option is available in <b>Premium Addons Pro</b>.', 'premium-addons-for-elementor' ) ); ?> |
| 896 | </div> |
| 897 | <# } |
| 898 | |
| 899 | } |
| 900 | |
| 901 | #> |
| 902 | |
| 903 | <?php |
| 904 | $slider_content = ob_get_contents(); |
| 905 | ob_end_clean(); |
| 906 | $template = $slider_content . $old_template; |
| 907 | return $template; |
| 908 | } |
| 909 | |
| 910 | /** |
| 911 | * Render Global divider output on the frontend. |
| 912 | * |
| 913 | * Written in PHP and used to generate the final HTML. |
| 914 | * |
| 915 | * @since 1.0.0 |
| 916 | * @access public |
| 917 | * @param object $element for current element. |
| 918 | */ |
| 919 | public function before_render( $element ) { |
| 920 | |
| 921 | $id = $element->get_id(); |
| 922 | $settings = $element->get_settings_for_display(); |
| 923 | $divider_enabled = $settings['premium_global_divider_sw']; |
| 924 | |
| 925 | if ( 'yes' === $divider_enabled ) { |
| 926 | |
| 927 | if ( ! $this->papro_activated || version_compare( PREMIUM_PRO_ADDONS_VERSION, '2.9.8', '<' ) ) { |
| 928 | |
| 929 | $is_pro_shape = 'default' === $settings['premium_gdivider_source'] && str_replace( 'shape', '', $settings['premium_gdivider_defaults'] ) > 25; |
| 930 | |
| 931 | if ( $is_pro_shape || 'custom' === $settings['premium_gdivider_source'] || 'color' !== $settings['premium_gdivider_bg_type'] || in_array( $settings['premium_gdivider_pos'], array( 'left', 'right' ), true ) ) { |
| 932 | |
| 933 | ?> |
| 934 | <div class="premium-error-notice"> |
| 935 | <?php |
| 936 | $message = __( 'This option is available in <b>Premium Addons Pro</b>.', 'premium-addons-for-elementor' ); |
| 937 | echo wp_kses_post( $message ); |
| 938 | ?> |
| 939 | </div> |
| 940 | <?php |
| 941 | return false; |
| 942 | |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | $source = $settings['premium_gdivider_source']; |
| 947 | $hidden_style = 'visibility:hidden; position: absolute; opacity:0;'; |
| 948 | $shape = ''; |
| 949 | $custom_fill = 'color' !== $settings['premium_gdivider_bg_type']; |
| 950 | $shape_classes = Helper_Functions::get_element_classes( $settings['premium_gdivider_hide'], array( 'premium-shape-divider__shape-container' ) ); |
| 951 | |
| 952 | if ( 'default' !== $source ) { |
| 953 | $shape = $settings['premium_gdivider_custom']; |
| 954 | } else { |
| 955 | $shape = '' !== $settings['premium_gdivider_defaults'] ? Helper_Functions::get_svg_shapes( $settings['premium_gdivider_defaults'] ) : ''; |
| 956 | } |
| 957 | |
| 958 | if ( $custom_fill ) { |
| 959 | $this->add_custom_fill( $id, $settings ); |
| 960 | } |
| 961 | |
| 962 | $element->add_render_attribute( |
| 963 | 'shape_divider_cont' . $id, |
| 964 | array( |
| 965 | 'class' => $shape_classes, |
| 966 | 'id' => 'premium-shape-divider-' . esc_attr( $id ), |
| 967 | 'style' => $hidden_style, |
| 968 | ) |
| 969 | ); |
| 970 | |
| 971 | ?> |
| 972 | <div <?php $element->print_render_attribute_string( 'shape_divider_cont' . $id ); ?>> |
| 973 | <?php echo $shape; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 974 | </div> |
| 975 | <?php |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | |
| 980 | /** |
| 981 | * Add Custom Fill |
| 982 | * |
| 983 | * @since 1.0.0 |
| 984 | * @access public |
| 985 | * |
| 986 | * @param number $id for id. |
| 987 | * @param object $settings for settings. |
| 988 | */ |
| 989 | public function add_custom_fill( $id, $settings ) { |
| 990 | |
| 991 | $img_fill = 'image' === $settings['premium_gdivider_bg_type']; |
| 992 | |
| 993 | $svg_html = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" aria-hidden="true" id="premium-shape-divider-fill-' . $id . '" width="0px" height="0px"><defs>'; |
| 994 | |
| 995 | if ( $img_fill ) { |
| 996 | $img_src = $settings['premium_gdivider_image']['url']; |
| 997 | $img_options = array( |
| 998 | 'width' => '100%', |
| 999 | 'height' => '100%', |
| 1000 | 'xpos' => 0, |
| 1001 | 'ypos' => 0, |
| 1002 | 'aspect' => 'preserveAspectRatio="none"', |
| 1003 | ); |
| 1004 | |
| 1005 | $svg_html .= '<pattern id="pa-shape-divider-fill-' . $id . '" patternUnits="userSpaceOnUse" width="100%" height="100%">' . |
| 1006 | |
| 1007 | '<image href="' . esc_url( $img_src ) . '" x="' . $img_options['xpos'] . '" y="' . $img_options['ypos'] . '" width="' . $img_options['width'] . '" height="' . $img_options['height'] . '" ' . $img_options['aspect'] . ' />' . |
| 1008 | |
| 1009 | '</pattern>'; |
| 1010 | } else { |
| 1011 | // gradient. |
| 1012 | $gradient_type = $settings['premium_gdivider_grad_type']; |
| 1013 | $grad_pos = 'linear' === $gradient_type ? $settings['premium_gdivider_grad_angle']['size'] : array( $settings['premium_gdivider_grad_xpos']['size'], $settings['premium_gdivider_grad_ypos']['size'] ); |
| 1014 | $grad_unit = 'linear' === $gradient_type ? 'deg' : ''; |
| 1015 | |
| 1016 | $grad_options = array( |
| 1017 | 'gradType' => $gradient_type, |
| 1018 | 'firstColor' => $settings['premium_gdivider_grad_firstcolor'], |
| 1019 | 'secColor' => $settings['premium_gdivider_grad_secondcolor'], |
| 1020 | 'firstLoc' => $settings['premium_gdivider_grad_firstloc']['size'], |
| 1021 | 'secLoc' => $settings['premium_gdivider_grad_secondloc']['size'], |
| 1022 | 'pos' => $grad_pos, |
| 1023 | ); |
| 1024 | |
| 1025 | if ( 'linear' === $grad_options['gradType'] ) { |
| 1026 | $tag_close = '</linearGradient>'; |
| 1027 | $svg_html .= '<linearGradient id="pa-shape-divider-fill-' . $id . '" gradientUnits="objectBoundingBox" gradientTransform="rotate(' . $grad_options['pos'] . $grad_unit . ')">'; |
| 1028 | } else { |
| 1029 | $tag_close = '</radialGradient>'; |
| 1030 | $svg_html .= '<radialGradient id="pa-shape-divider-fill-' . $id . '" gradientUnits="objectBoundingBox" cx="' . $grad_options['pos'][0] . '%" cy="' . $grad_options['pos'][1] . '%">'; |
| 1031 | } |
| 1032 | |
| 1033 | $svg_html .= '<stop offset="' . $grad_options['firstLoc'] . '%" stop-color="' . $grad_options['firstColor'] . '" />' . |
| 1034 | '<stop offset="' . $grad_options['secLoc'] . '%" stop-color="' . $grad_options['secColor'] . '" />'; |
| 1035 | |
| 1036 | $svg_html .= $tag_close; |
| 1037 | } |
| 1038 | |
| 1039 | $svg_html .= '</defs></svg>'; |
| 1040 | echo $svg_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1041 | } |
| 1042 | |
| 1043 | /** |
| 1044 | * Get Shape Divider SVG |
| 1045 | * |
| 1046 | * @since 4.11.32 |
| 1047 | * @access public |
| 1048 | */ |
| 1049 | public function get_shape_divider_svg() { |
| 1050 | |
| 1051 | check_ajax_referer( 'pa-shape-nonce', 'nonce' ); |
| 1052 | |
| 1053 | if ( ! isset( $_POST['shape'] ) ) { |
| 1054 | wp_send_json_error( 'No shape selected' ); |
| 1055 | } |
| 1056 | |
| 1057 | $shape = sanitize_text_field( wp_unslash( $_POST['shape'] ) ); |
| 1058 | |
| 1059 | $svg_shape = Helper_Functions::get_svg_shapes( $shape ); |
| 1060 | |
| 1061 | if ( empty( $svg_shape ) ) { |
| 1062 | wp_send_json_error( 'Invalid shape' ); |
| 1063 | } |
| 1064 | |
| 1065 | wp_send_json_success( array( 'shape' => $svg_shape ) ); |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * Check Script Enqueue |
| 1070 | * |
| 1071 | * Check if the script files should be loaded. |
| 1072 | * |
| 1073 | * @since 2.6.3 |
| 1074 | * @access public |
| 1075 | * |
| 1076 | * @param object $element for current element. |
| 1077 | */ |
| 1078 | public function check_script_enqueue( $element ) { |
| 1079 | |
| 1080 | if ( self::$load_script ) { |
| 1081 | return; |
| 1082 | } |
| 1083 | |
| 1084 | $settings = $element->get_active_settings(); |
| 1085 | |
| 1086 | if ( ! empty( $settings['premium_global_divider_sw'] ) ) { |
| 1087 | |
| 1088 | $this->enqueue_styles(); |
| 1089 | $this->enqueue_scripts(); |
| 1090 | |
| 1091 | self::$load_script = true; |
| 1092 | |
| 1093 | remove_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) ); |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | /** |
| 1098 | * Creates and returns an instance of the class |
| 1099 | * |
| 1100 | * @since 4.2.5 |
| 1101 | * @access public |
| 1102 | * |
| 1103 | * @return object |
| 1104 | */ |
| 1105 | public static function get_instance() { |
| 1106 | |
| 1107 | if ( ! isset( self::$instance ) ) { |
| 1108 | |
| 1109 | self::$instance = new self(); |
| 1110 | |
| 1111 | } |
| 1112 | |
| 1113 | return self::$instance; |
| 1114 | } |
| 1115 | } |
| 1116 |