start_controls_section( 'section_content', [ 'label' => __( 'Archive Title', 'admore-widgets-suite' ), ] ); $this->add_control( 'title_tag', [ 'label' => __( 'HTML Tag', 'admore-widgets-suite' ), 'type' => Controls_Manager::SELECT, 'default' => 'h1', 'options' => [ 'h1' => 'H1', 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'p' => 'P' ], ] ); $this->add_control( 'show_prefix', [ 'label' => __( 'Show Type Prefix', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'description' => __( 'E.g. "Category: News" vs "News".', 'admore-widgets-suite' ), 'default' => '', 'return_value' => 'yes', ] ); $this->add_control( 'alignment', [ 'label' => __( 'Alignment', 'admore-widgets-suite' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __( 'Left', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-left' ], 'center' => [ 'title' => __( 'Center', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-center' ], 'right' => [ 'title' => __( 'Right', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-right' ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .eppro-archive-title' => 'text-align: {{VALUE}};' ], ] ); $this->end_controls_section(); $this->start_controls_section( 'style_title', [ 'label' => __( 'Title', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .eppro-archive-title', ] ); $this->add_control( 'title_color', [ 'label' => __( 'Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-archive-title' => 'color: {{VALUE}};' ], ] ); $this->add_group_control( Group_Control_Text_Shadow::get_type(), [ 'name' => 'title_shadow', 'selector' => '{{WRAPPER}} .eppro-archive-title', ] ); $this->end_controls_section(); } protected function render(): void { $s = $this->get_settings_for_display(); $tag = esc_attr( $s['title_tag'] ); if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { $title = esc_html__( 'Archive Title Placeholder', 'admore-widgets-suite' ); } elseif ( 'yes' === $s['show_prefix'] ) { $title = esc_html( get_the_archive_title() ); } else { $obj = get_queried_object(); $title = ''; if ( $obj instanceof WP_Term ) { $title = esc_html( $obj->name ); } elseif ( is_author() ) { $title = esc_html( get_the_author() ); } elseif ( is_post_type_archive() ) { $title = esc_html( post_type_archive_title( '', false ) ); } elseif ( is_search() ) { /* translators: %s: search query string */ $title = esc_html( sprintf( __( 'Search: %s', 'admore-widgets-suite' ), get_search_query() ) ); } elseif ( is_date() ) { $title = esc_html( get_the_archive_title() ); } else { $title = esc_html( get_the_archive_title() ); } } if ( ! $title ) return; echo wp_kses_post( '<' . $tag . ' class="eppro-archive-title">' . $title . '' ); } }