start_controls_section( 'tags_content', [ 'label' => __( 'Tags', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_label', [ 'label' => __( 'Show Label', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'label_text', [ 'label' => __( 'Label Text', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Tags:', 'easy-elements' ), 'condition' => [ 'show_label' => 'yes', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'title_style', [ 'label' => __( 'Title Label', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_color', [ 'label' => __( 'Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label' => 'color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'title_margin', [ 'label' => __( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .eel-post-tags-widget .eel-tags-label', ] ); $this->end_controls_section(); $this->start_controls_section( 'tags_style', [ 'label' => __( 'Tag', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'tags_typography', 'selector' => '{{WRAPPER}} .eel-post-tags-widget a', ] ); $this->start_controls_tabs( 'tabs_tag_style' ); // Normal Tab $this->start_controls_tab( 'tab_tag_normal', [ 'label' => __( 'Normal', 'easy-elements' ), ] ); $this->add_control( 'tags_color', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget a' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => 'tags__bg_color', 'label' => __('Background', 'easy-elements'), 'types' => ['classic', 'gradient'], 'selector' => '{{WRAPPER}} .eel-post-tags-widget a', ] ); $this->end_controls_tab(); // Hover Tab $this->start_controls_tab( 'tab_tag_hover', [ 'label' => __( 'Hover', 'easy-elements' ), ] ); $this->add_control( 'tags_hover_color', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => 'tags_hover_bg_color', 'label' => __('Background', 'easy-elements'), 'types' => ['classic', 'gradient'], 'selector' => '{{WRAPPER}} .eel-post-tags-widget a:hover', ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_responsive_control( 'tags_margin', [ 'label' => __( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'tags_padding', [ 'label' => __( 'Padding', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-post-tags-widget a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); } protected function render() { // Password protected post check if ( post_password_required() ) { return; } $settings = $this->get_settings_for_display(); $post_id = function_exists('easyel_get_prepared_post_id') ? easyel_get_prepared_post_id() : get_the_ID(); $post_obj = get_post( $post_id ); if ( ! $post_obj instanceof \WP_Post ) { return; } // Setup global post for template functions global $post; $original_post = $post; $post = $post_obj; setup_postdata( $post ); $tags = get_the_tags(); if ( ! $tags || is_wp_error( $tags ) ) { wp_reset_postdata(); $post = $original_post; return; } echo '
'; if ( 'yes' === ( $settings['show_label'] ?? 'no' ) && ! empty( $settings['label_text'] ) ) { echo '' . esc_html( $settings['label_text'] ) . ' '; } foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); echo ' '; } echo '
'; // Reset global post wp_reset_postdata(); $post = $original_post; } }