start_controls_section( 'section_content', [ 'label' => __( 'Post Excerpt', 'admore-widgets-suite' ), ] ); $this->add_control( 'excerpt_length', [ 'label' => __( 'Word Limit', 'admore-widgets-suite' ), 'type' => Controls_Manager::NUMBER, 'default' => 0, 'min' => 0, 'description' => __( '0 = use the post\'s manual excerpt or WordPress default (55 words).', 'admore-widgets-suite' ), ] ); $this->add_control( 'show_read_more', [ 'label' => __( 'Show Read More Link', 'admore-widgets-suite' ), 'type' => Controls_Manager::SWITCHER, 'default' => '', 'return_value' => 'yes', ] ); $this->add_control( 'read_more_text', [ 'label' => __( 'Read More Text', 'admore-widgets-suite' ), 'type' => Controls_Manager::TEXT, 'default' => __( 'Read More', 'admore-widgets-suite' ), 'condition' => [ 'show_read_more' => '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-post-excerpt' => 'text-align: {{VALUE}};' ], ] ); $this->end_controls_section(); $this->start_controls_section( 'style_excerpt', [ 'label' => __( 'Excerpt', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'excerpt_typography', 'selector' => '{{WRAPPER}} .eppro-excerpt-text', ] ); $this->add_control( 'excerpt_color', [ 'label' => __( 'Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-excerpt-text' => 'color: {{VALUE}};' ], ] ); $this->end_controls_section(); $this->start_controls_section( 'style_readmore', [ 'label' => __( 'Read More', 'admore-widgets-suite' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_read_more' => 'yes' ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'rm_typography', 'selector' => '{{WRAPPER}} .eppro-read-more', ] ); $this->add_control( 'rm_color', [ 'label' => __( 'Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'default' => '#7c3aed', 'selectors' => [ '{{WRAPPER}} .eppro-read-more' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'rm_hover_color', [ 'label' => __( 'Hover Color', 'admore-widgets-suite' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-read-more:hover' => 'color: {{VALUE}};' ], ] ); $this->add_responsive_control( 'rm_margin_top', [ 'label' => __( 'Spacing Top', 'admore-widgets-suite' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 12, 'unit' => 'px' ], 'selectors' => [ '{{WRAPPER}} .eppro-read-more' => 'margin-top: {{SIZE}}{{UNIT}};' ], ] ); $this->end_controls_section(); } protected function render(): void { $s = $this->get_settings_for_display(); if ( \Elementor\Plugin::$instance->editor->is_edit_mode() && ! get_the_ID() ) { echo '

' . esc_html__( '[Post excerpt will appear here]', 'admore-widgets-suite' ) . '

'; return; } $length = absint( $s['excerpt_length'] ); if ( $length > 0 ) { $excerpt = wp_trim_words( get_the_excerpt(), $length, '…' ); } else { $excerpt = get_the_excerpt(); } ?>