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