start_controls_section( 'author_content', [ 'label' => __( 'Author Info', 'easy-elements' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_avatar', [ 'label' => __( 'Show Avatar', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'show_bio', [ 'label' => __( 'Show Bio', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_control( 'show_post_count', [ 'label' => __( 'Show Total Posts', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'default' => 'yes', ] ); $this->add_responsive_control( 'count_middle_space', [ 'label' => __( 'Spacing', 'easy-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px', '%', 'em' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .eel-author-info .eel-author-description' => 'padding-left: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Name $this->start_controls_section( 'author_style', [ 'label' => __( 'Name', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'author_typography', 'selector' => '{{WRAPPER}} .eel-author-info .eel-author-name', ] ); $this->add_control( 'author_text_color', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-author-info .eel-author-name' => 'color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'author_margin', [ 'label' => __( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-author-info .eel-author-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Description $this->start_controls_section( 'bio_style', [ 'label' => __( 'Biographical Info', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'bio_typography', 'selector' => '{{WRAPPER}} .eel-author-info .eel-author-bio', ] ); $this->add_control( 'bio_text_color', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-author-info .eel-author-bio' => 'color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'bio_margin', [ 'label' => __( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-author-info .eel-author-bio' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Count $this->start_controls_section( 'count_style', [ 'label' => __( 'Post Count', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'count_typography', 'selector' => '{{WRAPPER}} .eel-author-post-count', ] ); $this->add_control( 'count_text_color', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-author-post-count' => 'color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'count_margin', [ 'label' => __( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .eel-author-post-count' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); } protected function render() { $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 ) { echo '

' . esc_html__('No valid post found.', 'easy-elements') . '

'; return; } global $post; $original_post = $post; $post = $post_obj; setup_postdata( $post ); $author_id = $post->post_author; $author_name = get_the_author_meta( 'display_name', $author_id ); echo '
'; echo '
'; if ( 'yes' === $settings['show_avatar'] ) { echo get_avatar( $author_id, 96, '', $author_name, ['class' => 'eel-author-avatar'] ); } echo '
'; echo '
'; echo '

' . esc_html( $author_name ) . '

'; if ( 'yes' === $settings['show_bio'] ) { $bio = get_the_author_meta('description', $author_id); if ( $bio ) { echo '

' . esc_html( $bio ) . '

'; } } // Total posts if ( 'yes' === $settings['show_post_count'] ) { $post_count = (int) count_user_posts( $author_id, 'post' ); echo '' . /* translators: %d: number of posts */ esc_html( sprintf( _n( '%d post', '%d posts', $post_count, 'easy-elements' ), $post_count ) ) . ''; } echo '
'; echo '
'; wp_reset_postdata(); $post = $original_post; } }