documents
6 years ago
dynamic-tags
6 years ago
query-control
6 years ago
settings
6 years ago
theme-builder
6 years ago
column.php
7 years ago
common.php
6 years ago
section.php
7 years ago
templates-types-manager.php
6 years ago
common.php
992 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Modules; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Image_Size; |
| 8 | use Elementor\Group_Control_Typography; |
| 9 | use Elementor\Scheme_Color; |
| 10 | use Elementor\Scheme_Typography; |
| 11 | use Elementor\Control_Media; |
| 12 | use Elementor\Group_Control_Border; |
| 13 | use Elementor\Group_Control_Box_Shadow; |
| 14 | use Elementor\Group_Control_Background; |
| 15 | |
| 16 | |
| 17 | class Common { |
| 18 | |
| 19 | /** |
| 20 | * Instance of this class. |
| 21 | * |
| 22 | * @var object |
| 23 | */ |
| 24 | protected static $instance = null; |
| 25 | |
| 26 | |
| 27 | function __construct(){ |
| 28 | |
| 29 | // Add new controls to advanced tab globally |
| 30 | add_action( "elementor/element/after_section_end", array( $this, 'add_position_controls_section' ), 10, 3 ); |
| 31 | |
| 32 | // Go pro notice for parallax options |
| 33 | add_action( "elementor/element/after_section_end", array( $this, 'add_parallax_go_pro_notice' ), 15, 3 ); |
| 34 | add_action( "elementor/element/after_section_end", array( $this, 'add_transition_controls_section'), 18, 3 ); |
| 35 | |
| 36 | add_action( "elementor/element/after_section_end", array( $this, 'add_extra_controls_section' ), 19, 3 ); |
| 37 | add_action( "elementor/element/after_section_end", array( $this, 'add_pseudo_background_controls' ), 20, 3 ); |
| 38 | add_action( "elementor/element/after_section_end", array( $this, 'add_custom_css_controls_section'), 25, 3 ); |
| 39 | |
| 40 | |
| 41 | // Renders attributes for all Elementor Elements |
| 42 | // add_action( 'elementor/frontend/widget/before_render' , array( $this, 'render_widget_attributes' ) ); |
| 43 | |
| 44 | // Render the custom CSS |
| 45 | if ( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 46 | add_action( 'elementor/element/parse_css', array( $this, 'add_post_css' ), 10, 2 ); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Return an instance of this class. |
| 52 | * |
| 53 | * @return object A single instance of this class. |
| 54 | */ |
| 55 | public static function get_instance() { |
| 56 | // If the single instance hasn't been set, set it now. |
| 57 | if ( null == self::$instance ) { |
| 58 | self::$instance = new self; |
| 59 | } |
| 60 | |
| 61 | return self::$instance; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Add custom css control to all elements |
| 66 | * |
| 67 | * @return void |
| 68 | */ |
| 69 | public function add_custom_css_controls_section( $widget, $section_id, $args ){ |
| 70 | |
| 71 | if( 'section_custom_css_pro' !== $section_id ){ |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 76 | |
| 77 | $widget->start_controls_section( |
| 78 | 'aux_core_common_custom_css_section', |
| 79 | array( |
| 80 | 'label' => __( 'Custom CSS', 'auxin-elements' ), |
| 81 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 82 | ) |
| 83 | ); |
| 84 | |
| 85 | $widget->add_control( |
| 86 | 'custom_css', |
| 87 | array( |
| 88 | 'type' => Controls_Manager::CODE, |
| 89 | 'label' => __( 'Custom CSS', 'auxin-elements' ), |
| 90 | 'label_block' => true, |
| 91 | 'language' => 'css' |
| 92 | ) |
| 93 | ); |
| 94 | ob_start();?> |
| 95 | <pre> |
| 96 | Examples: |
| 97 | // To target main element |
| 98 | selector { color: red; } |
| 99 | // For child element |
| 100 | selector .child-element{ margin: 10px; } |
| 101 | </pre> |
| 102 | <?php |
| 103 | $example = ob_get_clean(); |
| 104 | |
| 105 | $widget->add_control( |
| 106 | 'custom_css_description', |
| 107 | array( |
| 108 | 'raw' => __( 'Use "selector" keyword to target wrapper element.', 'auxin-elements' ). $example, |
| 109 | 'type' => Controls_Manager::RAW_HTML, |
| 110 | 'content_classes' => 'elementor-descriptor', |
| 111 | 'separator' => 'none' |
| 112 | ) |
| 113 | ); |
| 114 | |
| 115 | $widget->end_controls_section(); |
| 116 | } |
| 117 | |
| 118 | } |
| 119 | |
| 120 | |
| 121 | |
| 122 | /** |
| 123 | * Add controls to advanced section for adding background image to pseudo elements |
| 124 | * |
| 125 | * @return void |
| 126 | */ |
| 127 | public function add_pseudo_background_controls( $widget, $section_id, $args ){ |
| 128 | |
| 129 | $target_sections = array('section_custom_css'); |
| 130 | |
| 131 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 132 | $target_sections[] = 'section_custom_css_pro'; |
| 133 | } |
| 134 | |
| 135 | if( ! in_array( $section_id, $target_sections ) ){ |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | if( in_array( $widget->get_name(), array('section') ) ){ |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | // Adds general background options to pseudo elements |
| 144 | // --------------------------------------------------------------------- |
| 145 | $widget->start_controls_section( |
| 146 | 'aux_core_common_background_pseudo', |
| 147 | array( |
| 148 | 'label' => __( 'Pseudo Background (developers)', 'auxin-elements' ), |
| 149 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 150 | ) |
| 151 | ); |
| 152 | |
| 153 | $widget->add_control( |
| 154 | 'background_pseudo_description', |
| 155 | array( |
| 156 | 'raw' => __( 'Adds background to pseudo elements like ::before and ::after selectors. (developers only)', 'auxin-elements' ), |
| 157 | 'type' => Controls_Manager::RAW_HTML, |
| 158 | 'content_classes' => 'elementor-descriptor' |
| 159 | ) |
| 160 | ); |
| 161 | |
| 162 | $widget->add_control( |
| 163 | 'background_pseudo_before_heading', |
| 164 | array( |
| 165 | 'label' => __( 'Background ::before', 'auxin-elements' ), |
| 166 | 'type' => Controls_Manager::HEADING, |
| 167 | 'separator' => 'before' |
| 168 | ) |
| 169 | ); |
| 170 | |
| 171 | $widget->add_group_control( |
| 172 | Group_Control_Background::get_type(), |
| 173 | array( |
| 174 | 'name' => 'background_pseudo_before', |
| 175 | 'types' => array( 'classic', 'gradient'), |
| 176 | 'selector' => '{{WRAPPER}}:before' |
| 177 | ) |
| 178 | ); |
| 179 | |
| 180 | $widget->add_control( |
| 181 | 'background_pseudo_after_heading', |
| 182 | array( |
| 183 | 'label' => __( 'Background ::after', 'auxin-elements' ), |
| 184 | 'type' => Controls_Manager::HEADING, |
| 185 | 'separator' => 'before' |
| 186 | ) |
| 187 | ); |
| 188 | |
| 189 | $widget->add_group_control( |
| 190 | Group_Control_Background::get_type(), |
| 191 | array( |
| 192 | 'name' => 'background_pseudo_after', |
| 193 | 'types' => array( 'classic', 'gradient'), |
| 194 | 'selector' => '{{WRAPPER}}:after' |
| 195 | ) |
| 196 | ); |
| 197 | |
| 198 | $widget->end_controls_section(); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | /** |
| 203 | * Add parallax pro notice to advanced section |
| 204 | * |
| 205 | * @return void |
| 206 | */ |
| 207 | public function add_parallax_go_pro_notice( $widget, $section_id, $args ){ |
| 208 | |
| 209 | if( defined('THEME_PRO') && THEME_PRO ){ |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | if( in_array( $widget->get_name(), array('section') ) ){ |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | // Anchor element sections |
| 218 | $target_sections = array('section_custom_css'); |
| 219 | |
| 220 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 221 | $target_sections[] = 'section_custom_css_pro'; |
| 222 | } |
| 223 | |
| 224 | if( ! in_array( $section_id, $target_sections ) ){ |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | $widget->start_controls_section( |
| 229 | 'aux_pro_common_parallax_notice', |
| 230 | array( |
| 231 | 'label' => __( 'Parallax', 'auxin-elements' ), |
| 232 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 233 | ) |
| 234 | ); |
| 235 | |
| 236 | $widget->add_control( |
| 237 | 'parallax_go_pro_notice', |
| 238 | array( |
| 239 | 'type' => Controls_Manager::RAW_HTML, |
| 240 | 'content_classes' => 'elementor-descriptor', |
| 241 | 'raw' => '<div class="auxin-elementor-panel-notice">' . |
| 242 | '<i class="auxin-elementor-upgrade-notice-icon eicon-favorite" aria-hidden="true"></i> |
| 243 | <div class="auxin-elementor-panel-notice-title">' . |
| 244 | __( 'Parallax Effect', 'auxin-elements' ) . |
| 245 | '</div> |
| 246 | <div class="auxin-elementor-panel-notice-message">' . |
| 247 | __( 'Parallax options let you add parallax effect to any widget.', 'auxin-elements' ) . |
| 248 | '</div> |
| 249 | <div class="auxin-elementor-panel-notice-message">' . |
| 250 | __( 'This feature is only available on Phlox Pro.', 'auxin-elements' ) . |
| 251 | '</div> |
| 252 | <a class="auxin-elementor-panel-notice-link elementor-button elementor-button-default auxin-elementor-go-pro-link" href="http://phlox.pro/go-pro/?utm_source=elementor-panel&utm_medium=phlox-free&utm_campaign=phlox-go-pro&utm_content=parallax" target="_blank">' . |
| 253 | __( 'Get Phlox Pro', 'auxin-elements' ) . |
| 254 | '</a> |
| 255 | </div>' |
| 256 | ) |
| 257 | ); |
| 258 | |
| 259 | $widget->end_controls_section(); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | /** |
| 264 | * Add transition controls to advanced section |
| 265 | * |
| 266 | * @return void |
| 267 | */ |
| 268 | public function add_transition_controls_section( $widget, $section_id, $args ){ |
| 269 | |
| 270 | // Anchor element sections |
| 271 | $target_sections = array('section_custom_css'); |
| 272 | |
| 273 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 274 | $target_sections[] = 'section_custom_css_pro'; |
| 275 | } |
| 276 | |
| 277 | if( ! in_array( $section_id, $target_sections ) ){ |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | // Adds transition options to all elements |
| 282 | // --------------------------------------------------------------------- |
| 283 | $widget->start_controls_section( |
| 284 | 'aux_core_common_inview_transition', |
| 285 | array( |
| 286 | 'label' => __( 'Entrance Animation', 'auxin-elements' ), |
| 287 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 288 | ) |
| 289 | ); |
| 290 | |
| 291 | $widget->add_control( |
| 292 | 'aux_animation_name', |
| 293 | array( |
| 294 | 'label' => __( 'Animation', 'auxin-elements' ), |
| 295 | 'type' => Controls_Manager::SELECT, |
| 296 | 'options' => array( |
| 297 | '' => 'None', |
| 298 | |
| 299 | 'aux-fade-in' => 'Fade In', |
| 300 | 'aux-fade-in-down' => 'Fade In Down', |
| 301 | 'aux-fade-in-down-1' => 'Fade In Down 1', |
| 302 | 'aux-fade-in-down-2' => 'Fade In Down 2', |
| 303 | 'aux-fade-in-up' => 'Fade In Up', |
| 304 | 'aux-fade-in-up-1' => 'Fade In Up 1', |
| 305 | 'aux-fade-in-up-2' => 'Fade In Up 2', |
| 306 | 'aux-fade-in-left' => 'Fade In Left', |
| 307 | 'aux-fade-in-left-1' => 'Fade In Left 1', |
| 308 | 'aux-fade-in-left-2' => 'Fade In Left 2', |
| 309 | 'aux-fade-in-right' => 'Fade In Right', |
| 310 | 'aux-fade-in-right-1' => 'Fade In Right 1', |
| 311 | 'aux-fade-in-right-2' => 'Fade In Right 2', |
| 312 | |
| 313 | // Slide Animation |
| 314 | 'aux-slide-from-right' => 'Slide From Right', |
| 315 | 'aux-slide-from-left' => 'Slide From Left', |
| 316 | 'aux-slide-from-top' => 'Slide From Top', |
| 317 | 'aux-slide-from-bot' => 'Slide From Bottom', |
| 318 | |
| 319 | // Mask Animation |
| 320 | 'aux-mask-from-top' => 'Mask From Top', |
| 321 | 'aux-mask-from-bot' => 'Mask From Bottom', |
| 322 | 'aux-mask-from-left' => 'Mask From Left', |
| 323 | 'aux-mask-from-right' => 'Mask From Right', |
| 324 | |
| 325 | 'aux-rotate-in' => 'Rotate In', |
| 326 | 'aux-rotate-in-down-left' => 'Rotate In Down Left', |
| 327 | 'aux-rotate-in-down-left-1' => 'Rotate In Down Left 1', |
| 328 | 'aux-rotate-in-down-left-2' => 'Rotate In Down Left 2', |
| 329 | 'aux-rotate-in-down-right' => 'Rotate In Down Right', |
| 330 | 'aux-rotate-in-down-right-1' => 'Rotate In Down Right 1', |
| 331 | 'aux-rotate-in-down-right-2' => 'Rotate In Down Right 2', |
| 332 | 'aux-rotate-in-up-left' => 'Rotate In Up Left', |
| 333 | 'aux-rotate-in-up-left-1' => 'Rotate In Up Left 1', |
| 334 | 'aux-rotate-in-up-left-2' => 'Rotate In Up Left 2', |
| 335 | 'aux-rotate-in-up-right' => 'Rotate In Up Right', |
| 336 | 'aux-rotate-in-up-right-1' => 'Rotate In Up Right 1', |
| 337 | 'aux-rotate-in-up-right-2' => 'Rotate In Up Right 2', |
| 338 | |
| 339 | 'aux-zoom-in' => 'Zoom In', |
| 340 | 'aux-zoom-in-1' => 'Zoom In 1', |
| 341 | 'aux-zoom-in-2' => 'Zoom In 2', |
| 342 | 'aux-zoom-in-3' => 'Zoom In 3', |
| 343 | |
| 344 | 'aux-scale-up' => 'Scale Up', |
| 345 | 'aux-scale-up-1' => 'Scale Up 1', |
| 346 | 'aux-scale-up-2' => 'Scale Up 2', |
| 347 | |
| 348 | 'aux-scale-down' => 'Scale Down', |
| 349 | 'aux-scale-down-1' => 'Scale Down 1', |
| 350 | 'aux-scale-down-2' => 'Scale Down 2', |
| 351 | |
| 352 | 'aux-flip-in-down' => 'Flip In Down', |
| 353 | 'aux-flip-in-down-1' => 'Flip In Down 1', |
| 354 | 'aux-flip-in-down-2' => 'Flip In Down 2', |
| 355 | 'aux-flip-in-up' => 'Flip In Up', |
| 356 | 'aux-flip-in-up-1' => 'Flip In Up 1', |
| 357 | 'aux-flip-in-up-2' => 'Flip In Up 2', |
| 358 | 'aux-flip-in-left' => 'Flip In Left', |
| 359 | 'aux-flip-in-left-1' => 'Flip In Left 1', |
| 360 | 'aux-flip-in-left-2' => 'Flip In Left 2', |
| 361 | 'aux-flip-in-left-3' => 'Flip In Left 3', |
| 362 | 'aux-flip-in-right' => 'Flip In Right', |
| 363 | 'aux-flip-in-right-1' => 'Flip In Right 1', |
| 364 | 'aux-flip-in-right-2' => 'Flip In Right 2', |
| 365 | 'aux-flip-in-right-3' => 'Flip In Right 3', |
| 366 | |
| 367 | 'aux-pulse' => 'Pulse In 1' , |
| 368 | 'aux-pulse1' => 'Pulse In 2', |
| 369 | 'aux-pulse2' => 'Pulse In 3', |
| 370 | 'aux-pulse3' => 'Pulse In 4', |
| 371 | 'aux-pulse4' => 'Pulse In 5', |
| 372 | |
| 373 | 'aux-pulse-out-1' => 'Pulse Out 1' , |
| 374 | 'aux-pulse-out-2' => 'Pulse Out 2' , |
| 375 | 'aux-pulse-out-3' => 'Pulse Out 3' , |
| 376 | 'aux-pulse-out-4' => 'Pulse Out 4' , |
| 377 | |
| 378 | // Specials |
| 379 | 'aux-shake' => 'Shake', |
| 380 | 'aux-bounce-in' => 'Bounce In', |
| 381 | 'aux-jack-in-box' => 'Jack In the Box', |
| 382 | |
| 383 | |
| 384 | ), |
| 385 | 'default' => '', |
| 386 | 'prefix_class' => 'aux-appear-watch-animation ', |
| 387 | 'label_block' => false |
| 388 | ) |
| 389 | ); |
| 390 | |
| 391 | |
| 392 | $widget->add_control( |
| 393 | 'aux_animation_duration', |
| 394 | array( |
| 395 | 'label' => __( 'Duration', 'auxin-elements' ) . ' (ms)', |
| 396 | 'type' => Controls_Manager::NUMBER, |
| 397 | 'default' => '', |
| 398 | 'min' => 0, |
| 399 | 'step' => 100, |
| 400 | 'selectors' => array( |
| 401 | '{{WRAPPER}}' => 'animation-duration:{{SIZE}}ms;' |
| 402 | ), |
| 403 | 'condition' => array( |
| 404 | 'aux_animation_name!' => '' |
| 405 | ), |
| 406 | 'render_type' => 'template' |
| 407 | ) |
| 408 | ); |
| 409 | |
| 410 | $widget->add_control( |
| 411 | 'aux_animation_delay', |
| 412 | array( |
| 413 | 'label' => __( 'Delay', 'auxin-elements' ) . ' (ms)', |
| 414 | 'type' => Controls_Manager::NUMBER, |
| 415 | 'default' => '', |
| 416 | 'min' => 0, |
| 417 | 'step' => 100, |
| 418 | 'selectors' => array( |
| 419 | '{{WRAPPER}}' => 'animation-delay:{{SIZE}}ms;' |
| 420 | ), |
| 421 | 'condition' => array( |
| 422 | 'aux_animation_name!' => '' |
| 423 | ) |
| 424 | ) |
| 425 | ); |
| 426 | |
| 427 | $widget->add_control( |
| 428 | 'aux_animation_easing', |
| 429 | array( |
| 430 | 'label' => __( 'Easing', 'auxin-elements' ), |
| 431 | 'type' => Controls_Manager::SELECT, |
| 432 | 'options' => array( |
| 433 | '' => 'Default', |
| 434 | 'initial' => 'Initial', |
| 435 | |
| 436 | 'linear' => 'Linear', |
| 437 | 'ease-out' => 'Ease Out', |
| 438 | '0.19,1,0.22,1' => 'Ease In Out', |
| 439 | |
| 440 | '0.47,0,0.745,0.715' => 'Sine In', |
| 441 | '0.39,0.575,0.565,1' => 'Sine Out', |
| 442 | '0.445,0.05,0.55,0.95' => 'Sine In Out', |
| 443 | |
| 444 | '0.55,0.085,0.68,0.53' => 'Quad In', |
| 445 | '0.25,0.46,0.45,0.94' => 'Quad Out', |
| 446 | '0.455,0.03,0.515,0.955' => 'Quad In Out', |
| 447 | |
| 448 | '0.55,0.055,0.675,0.19' => 'Cubic In', |
| 449 | '0.215,0.61,0.355,1' => 'Cubic Out', |
| 450 | '0.645,0.045,0.355,1' => 'Cubic In Out', |
| 451 | |
| 452 | '0.895,0.03,0.685,0.22' => 'Quart In', |
| 453 | '0.165,0.84,0.44,1' => 'Quart Out', |
| 454 | '0.77,0,0.175,1' => 'Quart In Out', |
| 455 | |
| 456 | '0.895,0.03,0.685,0.22' => 'Quint In', |
| 457 | '0.895,0.03,0.685,0.22' => 'Quint Out', |
| 458 | '0.895,0.03,0.685,0.22' => 'Quint In Out', |
| 459 | |
| 460 | '0.95,0.05,0.795,0.035' => 'Expo In', |
| 461 | '0.19,1,0.22,1' => 'Expo Out', |
| 462 | '1,0,0,1' => 'Expo In Out', |
| 463 | |
| 464 | '0.6,0.04,0.98,0.335' => 'Circ In', |
| 465 | '0.075,0.82,0.165,1' => 'Circ Out', |
| 466 | '0.785,0.135,0.15,0.86' => 'Circ In Out', |
| 467 | |
| 468 | '0.6,-0.28,0.735,0.045' => 'Back In', |
| 469 | '0.175,0.885,0.32,1.275' => 'Back Out', |
| 470 | '0.68,-0.55,0.265,1.55' => 'Back In Out' |
| 471 | ), |
| 472 | 'selectors' => array( |
| 473 | '{{WRAPPER}}' => 'animation-timing-function:cubic-bezier({{VALUE}});' |
| 474 | ), |
| 475 | 'condition' => array( |
| 476 | 'aux_animation_name!' => '' |
| 477 | ), |
| 478 | 'default' => '', |
| 479 | 'return_value' => '' |
| 480 | ) |
| 481 | ); |
| 482 | |
| 483 | $widget->add_control( |
| 484 | 'aux_animation_count', |
| 485 | array( |
| 486 | 'label' => __( 'Repeat Count', 'auxin-elements' ), |
| 487 | 'type' => Controls_Manager::SELECT, |
| 488 | 'options' => array( |
| 489 | '' => __( 'Default', 'auxin-elements' ), |
| 490 | '1' => '1', |
| 491 | '2' => '2', |
| 492 | '3' => '3', |
| 493 | '4' => '4', |
| 494 | '5' => '5', |
| 495 | 'infinite' => __( 'Infinite', 'auxin-elements' ) |
| 496 | ), |
| 497 | 'selectors' => array( |
| 498 | '{{WRAPPER}}' => 'animation-iteration-count:{{VALUE}};opacity:1;' // opacity is required to prevent flick between repetitions |
| 499 | ), |
| 500 | 'condition' => array( |
| 501 | 'aux_animation_name!' => '' |
| 502 | ), |
| 503 | 'default' => '' |
| 504 | ) |
| 505 | ); |
| 506 | |
| 507 | $widget->end_controls_section(); |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Add extra controls for positioning to advanced section |
| 512 | * |
| 513 | * @return void |
| 514 | */ |
| 515 | public function add_position_controls_section( $widget, $section_id, $args ){ |
| 516 | |
| 517 | // Anchor element sections |
| 518 | $target_sections = array('section_custom_css'); |
| 519 | |
| 520 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 521 | $target_sections[] = 'section_custom_css_pro'; |
| 522 | } |
| 523 | |
| 524 | if( ! in_array( $section_id, $target_sections ) ){ |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | // Adds general positioning options |
| 529 | // --------------------------------------------------------------------- |
| 530 | $widget->start_controls_section( |
| 531 | 'aux_core_common_position', |
| 532 | array( |
| 533 | 'label' => __( 'Positioning', 'auxin-elements' ), |
| 534 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 535 | ) |
| 536 | ); |
| 537 | |
| 538 | $widget->add_responsive_control( |
| 539 | 'aux_position_type', |
| 540 | array( |
| 541 | 'label' => __( 'Position Type', 'auxin-elements' ), |
| 542 | 'label_block' => true, |
| 543 | 'type' => Controls_Manager::SELECT, |
| 544 | 'options' => array( |
| 545 | '' => __( 'Default', 'auxin-elements' ), |
| 546 | 'static' => __( 'Static', 'auxin-elements' ), |
| 547 | 'relative' => __( 'Relative', 'auxin-elements' ), |
| 548 | 'absolute' => __( 'Absolute', 'auxin-elements' ) |
| 549 | ), |
| 550 | 'default' => '', |
| 551 | 'selectors' => array( |
| 552 | '{{WRAPPER}}' => 'position:{{VALUE}};', |
| 553 | ) |
| 554 | ) |
| 555 | ); |
| 556 | |
| 557 | $widget->add_responsive_control( |
| 558 | 'aux_position_top', |
| 559 | array( |
| 560 | 'label' => __('Top','auxin-elements' ), |
| 561 | 'type' => Controls_Manager::SLIDER, |
| 562 | 'size_units' => array('px', 'em', '%'), |
| 563 | 'range' => array( |
| 564 | 'px' => array( |
| 565 | 'min' => -2000, |
| 566 | 'max' => 2000, |
| 567 | 'step' => 1 |
| 568 | ), |
| 569 | '%' => array( |
| 570 | 'min' => -100, |
| 571 | 'max' => 100, |
| 572 | 'step' => 1 |
| 573 | ), |
| 574 | 'em' => array( |
| 575 | 'min' => -150, |
| 576 | 'max' => 150, |
| 577 | 'step' => 1 |
| 578 | ) |
| 579 | ), |
| 580 | 'selectors' => array( |
| 581 | '{{WRAPPER}}' => 'top:{{SIZE}}{{UNIT}};' |
| 582 | ), |
| 583 | 'condition' => array( |
| 584 | 'aux_position_type' => array('relative', 'absolute') |
| 585 | ) |
| 586 | ) |
| 587 | ); |
| 588 | |
| 589 | $widget->add_responsive_control( |
| 590 | 'aux_position_right', |
| 591 | array( |
| 592 | 'label' => __('Right','auxin-elements' ), |
| 593 | 'type' => Controls_Manager::SLIDER, |
| 594 | 'size_units' => array('px', 'em', '%'), |
| 595 | 'range' => array( |
| 596 | 'px' => array( |
| 597 | 'min' => -2000, |
| 598 | 'max' => 2000, |
| 599 | 'step' => 1 |
| 600 | ), |
| 601 | '%' => array( |
| 602 | 'min' => -100, |
| 603 | 'max' => 100, |
| 604 | 'step' => 1 |
| 605 | ), |
| 606 | 'em' => array( |
| 607 | 'min' => -150, |
| 608 | 'max' => 150, |
| 609 | 'step' => 1 |
| 610 | ) |
| 611 | ), |
| 612 | 'selectors' => array( |
| 613 | '{{WRAPPER}}' => 'right:{{SIZE}}{{UNIT}};' |
| 614 | ), |
| 615 | 'condition' => array( |
| 616 | 'aux_position_type' => array('relative', 'absolute') |
| 617 | ), |
| 618 | 'return_value' => '' |
| 619 | ) |
| 620 | ); |
| 621 | |
| 622 | $widget->add_responsive_control( |
| 623 | 'aux_position_bottom', |
| 624 | array( |
| 625 | 'label' => __('Bottom','auxin-elements' ), |
| 626 | 'type' => Controls_Manager::SLIDER, |
| 627 | 'size_units' => array('px', 'em', '%'), |
| 628 | 'range' => array( |
| 629 | 'px' => array( |
| 630 | 'min' => -2000, |
| 631 | 'max' => 2000, |
| 632 | 'step' => 1 |
| 633 | ), |
| 634 | '%' => array( |
| 635 | 'min' => -100, |
| 636 | 'max' => 100, |
| 637 | 'step' => 1 |
| 638 | ), |
| 639 | 'em' => array( |
| 640 | 'min' => -150, |
| 641 | 'max' => 150, |
| 642 | 'step' => 1 |
| 643 | ) |
| 644 | ), |
| 645 | 'selectors' => array( |
| 646 | '{{WRAPPER}}' => 'bottom:{{SIZE}}{{UNIT}};' |
| 647 | ), |
| 648 | 'condition' => array( |
| 649 | 'aux_position_type' => array('relative', 'absolute') |
| 650 | ) |
| 651 | ) |
| 652 | ); |
| 653 | |
| 654 | $widget->add_responsive_control( |
| 655 | 'aux_position_left', |
| 656 | array( |
| 657 | 'label' => __('Left','auxin-elements' ), |
| 658 | 'type' => Controls_Manager::SLIDER, |
| 659 | 'size_units' => array('px', 'em', '%'), |
| 660 | 'range' => array( |
| 661 | 'px' => array( |
| 662 | 'min' => -2000, |
| 663 | 'max' => 2000, |
| 664 | 'step' => 1 |
| 665 | ), |
| 666 | '%' => array( |
| 667 | 'min' => -100, |
| 668 | 'max' => 100, |
| 669 | 'step' => 1 |
| 670 | ), |
| 671 | 'em' => array( |
| 672 | 'min' => -150, |
| 673 | 'max' => 150, |
| 674 | 'step' => 1 |
| 675 | ) |
| 676 | ), |
| 677 | 'selectors' => array( |
| 678 | '{{WRAPPER}}' => 'left:{{SIZE}}{{UNIT}};' |
| 679 | ), |
| 680 | 'condition' => array( |
| 681 | 'aux_position_type' => array('relative', 'absolute') |
| 682 | ) |
| 683 | ) |
| 684 | ); |
| 685 | |
| 686 | $widget->add_responsive_control( |
| 687 | 'aux_position_from_center', |
| 688 | array( |
| 689 | 'label' => __('From Center','auxin-elements' ), |
| 690 | 'description'=> __('Please avoid using "From Center" and "Left" options at the same time.','auxin-elements' ), |
| 691 | 'type' => Controls_Manager::SLIDER, |
| 692 | 'size_units' => array('px', 'em', '%'), |
| 693 | 'range' => array( |
| 694 | 'px' => array( |
| 695 | 'min' => -1000, |
| 696 | 'max' => 1000, |
| 697 | 'step' => 1 |
| 698 | ), |
| 699 | '%' => array( |
| 700 | 'min' => -100, |
| 701 | 'max' => 100, |
| 702 | 'step' => 1 |
| 703 | ), |
| 704 | 'em' => array( |
| 705 | 'min' => -150, |
| 706 | 'max' => 150, |
| 707 | 'step' => 1 |
| 708 | ) |
| 709 | ), |
| 710 | 'selectors' => array( |
| 711 | '{{WRAPPER}}' => 'left:calc( 50% + {{SIZE}}{{UNIT}} );' |
| 712 | ), |
| 713 | 'condition' => array( |
| 714 | 'aux_position_type' => array('relative', 'absolute') |
| 715 | ) |
| 716 | ) |
| 717 | ); |
| 718 | |
| 719 | $widget->end_controls_section(); |
| 720 | } |
| 721 | |
| 722 | |
| 723 | /** |
| 724 | * Add extra options to advanced section |
| 725 | * |
| 726 | * @return void |
| 727 | */ |
| 728 | public function add_extra_controls_section( $widget, $section_id, $args ){ |
| 729 | |
| 730 | // Anchor element sections |
| 731 | $target_sections = array('section_custom_css'); |
| 732 | |
| 733 | if( ! defined('ELEMENTOR_PRO_VERSION') ) { |
| 734 | $target_sections[] = 'section_custom_css_pro'; |
| 735 | } |
| 736 | |
| 737 | if( ! in_array( $section_id, $target_sections ) ){ |
| 738 | return; |
| 739 | } |
| 740 | |
| 741 | // Adds extra options |
| 742 | // --------------------------------------------------------------------- |
| 743 | $widget->start_controls_section( |
| 744 | 'aux_core_general_extra', |
| 745 | array( |
| 746 | 'label' => __( 'Dimensions (extra)', 'auxin-elements' ), |
| 747 | 'tab' => Controls_Manager::TAB_ADVANCED |
| 748 | ) |
| 749 | ); |
| 750 | |
| 751 | $widget->add_responsive_control( |
| 752 | 'aux_max_width', |
| 753 | [ |
| 754 | 'label' => __('Max Width','auxin-elements' ), |
| 755 | 'type' => Controls_Manager::SLIDER, |
| 756 | 'size_units' => ['px', 'em', '%', 'vw'], |
| 757 | 'range' => [ |
| 758 | 'px' => [ |
| 759 | 'min' => 0, |
| 760 | 'step' => 1 |
| 761 | ], |
| 762 | '%' => [ |
| 763 | 'min' => 0, |
| 764 | 'max' => 100, |
| 765 | 'step' => 1 |
| 766 | ], |
| 767 | 'em' => [ |
| 768 | 'min' => 0, |
| 769 | 'step' => 1 |
| 770 | ], |
| 771 | 'vw' => [ |
| 772 | 'min' => 0, |
| 773 | 'max' => 100, |
| 774 | 'step' => 1 |
| 775 | ] |
| 776 | ], |
| 777 | 'selectors' => [ |
| 778 | '{{WRAPPER}}' => 'max-width:{{SIZE}}{{UNIT}};' |
| 779 | ] |
| 780 | ] |
| 781 | ); |
| 782 | |
| 783 | $widget->add_responsive_control( |
| 784 | 'aux_max_height', |
| 785 | [ |
| 786 | 'label' => __('Max Height','auxin-elements' ), |
| 787 | 'type' => Controls_Manager::SLIDER, |
| 788 | 'size_units' => ['px', 'em', '%', 'vh'], |
| 789 | 'range' => [ |
| 790 | 'px' => [ |
| 791 | 'min' => 0, |
| 792 | 'step' => 1 |
| 793 | ], |
| 794 | '%' => [ |
| 795 | 'min' => 0, |
| 796 | 'max' => 100, |
| 797 | 'step' => 1 |
| 798 | ], |
| 799 | 'em' => [ |
| 800 | 'min' => 0, |
| 801 | 'step' => 1 |
| 802 | ], |
| 803 | 'vh' => [ |
| 804 | 'min' => 0, |
| 805 | 'max' => 100, |
| 806 | 'step' => 1 |
| 807 | ] |
| 808 | ], |
| 809 | 'selectors' => [ |
| 810 | '{{WRAPPER}}' => 'max-height:{{SIZE}}{{UNIT}};' |
| 811 | ], |
| 812 | 'separator' => 'after' |
| 813 | ] |
| 814 | ); |
| 815 | |
| 816 | $widget->add_responsive_control( |
| 817 | 'aux_min_width', |
| 818 | [ |
| 819 | 'label' => __('Min Width','auxin-elements' ), |
| 820 | 'type' => Controls_Manager::SLIDER, |
| 821 | 'size_units' => ['px', 'em', '%', 'vw'], |
| 822 | 'range' => [ |
| 823 | 'px' => [ |
| 824 | 'min' => 0, |
| 825 | 'step' => 1 |
| 826 | ], |
| 827 | '%' => [ |
| 828 | 'min' => 0, |
| 829 | 'max' => 100, |
| 830 | 'step' => 1 |
| 831 | ], |
| 832 | 'em' => [ |
| 833 | 'min' => 0, |
| 834 | 'step' => 1 |
| 835 | ], |
| 836 | 'vw' => [ |
| 837 | 'min' => 0, |
| 838 | 'max' => 100, |
| 839 | 'step' => 1 |
| 840 | ] |
| 841 | ], |
| 842 | 'selectors' => [ |
| 843 | '{{WRAPPER}}' => 'min-width:{{SIZE}}{{UNIT}};' |
| 844 | ] |
| 845 | ] |
| 846 | ); |
| 847 | |
| 848 | $widget->add_responsive_control( |
| 849 | 'aux_min_height', |
| 850 | [ |
| 851 | 'label' => __('Min Height','auxin-elements' ), |
| 852 | 'type' => Controls_Manager::SLIDER, |
| 853 | 'size_units' => ['px', 'em', '%', 'vh'], |
| 854 | 'range' => [ |
| 855 | 'px' => [ |
| 856 | 'min' => 0, |
| 857 | 'step' => 1 |
| 858 | ], |
| 859 | '%' => [ |
| 860 | 'min' => 0, |
| 861 | 'max' => 100, |
| 862 | 'step' => 1 |
| 863 | ], |
| 864 | 'em' => [ |
| 865 | 'min' => 0, |
| 866 | 'step' => 1 |
| 867 | ], |
| 868 | 'vh' => [ |
| 869 | 'min' => 0, |
| 870 | 'max' => 100, |
| 871 | 'step' => 1 |
| 872 | ] |
| 873 | ], |
| 874 | 'selectors' => [ |
| 875 | '{{WRAPPER}}' => 'min-height:{{SIZE}}{{UNIT}};' |
| 876 | ], |
| 877 | 'separator' => 'after' |
| 878 | ] |
| 879 | ); |
| 880 | |
| 881 | $widget->add_responsive_control( |
| 882 | 'aux_height', |
| 883 | [ |
| 884 | 'label' => __('Height','auxin-elements' ), |
| 885 | 'type' => Controls_Manager::SLIDER, |
| 886 | 'size_units' => ['px', 'em', '%', 'vh'], |
| 887 | 'range' => [ |
| 888 | 'px' => [ |
| 889 | 'min' => 0, |
| 890 | 'step' => 1 |
| 891 | ], |
| 892 | '%' => [ |
| 893 | 'min' => 0, |
| 894 | 'max' => 100, |
| 895 | 'step' => 1 |
| 896 | ], |
| 897 | 'em' => [ |
| 898 | 'min' => 0, |
| 899 | 'step' => 1 |
| 900 | ], |
| 901 | 'vh' => [ |
| 902 | 'min' => 0, |
| 903 | 'max' => 100, |
| 904 | 'step' => 1 |
| 905 | ] |
| 906 | ], |
| 907 | 'selectors' => [ |
| 908 | '{{WRAPPER}}' => 'height:{{SIZE}}{{UNIT}};' |
| 909 | ] |
| 910 | ] |
| 911 | ); |
| 912 | |
| 913 | $widget->add_responsive_control( |
| 914 | 'flex_grow', |
| 915 | [ |
| 916 | 'label' => __( 'Grow in width', 'auxin-elements' ), |
| 917 | 'label_block' => false, |
| 918 | 'type' => Controls_Manager::NUMBER, |
| 919 | 'min' => 0, |
| 920 | 'selectors' => [ |
| 921 | '{{WRAPPER}}' => 'flex-grow: {{VALUE}};' |
| 922 | ], |
| 923 | 'separator' => 'before' |
| 924 | ] |
| 925 | ); |
| 926 | |
| 927 | $widget->end_controls_section(); |
| 928 | } |
| 929 | |
| 930 | |
| 931 | /** |
| 932 | * Modify the render of elementor elements |
| 933 | * |
| 934 | * @param Widget_Base $widget Instance of Elementor Widget |
| 935 | * |
| 936 | * @return void |
| 937 | */ |
| 938 | public function render_widget_attributes( $widget ){ |
| 939 | $settings = $widget->get_settings(); |
| 940 | } |
| 941 | |
| 942 | |
| 943 | /** |
| 944 | * Retrives the setting value or checkes whether the setting value |
| 945 | * mathes with a value or not |
| 946 | * |
| 947 | * @param array $settings Settings in an array |
| 948 | * @param string $key The setting key |
| 949 | * @param string $value An optional value to compare with the setting value |
| 950 | * |
| 951 | * @return mixed Setting value or a boolean value |
| 952 | */ |
| 953 | private function setting_value( $settings, $key, $value = null ){ |
| 954 | if( ! isset( $settings[ $key ] ) ){ |
| 955 | return; |
| 956 | } |
| 957 | // Retrieves the setting value |
| 958 | if( is_null( $value ) ){ |
| 959 | return $settings[ $key ]; |
| 960 | } |
| 961 | // Validates the setting value |
| 962 | return ! empty( $settings[ $key ] ) && $value == $settings[ $key ]; |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Render Custom CSS for an Elementor Element |
| 967 | * |
| 968 | * @param $post_css Post_CSS_File |
| 969 | * @param $element Element_Base |
| 970 | */ |
| 971 | public function add_post_css( $post_css, $element ) { |
| 972 | $element_settings = $element->get_settings(); |
| 973 | |
| 974 | if ( empty( $element_settings['custom_css'] ) ) { |
| 975 | return; |
| 976 | } |
| 977 | |
| 978 | $css = trim( $element_settings['custom_css'] ); |
| 979 | |
| 980 | if ( empty( $css ) ) { |
| 981 | return; |
| 982 | } |
| 983 | $css = str_replace( 'selector', $post_css->get_element_unique_selector( $element ), $css ); |
| 984 | |
| 985 | // Add a css comment |
| 986 | $css = sprintf( '/* Start custom CSS for %s, class: %s */', $element->get_name(), $element->get_unique_selector() ) . $css . '/* End custom CSS */'; |
| 987 | |
| 988 | $post_css->get_stylesheet()->add_raw_css( $css ); |
| 989 | } |
| 990 | |
| 991 | } |
| 992 |