breadcrumbs.php
1 year ago
copyright.php
1 year ago
current-time.php
1 year ago
logo.php
1 year ago
menu.php
1 year ago
modern-search.php
1 year ago
search.php
1 year ago
select.php
1 year ago
shopping-cart.php
1 year ago
site-title.php
1 year ago
breadcrumbs.php
557 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements; |
| 3 | |
| 4 | use Elementor\Widget_Base; |
| 5 | use Elementor\Controls_Manager; |
| 6 | use Elementor\Group_Control_Typography; |
| 7 | use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 | use Elementor\Group_Control_Border; |
| 10 | use Elementor\Group_Control_Background; |
| 11 | use Elementor\Group_Control_Box_Shadow; |
| 12 | use Elementor\Group_Control_Text_Shadow; |
| 13 | |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; // Exit if accessed directly. |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Elementor 'Breadcrumbs' widget. |
| 21 | * |
| 22 | * Elementor widget that displays an 'PostTitle'. |
| 23 | * |
| 24 | * @since 1.0.0 |
| 25 | */ |
| 26 | class Breadcrumbs extends Widget_Base { |
| 27 | |
| 28 | /** |
| 29 | * Get widget name. |
| 30 | * |
| 31 | * Retrieve 'Breadcrumbs' widget name. |
| 32 | * |
| 33 | * @since 1.0.0 |
| 34 | * @access public |
| 35 | * |
| 36 | * @return string Widget name. |
| 37 | */ |
| 38 | public function get_name() { |
| 39 | return 'aux_breadcrumbs'; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get widget title. |
| 44 | * |
| 45 | * Retrieve 'Breadcrumbs' widget title. |
| 46 | * |
| 47 | * @since 1.0.0 |
| 48 | * @access public |
| 49 | * |
| 50 | * @return string Widget title. |
| 51 | */ |
| 52 | public function get_title() { |
| 53 | return __( 'Breadcrumbs', 'auxin-elements' ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get widget icon. |
| 58 | * |
| 59 | * Retrieve 'Breadcrumbs' widget icon. |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | * @access public |
| 63 | * |
| 64 | * @return string Widget icon. |
| 65 | */ |
| 66 | public function get_icon() { |
| 67 | return 'eicon-product-breadcrumbs auxin-badge'; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get widget categories. |
| 72 | * |
| 73 | * Retrieve 'Breadcrumbs' widget icon. |
| 74 | * |
| 75 | * @since 1.0.0 |
| 76 | * @access public |
| 77 | * |
| 78 | * @return string Widget icon. |
| 79 | */ |
| 80 | public function get_categories() { |
| 81 | return array( 'auxin-core', 'auxin-theme-elements-single' ); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | private function is_yoast_breadcrumbs_enabled(){ |
| 86 | |
| 87 | $is_enabled = false; |
| 88 | |
| 89 | if ( function_exists( 'yoast_breadcrumb' ) ) { |
| 90 | if ( ! $is_enabled = current_theme_supports( 'yoast-seo-breadcrumbs' ) ) { |
| 91 | $options = get_option( 'wpseo_titles' ); |
| 92 | $is_enabled = isset( $options['breadcrumbs-enable'] ) && ( $options['breadcrumbs-enable'] === true ); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return $is_enabled; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Register 'Breadcrumbs' widget controls. |
| 101 | * |
| 102 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 103 | * |
| 104 | * @since 1.0.0 |
| 105 | * @access protected |
| 106 | */ |
| 107 | protected function register_controls() { |
| 108 | |
| 109 | /*--------------------------------------------------------------------*/ |
| 110 | /* Content |
| 111 | /*--------------------------------------------------------------------*/ |
| 112 | |
| 113 | $this->start_controls_section( |
| 114 | 'section_breadcrumb', |
| 115 | [ |
| 116 | 'label' => __( 'General', 'auxin-elements' ), |
| 117 | ] |
| 118 | ); |
| 119 | |
| 120 | if ( ! $yoast_breadcrumbs_enabled = $this->is_yoast_breadcrumbs_enabled() ) { |
| 121 | |
| 122 | $this->add_control( |
| 123 | 'show_home_icon', |
| 124 | array( |
| 125 | 'label' => __('Show home icon','auxin-elements' ), |
| 126 | 'description' => __('Show icon instead of text for home', 'auxin-elements' ), |
| 127 | 'type' => Controls_Manager::SWITCHER, |
| 128 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 129 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 130 | 'return_value' => 'yes', |
| 131 | 'default' => '' |
| 132 | ) |
| 133 | ); |
| 134 | |
| 135 | $this->add_control( |
| 136 | 'home_icon', |
| 137 | [ |
| 138 | 'label' => __( 'Custom Seperator Icon', 'auxin-elements' ), |
| 139 | 'label_block' => true, |
| 140 | 'type' => Controls_Manager::ICONS, |
| 141 | 'recommended' => [ |
| 142 | 'fa-solid' => [ |
| 143 | 'home' |
| 144 | ], |
| 145 | ], |
| 146 | 'exclude_inline_options' => [ 'svg' ], |
| 147 | 'default' => [ |
| 148 | 'value' => 'auxicon-home-house-streamline', |
| 149 | 'library' => 'auxicon' |
| 150 | ], |
| 151 | 'condition' => [ |
| 152 | 'show_home_icon' => 'yes' |
| 153 | ] |
| 154 | ] |
| 155 | ); |
| 156 | |
| 157 | $this->add_control( |
| 158 | 'separator_icon', |
| 159 | [ |
| 160 | 'label' => __( 'Custom Separator', 'auxin-elements' ), |
| 161 | 'label_block' => true, |
| 162 | 'type' => Controls_Manager::ICONS, |
| 163 | 'separator' => 'before' |
| 164 | ] |
| 165 | ); |
| 166 | |
| 167 | } else { |
| 168 | $this->add_control( |
| 169 | 'yoast_is_enabled_notice', |
| 170 | [ |
| 171 | 'type' => Controls_Manager::RAW_HTML, |
| 172 | 'raw' => __( 'Note: Breadcrumb is using "Yoast SEO" plugin. You can change the options from plugin setting page.', 'auxin-elements' ), |
| 173 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-danger', |
| 174 | ] |
| 175 | ); |
| 176 | } |
| 177 | |
| 178 | $this->end_controls_section(); |
| 179 | |
| 180 | |
| 181 | /*----------------------------------------------------------------*/ |
| 182 | /* Style |
| 183 | /*----------------------------------------------------------------*/ |
| 184 | |
| 185 | if ( ! $yoast_breadcrumbs_enabled ) { |
| 186 | |
| 187 | $this->start_controls_section( |
| 188 | 'home_icon_style_section', |
| 189 | [ |
| 190 | 'label' => __( 'Home Icon', 'auxin-elements' ), |
| 191 | 'tab' => Controls_Manager::TAB_STYLE, |
| 192 | 'condition' => [ |
| 193 | 'show_home_icon' => 'yes' |
| 194 | ] |
| 195 | ] |
| 196 | ); |
| 197 | |
| 198 | $this->add_responsive_control( |
| 199 | 'home_icon_position', |
| 200 | [ |
| 201 | 'label' => __( 'Position', 'auxin-elements' ), |
| 202 | 'type' => Controls_Manager::DIMENSIONS, |
| 203 | 'allowed_dimensions' => 'vertical', |
| 204 | 'size_units' => [ 'px', '%', 'em' ], |
| 205 | 'selectors' => [ |
| 206 | '{{WRAPPER}} .aux-breadcrumb-home' => 'position:relative; top: {{TOP}}{{UNIT}}; bottom:{{BOTTOM}}{{UNIT}};' |
| 207 | ] |
| 208 | ] |
| 209 | ); |
| 210 | |
| 211 | $this->add_responsive_control( |
| 212 | 'home_icon_margin', |
| 213 | [ |
| 214 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 215 | 'type' => Controls_Manager::DIMENSIONS, |
| 216 | 'allowed_dimensions' => 'horizontal', |
| 217 | 'size_units' => [ 'px', '%', 'em' ], |
| 218 | 'selectors' => [ |
| 219 | '{{WRAPPER}} .aux-breadcrumb-home' => 'margin: auto {{RIGHT}}{{UNIT}} auto {{LEFT}}{{UNIT}};' |
| 220 | ] |
| 221 | ] |
| 222 | ); |
| 223 | |
| 224 | $this->add_control( |
| 225 | 'home_icon_color', |
| 226 | [ |
| 227 | 'label' => __( 'Icon Color', 'auxin-elements' ), |
| 228 | 'type' => Controls_Manager::COLOR, |
| 229 | 'global' => [ |
| 230 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 231 | ], |
| 232 | 'selectors' => [ |
| 233 | '{{WRAPPER}} span.aux-breadcrumb-home' => 'color: {{VALUE}}; fill: {{VALUE}};', |
| 234 | ] |
| 235 | ] |
| 236 | ); |
| 237 | |
| 238 | $this->add_responsive_control( |
| 239 | 'home_icon_size', |
| 240 | [ |
| 241 | 'label' => __( 'Size', 'auxin-elements' ), |
| 242 | 'type' => Controls_Manager::SLIDER, |
| 243 | 'size_units' => [ 'px', '%', 'em' ], |
| 244 | 'selectors' => [ |
| 245 | '{{WRAPPER}} .aux-breadcrumb-home' => 'font-size:{{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};' |
| 246 | ] |
| 247 | ] |
| 248 | ); |
| 249 | |
| 250 | $this->end_controls_section(); |
| 251 | } |
| 252 | |
| 253 | /*--------------------------------------------------------------------*/ |
| 254 | /* Text style |
| 255 | /*--------------------------------------------------------------------*/ |
| 256 | |
| 257 | $this->start_controls_section( |
| 258 | 'text_style_section', |
| 259 | [ |
| 260 | 'label' => __( 'Text', 'auxin-elements' ), |
| 261 | 'tab' => Controls_Manager::TAB_STYLE, |
| 262 | ] |
| 263 | ); |
| 264 | |
| 265 | $this->add_control( |
| 266 | 'link_color', |
| 267 | [ |
| 268 | 'label' => __( 'Link Color', 'auxin-elements' ), |
| 269 | 'type' => Controls_Manager::COLOR, |
| 270 | 'global' => [ |
| 271 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 272 | ], |
| 273 | 'selectors' => [ |
| 274 | '{{WRAPPER}} span:not(.aux-breadcrumb-sep) a' => 'color: {{VALUE}};', |
| 275 | ], |
| 276 | ] |
| 277 | ); |
| 278 | |
| 279 | $this->add_control( |
| 280 | 'link_hover_color', |
| 281 | [ |
| 282 | 'label' => __( 'Link Hover Color', 'auxin-elements' ), |
| 283 | 'type' => Controls_Manager::COLOR, |
| 284 | 'global' => [ |
| 285 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 286 | ], |
| 287 | 'selectors' => [ |
| 288 | '{{WRAPPER}} span:not(.aux-breadcrumb-sep) a:hover' => 'color: {{VALUE}};', |
| 289 | ], |
| 290 | ] |
| 291 | ); |
| 292 | |
| 293 | $this->add_control( |
| 294 | 'text_color', |
| 295 | [ |
| 296 | 'label' => __( 'Text Color', 'auxin-elements' ), |
| 297 | 'type' => Controls_Manager::COLOR, |
| 298 | 'global' => [ |
| 299 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 300 | ], |
| 301 | 'selectors' => [ |
| 302 | '{{WRAPPER}} span:not(.aux-breadcrumb-sep)' => 'color: {{VALUE}};', |
| 303 | ], |
| 304 | ] |
| 305 | ); |
| 306 | |
| 307 | $this->add_group_control( |
| 308 | Group_Control_Typography::get_type(), |
| 309 | [ |
| 310 | 'name' => 'typography', |
| 311 | 'global' => [ |
| 312 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 313 | ], |
| 314 | 'selector' => '{{WRAPPER}} span' |
| 315 | ] |
| 316 | ); |
| 317 | |
| 318 | $this->add_group_control( |
| 319 | Group_Control_Text_Shadow::get_type(), |
| 320 | [ |
| 321 | 'name' => 'text_shadow', |
| 322 | 'selector' => '{{WRAPPER}} span' |
| 323 | ] |
| 324 | ); |
| 325 | |
| 326 | $this->end_controls_section(); |
| 327 | |
| 328 | /*--------------------------------------------------------------------*/ |
| 329 | /* Separator |
| 330 | /*--------------------------------------------------------------------*/ |
| 331 | |
| 332 | if ( ! $yoast_breadcrumbs_enabled ) { |
| 333 | |
| 334 | $this->start_controls_section( |
| 335 | 'separator_style_section', |
| 336 | [ |
| 337 | 'label' => __( 'Separator', 'auxin-elements' ), |
| 338 | 'tab' => Controls_Manager::TAB_STYLE, |
| 339 | ] |
| 340 | ); |
| 341 | |
| 342 | $this->add_responsive_control( |
| 343 | 'separator_margin', |
| 344 | [ |
| 345 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 346 | 'type' => Controls_Manager::DIMENSIONS, |
| 347 | 'size_units' => [ 'px', '%', 'em' ], |
| 348 | 'selectors' => [ |
| 349 | '{{WRAPPER}} .aux-breadcrumb-sep' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 350 | ] |
| 351 | ] |
| 352 | ); |
| 353 | |
| 354 | $this->add_control( |
| 355 | 'separator_icon_color', |
| 356 | [ |
| 357 | 'label' => __( 'Icon Color', 'auxin-elements' ), |
| 358 | 'type' => Controls_Manager::COLOR, |
| 359 | 'global' => [ |
| 360 | 'default' => Global_Colors::COLOR_PRIMARY, |
| 361 | ], |
| 362 | 'selectors' => [ |
| 363 | '{{WRAPPER}} span.aux-breadcrumb-sep' => 'color: {{VALUE}};fill: {{VALUE}};', |
| 364 | ] |
| 365 | ] |
| 366 | ); |
| 367 | |
| 368 | $this->add_responsive_control( |
| 369 | 'separator_size', |
| 370 | [ |
| 371 | 'label' => __( 'Size', 'auxin-elements' ), |
| 372 | 'type' => Controls_Manager::SLIDER, |
| 373 | 'size_units' => [ 'px', '%', 'em' ], |
| 374 | 'selectors' => [ |
| 375 | '{{WRAPPER}} .aux-breadcrumb-sep' => 'font-size:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};' |
| 376 | ] |
| 377 | ] |
| 378 | ); |
| 379 | |
| 380 | $this->end_controls_section(); |
| 381 | } |
| 382 | |
| 383 | /*--------------------------------------------------------------------*/ |
| 384 | /* Container |
| 385 | /*--------------------------------------------------------------------*/ |
| 386 | |
| 387 | $this->start_controls_section( |
| 388 | 'container_style_section', |
| 389 | [ |
| 390 | 'label' => __( 'Container', 'auxin-elements' ), |
| 391 | 'tab' => Controls_Manager::TAB_STYLE, |
| 392 | ] |
| 393 | ); |
| 394 | |
| 395 | $this->add_responsive_control( |
| 396 | 'container_alignment', |
| 397 | [ |
| 398 | 'label' => __('Alignment','auxin-elements' ), |
| 399 | 'type' => Controls_Manager::CHOOSE, |
| 400 | 'options' => [ |
| 401 | 'left' => [ |
| 402 | 'title' => __( 'Left', 'auxin-elements' ), |
| 403 | 'icon' => 'eicon-text-align-left' |
| 404 | ], |
| 405 | 'center' => [ |
| 406 | 'title' => __( 'Center', 'auxin-elements' ), |
| 407 | 'icon' => 'eicon-text-align-center' |
| 408 | ], |
| 409 | 'right' => [ |
| 410 | 'title' => __( 'Right', 'auxin-elements' ), |
| 411 | 'icon' => 'eicon-text-align-right' |
| 412 | ] |
| 413 | ], |
| 414 | 'default' => '', |
| 415 | 'separator' => 'after', |
| 416 | 'toggle' => true, |
| 417 | 'selectors' => [ |
| 418 | '{{WRAPPER}} .aux-elementor-breadcrumbs' => 'text-align:{{VALUE}};' |
| 419 | ] |
| 420 | ] |
| 421 | ); |
| 422 | |
| 423 | $this->add_group_control( |
| 424 | Group_Control_Border::get_type(), |
| 425 | [ |
| 426 | 'name' => 'container_border', |
| 427 | 'selector' => '{{WRAPPER}} .aux-breadcrumbs' |
| 428 | ] |
| 429 | ); |
| 430 | |
| 431 | $this->add_responsive_control( |
| 432 | 'container_border_radius', |
| 433 | [ |
| 434 | 'label' => __( 'Border Radius', 'auxin-elements' ), |
| 435 | 'type' => Controls_Manager::DIMENSIONS, |
| 436 | 'size_units' => [ 'px', '%' ], |
| 437 | 'selectors' => [ |
| 438 | '{{WRAPPER}} p.aux-breadcrumbs' => 'border-radius:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 439 | ] |
| 440 | ] |
| 441 | ); |
| 442 | |
| 443 | $this->add_responsive_control( |
| 444 | 'container_padding', |
| 445 | [ |
| 446 | 'label' => __( 'Padding', 'auxin-elements' ), |
| 447 | 'type' => Controls_Manager::DIMENSIONS, |
| 448 | 'size_units' => [ 'px', '%', 'em' ], |
| 449 | 'selectors' => [ |
| 450 | '{{WRAPPER}} p.aux-breadcrumbs' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 451 | ], |
| 452 | 'separator' => 'after' |
| 453 | ] |
| 454 | ); |
| 455 | |
| 456 | $this->start_controls_tabs( 'container_style_tabs' ); |
| 457 | |
| 458 | $this->start_controls_tab( |
| 459 | 'container_tab_normal_state', |
| 460 | [ |
| 461 | 'label' => __( 'Normal', 'auxin-elements' ), |
| 462 | ] |
| 463 | ); |
| 464 | |
| 465 | $this->add_group_control( |
| 466 | Group_Control_Background::get_type(), |
| 467 | [ |
| 468 | 'name' => 'container_background', |
| 469 | 'selector' => '{{WRAPPER}} p.aux-breadcrumbs', |
| 470 | 'types' => [ 'classic', 'gradient'] |
| 471 | ] |
| 472 | ); |
| 473 | |
| 474 | $this->add_group_control( |
| 475 | Group_Control_Box_Shadow::get_type(), |
| 476 | [ |
| 477 | 'name' => 'container_box_shadow', |
| 478 | 'selector' => '{{WRAPPER}} p.aux-breadcrumbs' |
| 479 | ] |
| 480 | ); |
| 481 | |
| 482 | $this->end_controls_tab(); |
| 483 | |
| 484 | $this->start_controls_tab( |
| 485 | 'container_tab_hover_state', |
| 486 | [ |
| 487 | 'label' => __( 'Hover', 'auxin-elements' ), |
| 488 | ] |
| 489 | ); |
| 490 | |
| 491 | $this->add_group_control( |
| 492 | Group_Control_Background::get_type(), |
| 493 | [ |
| 494 | 'name' => 'container_background_hover', |
| 495 | 'selector' => '{{WRAPPER}} p.aux-breadcrumbs:hover', |
| 496 | 'types' => [ 'classic', 'gradient'] |
| 497 | ] |
| 498 | ); |
| 499 | |
| 500 | $this->add_group_control( |
| 501 | Group_Control_Box_Shadow::get_type(), |
| 502 | [ |
| 503 | 'name' => 'container_box_shadow_hover', |
| 504 | 'selector' => '{{WRAPPER}} p.aux-breadcrumbs:hover' |
| 505 | ] |
| 506 | ); |
| 507 | |
| 508 | $this->add_control( |
| 509 | 'container_transition', |
| 510 | [ |
| 511 | 'label' => __( 'Transition Duration', 'auxin-elements' ), |
| 512 | 'type' => Controls_Manager::SLIDER, |
| 513 | 'default' => [ |
| 514 | 'size' => 0.3, |
| 515 | ], |
| 516 | 'range' => [ |
| 517 | 'px' => [ |
| 518 | 'max' => 3, |
| 519 | 'step' => 0.1, |
| 520 | ], |
| 521 | ], |
| 522 | 'render_type' => 'ui', |
| 523 | 'selectors' => [ |
| 524 | '{{WRAPPER}} p.aux-breadcrumbs' => "transition:all ease-out {{SIZE}}s;" |
| 525 | ] |
| 526 | ] |
| 527 | ); |
| 528 | |
| 529 | $this->end_controls_tab(); |
| 530 | |
| 531 | $this->end_controls_tabs(); |
| 532 | // Background and Box Shadow for input - END |
| 533 | |
| 534 | $this->end_controls_section(); |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * Render image box widget output on the frontend. |
| 539 | * |
| 540 | * Written in PHP and used to generate the final HTML. |
| 541 | * |
| 542 | * @since 1.0.0 |
| 543 | * @access protected |
| 544 | */ |
| 545 | protected function render() { |
| 546 | $settings = $this->get_settings_for_display(); |
| 547 | |
| 548 | $home_icon = isset( $settings['show_home_icon'] ) && auxin_is_true( $settings['show_home_icon'] ) ? $settings['home_icon'] : ''; |
| 549 | $separator_icon = isset( $settings['separator_icon']['value'] ) ? $settings['separator_icon'] : ''; |
| 550 | |
| 551 | echo '<div class="aux-elementor-breadcrumbs">'; |
| 552 | auxin_the_breadcrumbs( $home_icon, $separator_icon ); |
| 553 | echo '</div>'; |
| 554 | } |
| 555 | |
| 556 | } |
| 557 |