register_query_section(); $this->register_display_section(); $this->register_slider_options_section(); $this->register_navigation_section(); $this->register_card_style_section(); $this->register_image_style_section(); $this->register_content_style_section(); $this->register_button_style_section(); $this->register_arrows_style_section(); $this->register_pagination_style_section(); } /** * Query controls. */ private function register_query_section() { $this->start_controls_section( 'aels_section_query', array( 'label' => esc_html__( 'Query', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'post_type', array( 'label' => esc_html__( 'Post Type', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'post', 'options' => Helper::get_post_types(), ) ); $this->add_control( 'include_terms', array( 'label' => esc_html__( 'Filter By Term', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT2, 'multiple' => true, 'label_block' => true, 'options' => Helper::get_taxonomy_terms(), 'description' => esc_html__( 'Leave empty to show everything from the selected post type.', 'advance-elementor-slider' ), ) ); $this->add_control( 'posts_per_page', array( 'label' => esc_html__( 'Number Of Posts', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 1, 'max' => 30, 'default' => 6, ) ); $this->add_control( 'offset', array( 'label' => esc_html__( 'Offset', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 0, 'max' => 100, 'default' => 0, ) ); $this->add_control( 'orderby', array( 'label' => esc_html__( 'Order By', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'date', 'options' => array( 'date' => esc_html__( 'Date', 'advance-elementor-slider' ), 'title' => esc_html__( 'Title', 'advance-elementor-slider' ), 'menu_order' => esc_html__( 'Menu Order', 'advance-elementor-slider' ), 'comment_count' => esc_html__( 'Comment Count', 'advance-elementor-slider' ), 'rand' => esc_html__( 'Random', 'advance-elementor-slider' ), ), ) ); $this->add_control( 'order', array( 'label' => esc_html__( 'Order', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'DESC', 'options' => array( 'DESC' => esc_html__( 'Descending', 'advance-elementor-slider' ), 'ASC' => esc_html__( 'Ascending', 'advance-elementor-slider' ), ), ) ); $this->add_control( 'exclude_current', array( 'label' => esc_html__( 'Exclude Current Post', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->end_controls_section(); } /** * What each card shows. */ private function register_display_section() { $this->start_controls_section( 'aels_section_display', array( 'label' => esc_html__( 'Card Content', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'show_image', array( 'label' => esc_html__( 'Featured Image', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_group_control( Group_Control_Image_Size::get_type(), array( 'name' => 'thumbnail', 'default' => 'medium_large', 'condition' => array( 'show_image' => 'yes' ), ) ); $this->add_control( 'show_title', array( 'label' => esc_html__( 'Title', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', ) ); $this->add_control( 'title_tag', array( 'label' => esc_html__( 'Title Tag', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'h3', 'options' => array( 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6', 'div' => 'div', 'span' => 'span', ), 'condition' => array( 'show_title' => 'yes' ), ) ); $this->add_control( 'title_words', array( 'label' => esc_html__( 'Title Word Limit', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 0, 'max' => 40, 'default' => 0, 'description' => esc_html__( 'Set to 0 for the full title.', 'advance-elementor-slider' ), 'condition' => array( 'show_title' => 'yes' ), ) ); $this->add_control( 'show_meta', array( 'label' => esc_html__( 'Meta', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', ) ); $this->add_control( 'meta_items', array( 'label' => esc_html__( 'Meta Items', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT2, 'multiple' => true, 'default' => array( 'date', 'author' ), 'options' => array( 'date' => esc_html__( 'Date', 'advance-elementor-slider' ), 'author' => esc_html__( 'Author', 'advance-elementor-slider' ), 'comments' => esc_html__( 'Comments', 'advance-elementor-slider' ), ), 'condition' => array( 'show_meta' => 'yes' ), ) ); $this->add_control( 'show_excerpt', array( 'label' => esc_html__( 'Excerpt', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', ) ); $this->add_control( 'excerpt_words', array( 'label' => esc_html__( 'Excerpt Word Limit', 'advance-elementor-slider' ), 'type' => Controls_Manager::NUMBER, 'min' => 5, 'max' => 120, 'default' => 22, 'condition' => array( 'show_excerpt' => 'yes' ), ) ); $this->add_control( 'show_button', array( 'label' => esc_html__( 'Read More Button', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', ) ); $this->add_control( 'button_text', array( 'label' => esc_html__( 'Button Text', 'advance-elementor-slider' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Read More', 'advance-elementor-slider' ), 'condition' => array( 'show_button' => 'yes' ), ) ); $this->add_responsive_control( 'card_text_align', array( 'label' => esc_html__( 'Text Align', 'advance-elementor-slider' ), 'type' => Controls_Manager::CHOOSE, 'separator' => 'before', 'options' => array( 'left' => array( 'title' => esc_html__( 'Left', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => esc_html__( 'Center', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => esc_html__( 'Right', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-right', ), ), 'default' => 'left', 'selectors' => array( '{{WRAPPER}} .aels-post__body' => 'text-align: {{VALUE}};', ), ) ); $this->end_controls_section(); } /** * Card styling. */ private function register_card_style_section() { $this->start_controls_section( 'aels_style_card', array( 'label' => esc_html__( 'Card', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'card_bg', array( 'label' => esc_html__( 'Background', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .aels-post' => 'background-color: {{VALUE}};', ), ) ); $this->add_responsive_control( 'card_body_padding', array( 'label' => esc_html__( 'Body Padding', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => 24, 'right' => 24, 'bottom' => 24, 'left' => 24, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-post__body' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_control( 'card_radius', array( 'label' => esc_html__( 'Border Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 10, 'right' => 10, 'bottom' => 10, 'left' => 10, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-post' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'card_border', 'selector' => '{{WRAPPER}} .aels-post', ) ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'card_shadow', 'selector' => '{{WRAPPER}} .aels-post', ) ); $this->add_control( 'equal_height', array( 'label' => esc_html__( 'Equal Card Height', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', 'prefix_class' => 'aels-equal-height-', 'return_value' => 'yes', ) ); $this->end_controls_section(); } /** * Thumbnail styling. */ private function register_image_style_section() { $this->start_controls_section( 'aels_style_image', array( 'label' => esc_html__( 'Featured Image', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => array( 'show_image' => 'yes' ), ) ); $this->add_responsive_control( 'image_height', array( 'label' => esc_html__( 'Height', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 80, 'max' => 600, ), ), 'default' => array( 'unit' => 'px', 'size' => 220, ), 'selectors' => array( '{{WRAPPER}} .aels-post__thumb' => 'height: {{SIZE}}{{UNIT}};', ), ) ); $this->add_control( 'image_hover_zoom', array( 'label' => esc_html__( 'Zoom On Hover', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'prefix_class' => 'aels-zoom-', 'return_value' => 'yes', ) ); $this->end_controls_section(); } /** * Title, meta and excerpt styling. */ private function register_content_style_section() { $this->start_controls_section( 'aels_style_content', array( 'label' => esc_html__( 'Title, Meta & Excerpt', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'title_heading', array( 'label' => esc_html__( 'Title', 'advance-elementor-slider' ), 'type' => Controls_Manager::HEADING, ) ); $this->add_control( 'title_color', array( 'label' => esc_html__( 'Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#111827', 'selectors' => array( '{{WRAPPER}} .aels-post__title, {{WRAPPER}} .aels-post__title a' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'title_color_hover', array( 'label' => esc_html__( 'Hover Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#2563eb', 'selectors' => array( '{{WRAPPER}} .aels-post__title a:hover' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'post_title_typography', 'selector' => '{{WRAPPER}} .aels-post__title', ) ); $this->add_control( 'meta_heading', array( 'label' => esc_html__( 'Meta', 'advance-elementor-slider' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', 'condition' => array( 'show_meta' => 'yes' ), ) ); $this->add_control( 'meta_color', array( 'label' => esc_html__( 'Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#6b7280', 'selectors' => array( '{{WRAPPER}} .aels-post__meta' => 'color: {{VALUE}};', ), 'condition' => array( 'show_meta' => 'yes' ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'meta_typography', 'selector' => '{{WRAPPER}} .aels-post__meta', 'condition' => array( 'show_meta' => 'yes' ), ) ); $this->add_control( 'excerpt_heading', array( 'label' => esc_html__( 'Excerpt', 'advance-elementor-slider' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', 'condition' => array( 'show_excerpt' => 'yes' ), ) ); $this->add_control( 'excerpt_color', array( 'label' => esc_html__( 'Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#4b5563', 'selectors' => array( '{{WRAPPER}} .aels-post__excerpt' => 'color: {{VALUE}};', ), 'condition' => array( 'show_excerpt' => 'yes' ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'excerpt_typography', 'selector' => '{{WRAPPER}} .aels-post__excerpt', 'condition' => array( 'show_excerpt' => 'yes' ), ) ); $this->end_controls_section(); } /** * Read more button styling. */ private function register_button_style_section() { $this->start_controls_section( 'aels_style_button', array( 'label' => esc_html__( 'Read More Button', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => array( 'show_button' => 'yes' ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'post_button_typography', 'selector' => '{{WRAPPER}} .aels-post__btn', ) ); $this->add_responsive_control( 'post_button_padding', array( 'label' => esc_html__( 'Padding', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => 10, 'right' => 22, 'bottom' => 10, 'left' => 22, 'unit' => 'px', 'isLinked' => false, ), 'selectors' => array( '{{WRAPPER}} .aels-post__btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_control( 'post_button_radius', array( 'label' => esc_html__( 'Border Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 4, 'right' => 4, 'bottom' => 4, 'left' => 4, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-post__btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->start_controls_tabs( 'aels_tabs_post_button' ); $this->start_controls_tab( 'aels_tab_post_button_normal', array( 'label' => esc_html__( 'Normal', 'advance-elementor-slider' ) ) ); $this->add_control( 'post_button_color', array( 'label' => esc_html__( 'Text Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => array( '{{WRAPPER}} .aels-post__btn' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'post_button_bg', array( 'label' => esc_html__( 'Background Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#2563eb', 'selectors' => array( '{{WRAPPER}} .aels-post__btn' => 'background-color: {{VALUE}};', ), ) ); $this->end_controls_tab(); $this->start_controls_tab( 'aels_tab_post_button_hover', array( 'label' => esc_html__( 'Hover', 'advance-elementor-slider' ) ) ); $this->add_control( 'post_button_color_hover', array( 'label' => esc_html__( 'Text Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .aels-post__btn:hover' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'post_button_bg_hover', array( 'label' => esc_html__( 'Background Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#1d4ed8', 'selectors' => array( '{{WRAPPER}} .aels-post__btn:hover' => 'background-color: {{VALUE}};', ), ) ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } /** * Render the widget. */ protected function render() { $settings = $this->get_settings_for_display(); $query = new \WP_Query( Helper::build_query_args( $settings ) ); if ( ! $query->have_posts() ) { $this->render_empty_notice( esc_html__( 'No posts matched this query.', 'advance-elementor-slider' ) ); wp_reset_postdata(); return; } $this->render_slider_start( $settings, array( 'aels-slider--posts' ) ); while ( $query->have_posts() ) { $query->the_post(); $this->render_post_card( $settings ); } $this->render_slider_end( $settings ); wp_reset_postdata(); } /** * Render a single post card. * * @param array $settings Widget settings. */ private function render_post_card( array $settings ) { $allowed_tags = array( 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'span' ); $title_tag = in_array( $settings['title_tag'], $allowed_tags, true ) ? $settings['title_tag'] : 'h3'; $permalink = get_permalink(); $title = get_the_title(); if ( ! empty( $settings['title_words'] ) ) { $title = Helper::trim_words( $title, $settings['title_words'] ); } ?>
' . esc_html( get_the_date() ) . ''; } if ( in_array( 'author', $items, true ) ) { $parts[] = ''; } if ( in_array( 'comments', $items, true ) ) { $count = (int) get_comments_number(); $parts[] = ''; } echo wp_kses_post( implode( '', $parts ) ); } }