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
site-title.php
530 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Elements\Theme_Elements; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Widget_Base; |
| 6 | use Elementor\Controls_Manager; |
| 7 | use Elementor\Group_Control_Typography; |
| 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 9 | use Elementor\Group_Control_Text_Shadow; |
| 10 | |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Elementor 'SiteTitle' widget. |
| 18 | * |
| 19 | * Elementor widget that displays an 'SiteTitle'. |
| 20 | * |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | class SiteTitle extends Widget_Base { |
| 24 | |
| 25 | /** |
| 26 | * Get widget name. |
| 27 | * |
| 28 | * Retrieve 'SiteTitle' widget name. |
| 29 | * |
| 30 | * @since 1.0.0 |
| 31 | * @access public |
| 32 | * |
| 33 | * @return string Widget name. |
| 34 | */ |
| 35 | public function get_name() { |
| 36 | return 'aux_site_title'; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get widget title. |
| 41 | * |
| 42 | * Retrieve 'SiteTitle' widget title. |
| 43 | * |
| 44 | * @since 1.0.0 |
| 45 | * @access public |
| 46 | * |
| 47 | * @return string Widget title. |
| 48 | */ |
| 49 | public function get_title() { |
| 50 | return __('Site Title', 'auxin-elements' ); |
| 51 | } |
| 52 | |
| 53 | public function has_widget_inner_wrapper(): bool { |
| 54 | return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * Get widget icon. |
| 60 | * |
| 61 | * Retrieve 'SiteTitle' widget icon. |
| 62 | * |
| 63 | * @since 1.0.0 |
| 64 | * @access public |
| 65 | * |
| 66 | * @return string Widget icon. |
| 67 | */ |
| 68 | public function get_icon() { |
| 69 | return 'eicon-site-title auxin-badge'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get widget categories. |
| 74 | * |
| 75 | * Retrieve 'SiteTitle' widget icon. |
| 76 | * |
| 77 | * @since 1.0.0 |
| 78 | * @access public |
| 79 | * |
| 80 | * @return string Widget icon. |
| 81 | */ |
| 82 | public function get_categories() { |
| 83 | return array( 'auxin-core', 'auxin-theme-elements' ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Register 'SiteTitle' widget controls. |
| 88 | * |
| 89 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 90 | * |
| 91 | * @since 1.0.0 |
| 92 | * @access protected |
| 93 | */ |
| 94 | protected function register_controls() { |
| 95 | |
| 96 | $this->start_controls_section( |
| 97 | 'title_section', |
| 98 | array( |
| 99 | 'label' => __('Title', 'auxin-elements' ), |
| 100 | ) |
| 101 | ); |
| 102 | |
| 103 | $this->add_control( |
| 104 | 'title_tag', |
| 105 | array( |
| 106 | 'label' => __( 'Site Title HTML Tag', 'auxin-elements' ), |
| 107 | 'type' => Controls_Manager::SELECT, |
| 108 | 'options' => array( |
| 109 | 'h1' => 'H1', |
| 110 | 'h2' => 'H2', |
| 111 | 'h3' => 'H3', |
| 112 | 'h4' => 'H4', |
| 113 | 'h5' => 'H5', |
| 114 | 'h6' => 'H6', |
| 115 | 'div' => 'Div', |
| 116 | 'span' => 'Span', |
| 117 | 'p' => 'P', |
| 118 | ), |
| 119 | 'default' => 'h1', |
| 120 | 'separator' => 'after' |
| 121 | ) |
| 122 | ); |
| 123 | |
| 124 | $this->add_control( |
| 125 | 'title_before', |
| 126 | array( |
| 127 | 'label' => __( 'Before Title', 'auxin-elements' ), |
| 128 | 'type' => Controls_Manager::TEXT, |
| 129 | 'default' => '', |
| 130 | 'label_block' => true |
| 131 | ) |
| 132 | ); |
| 133 | |
| 134 | $this->add_control( |
| 135 | 'title_before_tag', |
| 136 | array( |
| 137 | 'label' => __( 'Before Title HTML Tag', 'auxin-elements' ), |
| 138 | 'type' => Controls_Manager::SELECT, |
| 139 | 'options' => array( |
| 140 | 'h1' => 'H1', |
| 141 | 'h2' => 'H2', |
| 142 | 'h3' => 'H3', |
| 143 | 'h4' => 'H4', |
| 144 | 'h5' => 'H5', |
| 145 | 'h6' => 'H6', |
| 146 | 'div' => 'Div', |
| 147 | 'span' => 'Span', |
| 148 | 'p' => 'P', |
| 149 | ), |
| 150 | 'default' => 'span', |
| 151 | 'separator' => 'after' |
| 152 | ) |
| 153 | ); |
| 154 | |
| 155 | $this->add_control( |
| 156 | 'title_after', |
| 157 | array( |
| 158 | 'label' => __( 'After Title', 'auxin-elements' ), |
| 159 | 'type' => Controls_Manager::TEXT, |
| 160 | 'default' => '', |
| 161 | 'label_block' => true |
| 162 | ) |
| 163 | ); |
| 164 | |
| 165 | $this->add_control( |
| 166 | 'title_after_tag', |
| 167 | array( |
| 168 | 'label' => __( 'After Title HTML Tag', 'auxin-elements' ), |
| 169 | 'type' => Controls_Manager::SELECT, |
| 170 | 'options' => array( |
| 171 | 'h1' => 'H1', |
| 172 | 'h2' => 'H2', |
| 173 | 'h3' => 'H3', |
| 174 | 'h4' => 'H4', |
| 175 | 'h5' => 'H5', |
| 176 | 'h6' => 'H6', |
| 177 | 'div' => 'Div', |
| 178 | 'span' => 'Span', |
| 179 | 'p' => 'P', |
| 180 | ), |
| 181 | 'default' => 'span', |
| 182 | 'separator' => 'after' |
| 183 | ) |
| 184 | ); |
| 185 | |
| 186 | $this->add_responsive_control( |
| 187 | 'align', |
| 188 | array( |
| 189 | 'label' => __( 'Alignment', 'auxin-elements' ), |
| 190 | 'type' => Controls_Manager::CHOOSE, |
| 191 | 'options' => array( |
| 192 | 'flex-start' => array( |
| 193 | 'title' => __( 'Left', 'auxin-elements' ), |
| 194 | 'icon' => 'eicon-text-align-left', |
| 195 | ), |
| 196 | 'center' => array( |
| 197 | 'title' => __( 'Center', 'auxin-elements' ), |
| 198 | 'icon' => 'eicon-text-align-center', |
| 199 | ), |
| 200 | 'flex-end' => array( |
| 201 | 'title' => __( 'Right', 'auxin-elements' ), |
| 202 | 'icon' => 'eicon-text-align-right', |
| 203 | ), |
| 204 | ), |
| 205 | 'default' => '', |
| 206 | 'selectors' => array( |
| 207 | '{{WRAPPER}}' => 'justify-content: {{VALUE}};', |
| 208 | ), |
| 209 | ) |
| 210 | ); |
| 211 | |
| 212 | $this->end_controls_section(); |
| 213 | |
| 214 | $this->start_controls_section( |
| 215 | 'link_section', |
| 216 | array( |
| 217 | 'label' => __('Link', 'auxin-elements' ), |
| 218 | ) |
| 219 | ); |
| 220 | |
| 221 | $this->add_control( |
| 222 | 'link', |
| 223 | array( |
| 224 | 'label' => __( 'Disable Link', 'auxin-elements' ), |
| 225 | 'type' => Controls_Manager::SWITCHER, |
| 226 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 227 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 228 | 'return_value' => 'yes', |
| 229 | 'default' => 'off', |
| 230 | ) |
| 231 | ); |
| 232 | |
| 233 | $this->add_control( |
| 234 | 'link_open', |
| 235 | array( |
| 236 | 'label' => __( 'Open in a New Window', 'auxin-elements' ), |
| 237 | 'type' => Controls_Manager::SWITCHER, |
| 238 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 239 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 240 | 'return_value' => 'yes', |
| 241 | 'default' => 'off', |
| 242 | 'condition' => array( |
| 243 | 'link!' => 'yes' |
| 244 | ) |
| 245 | ) |
| 246 | ); |
| 247 | |
| 248 | $this->add_control( |
| 249 | 'link_follow', |
| 250 | array( |
| 251 | 'label' => __( 'Add No Follow', 'auxin-elements' ), |
| 252 | 'type' => Controls_Manager::SWITCHER, |
| 253 | 'label_on' => __( 'On', 'auxin-elements' ), |
| 254 | 'label_off' => __( 'Off', 'auxin-elements' ), |
| 255 | 'return_value' => 'yes', |
| 256 | 'default' => 'off', |
| 257 | 'condition' => array( |
| 258 | 'link!' => 'yes' |
| 259 | ) |
| 260 | ) |
| 261 | ); |
| 262 | |
| 263 | $this->end_controls_section(); |
| 264 | |
| 265 | /*-----------------------------------------------------------------------------------*/ |
| 266 | /* Style TAB |
| 267 | |
| 268 | /*-----------------------------------------------------------------------------------*/ |
| 269 | /* General Section |
| 270 | /*-------------------------------------*/ |
| 271 | |
| 272 | $this->start_controls_section( |
| 273 | 'general_style_section', |
| 274 | array( |
| 275 | 'label' => __( 'General', 'auxin-elements' ), |
| 276 | 'tab' => Controls_Manager::TAB_STYLE |
| 277 | ) |
| 278 | ); |
| 279 | |
| 280 | $this->add_control( |
| 281 | 'direction', |
| 282 | array( |
| 283 | 'label' => __( 'Direction', 'auxin-elements' ), |
| 284 | 'type' => Controls_Manager::SELECT, |
| 285 | 'options' => array( |
| 286 | 'horizontal' => 'Horizontal', |
| 287 | 'vertical' => 'Vertical', |
| 288 | ), |
| 289 | 'default' => 'horizontal', |
| 290 | ) |
| 291 | ); |
| 292 | |
| 293 | $this->end_controls_section(); |
| 294 | /* Title Section |
| 295 | /*-------------------------------------*/ |
| 296 | |
| 297 | $this->start_controls_section( |
| 298 | 'title_style_section', |
| 299 | array( |
| 300 | 'label' => __( 'Site Title', 'auxin-elements' ), |
| 301 | 'tab' => Controls_Manager::TAB_STYLE |
| 302 | ) |
| 303 | ); |
| 304 | |
| 305 | $this->add_responsive_control( |
| 306 | 'title_color', |
| 307 | array( |
| 308 | 'label' => __( 'Color', 'auxin-elements' ), |
| 309 | 'type' => Controls_Manager::COLOR, |
| 310 | 'selectors' => array( |
| 311 | '{{WRAPPER}} .aux-site-title-heading, {{WRAPPER}} .aux-site-title-heading a' => 'color: {{VALUE}};' |
| 312 | ) |
| 313 | ) |
| 314 | ); |
| 315 | |
| 316 | $this->add_responsive_control( |
| 317 | 'title_hover_color', |
| 318 | array( |
| 319 | 'label' => __( 'Hover Color', 'auxin-elements' ), |
| 320 | 'type' => Controls_Manager::COLOR, |
| 321 | 'selectors' => array( |
| 322 | '{{WRAPPER}} .aux-site-title-heading:hover, {{WRAPPER}} .aux-site-title-heading a:hover' => 'color: {{VALUE}};', |
| 323 | ), |
| 324 | ) |
| 325 | ); |
| 326 | |
| 327 | $this->add_group_control( |
| 328 | Group_Control_Typography::get_type(), |
| 329 | array( |
| 330 | 'name' => 'title_typography', |
| 331 | 'global' => [ |
| 332 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 333 | ], |
| 334 | 'selector' => '{{WRAPPER}} .aux-site-title-heading' |
| 335 | ) |
| 336 | ); |
| 337 | |
| 338 | $this->add_responsive_control( |
| 339 | 'title_margin', |
| 340 | array( |
| 341 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 342 | 'type' => Controls_Manager::DIMENSIONS, |
| 343 | 'size_units' => array( 'px', 'em' ), |
| 344 | 'allowed_dimensions' => 'all', |
| 345 | 'selectors' => array( |
| 346 | '{{WRAPPER}} .aux-site-title-heading' => 'margin:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 347 | ) |
| 348 | ) |
| 349 | ); |
| 350 | |
| 351 | $this->add_group_control( |
| 352 | Group_Control_Text_Shadow::get_type(), |
| 353 | array( |
| 354 | 'name' => 'title_text_shadow', |
| 355 | 'label' => __( 'Text Shadow', 'auxin-elements' ), |
| 356 | 'selector' => '{{WRAPPER}} .aux-site-title-heading' |
| 357 | ) |
| 358 | ); |
| 359 | |
| 360 | $this->end_controls_section(); |
| 361 | |
| 362 | /* Before Title Section |
| 363 | /*-------------------------------------*/ |
| 364 | |
| 365 | $this->start_controls_section( |
| 366 | 'before_title_style_section', |
| 367 | array( |
| 368 | 'label' => __( 'Before Site Title', 'auxin-elements' ), |
| 369 | 'tab' => Controls_Manager::TAB_STYLE |
| 370 | ) |
| 371 | ); |
| 372 | |
| 373 | $this->add_responsive_control( |
| 374 | 'before_title_color', |
| 375 | array( |
| 376 | 'label' => __( 'Color', 'auxin-elements' ), |
| 377 | 'type' => Controls_Manager::COLOR, |
| 378 | 'selectors' => array( |
| 379 | '{{WRAPPER}} .aux-site-title-before-heading' => 'color: {{VALUE}};' |
| 380 | ) |
| 381 | ) |
| 382 | ); |
| 383 | |
| 384 | $this->add_responsive_control( |
| 385 | 'before_title_hover_color', |
| 386 | array( |
| 387 | 'label' => __( 'Hover Color', 'auxin-elements' ), |
| 388 | 'type' => Controls_Manager::COLOR, |
| 389 | 'selectors' => array( |
| 390 | '{{WRAPPER}} .aux-site-title-before-heading:hover' => 'color: {{VALUE}};', |
| 391 | ), |
| 392 | ) |
| 393 | ); |
| 394 | |
| 395 | $this->add_group_control( |
| 396 | Group_Control_Typography::get_type(), |
| 397 | array( |
| 398 | 'name' => 'before_title_typography', |
| 399 | 'global' => [ |
| 400 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 401 | ], |
| 402 | 'selector' => '{{WRAPPER}} .aux-site-title-before-heading' |
| 403 | ) |
| 404 | ); |
| 405 | |
| 406 | $this->add_responsive_control( |
| 407 | 'before_title_margin', |
| 408 | array( |
| 409 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 410 | 'type' => Controls_Manager::DIMENSIONS, |
| 411 | 'size_units' => array( 'px', 'em' ), |
| 412 | 'allowed_dimensions' => 'all', |
| 413 | 'selectors' => array( |
| 414 | '{{WRAPPER}} .aux-site-title-before-heading' => 'margin:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 415 | ) |
| 416 | ) |
| 417 | ); |
| 418 | |
| 419 | $this->add_group_control( |
| 420 | Group_Control_Text_Shadow::get_type(), |
| 421 | array( |
| 422 | 'name' => 'before_title_text_shadow', |
| 423 | 'label' => __( 'Text Shadow', 'auxin-elements' ), |
| 424 | 'selector' => '{{WRAPPER}} .aux-site-title-before-heading' |
| 425 | ) |
| 426 | ); |
| 427 | |
| 428 | $this->end_controls_section(); |
| 429 | |
| 430 | /* After Title Section |
| 431 | /*-------------------------------------*/ |
| 432 | |
| 433 | $this->start_controls_section( |
| 434 | 'after_title_style_section', |
| 435 | array( |
| 436 | 'label' => __( 'After Site Title', 'auxin-elements' ), |
| 437 | 'tab' => Controls_Manager::TAB_STYLE |
| 438 | ) |
| 439 | ); |
| 440 | |
| 441 | $this->add_responsive_control( |
| 442 | 'after_title_color', |
| 443 | array( |
| 444 | 'label' => __( 'Color', 'auxin-elements' ), |
| 445 | 'type' => Controls_Manager::COLOR, |
| 446 | 'selectors' => array( |
| 447 | '{{WRAPPER}} .aux-site-title-after-heading' => 'color: {{VALUE}};' |
| 448 | ) |
| 449 | ) |
| 450 | ); |
| 451 | |
| 452 | $this->add_responsive_control( |
| 453 | 'after_title_hover_color', |
| 454 | array( |
| 455 | 'label' => __( 'Hover Color', 'auxin-elements' ), |
| 456 | 'type' => Controls_Manager::COLOR, |
| 457 | 'selectors' => array( |
| 458 | '{{WRAPPER}} .aux-site-title-after-heading:hover' => 'color: {{VALUE}};', |
| 459 | ), |
| 460 | ) |
| 461 | ); |
| 462 | |
| 463 | $this->add_group_control( |
| 464 | Group_Control_Typography::get_type(), |
| 465 | array( |
| 466 | 'name' => 'after_title_typography', |
| 467 | 'global' => [ |
| 468 | 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, |
| 469 | ], |
| 470 | 'selector' => '{{WRAPPER}} .aux-site-title-after-heading' |
| 471 | ) |
| 472 | ); |
| 473 | |
| 474 | $this->add_responsive_control( |
| 475 | 'after_title_margin', |
| 476 | array( |
| 477 | 'label' => __( 'Margin', 'auxin-elements' ), |
| 478 | 'type' => Controls_Manager::DIMENSIONS, |
| 479 | 'size_units' => array( 'px', 'em' ), |
| 480 | 'allowed_dimensions' => 'all', |
| 481 | 'selectors' => array( |
| 482 | '{{WRAPPER}} .aux-site-title-after-heading' => 'margin:{{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 483 | ) |
| 484 | ) |
| 485 | ); |
| 486 | |
| 487 | $this->add_group_control( |
| 488 | Group_Control_Text_Shadow::get_type(), |
| 489 | array( |
| 490 | 'name' => 'after_title_text_shadow', |
| 491 | 'label' => __( 'Text Shadow', 'auxin-elements' ), |
| 492 | 'selector' => '{{WRAPPER}} .aux-site-title-after-heading' |
| 493 | ) |
| 494 | ); |
| 495 | |
| 496 | $this->end_controls_section(); |
| 497 | |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Render image box widget output on the frontend. |
| 502 | * |
| 503 | * Written in PHP and used to generate the final HTML. |
| 504 | * |
| 505 | * @since 1.0.0 |
| 506 | * @access protected |
| 507 | */ |
| 508 | protected function render() { |
| 509 | $settings = $this->get_settings_for_display(); |
| 510 | echo sprintf( '<div class="aux-widget-site-title aux-%s">', esc_attr( $settings['direction'] ) ); |
| 511 | |
| 512 | $site_title = get_bloginfo('name'); |
| 513 | |
| 514 | if ( !auxin_is_true( $settings['link'] ) ) { |
| 515 | $site_url = home_url( '/' ); |
| 516 | $no_follow = auxin_is_true( $settings['link_follow'] ) ? 'rel = ”nofollow”': ''; |
| 517 | $open_window = auxin_is_true( $settings['link_open'] ) ? 'target=_blank' : ''; |
| 518 | $link_output = sprintf( '<a href="%s" title="%s" %s %s>%s</a>', esc_url( $site_url ), get_bloginfo( 'name', 'display' ), $no_follow, $open_window, $site_title ); |
| 519 | $site_title = $link_output; |
| 520 | } |
| 521 | |
| 522 | echo $settings['title_before'] !== '' ? sprintf('<%1$s class ="aux-site-title-before-heading">%2$s</%1$s>', tag_escape( $settings['title_before_tag'] ), esc_html( $settings['title_before'] ) ) : ''; |
| 523 | echo sprintf('<%1$s class="aux-site-title-heading">%2$s</%1$s>', tag_escape( $settings['title_tag'] ), wp_kses_post( $site_title ) ); |
| 524 | echo $settings['title_after'] !== '' ? sprintf('<%1$s class ="aux-site-title-after-heading">%2$s</%1$s>', tag_escape( $settings['title_after_tag'] ), esc_html( $settings['title_after'] ) ) : ''; |
| 525 | |
| 526 | echo '</div>'; |
| 527 | } |
| 528 | |
| 529 | } |
| 530 |