Loading...
ransform: translate(50%,-50%) !important;', ], 'condition' => [ 'timeline_layout' => ['one-sided', 'one-sided-left'] ], 'render_type' => 'template', ] ); $this->add_control( 'arrow_bothsided_position_top', [ 'label' => __( 'Position Top', 'wpr-addons' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ '%', 'px' ], 'range' => [ '%' => [ 'min' => 0, 'max' => 100, ], 'px' => [ 'min' => 0, 'max' => 150, ], ], 'default' => [ 'size' => 30, 'unit' => '%', ], 'selectors' => [ '{{WRAPPER}} .wpr-timeline-centered .wpr-data-wrap:after' => 'top: {{size}}{{UNIT}}; transform: translateY(-50%) !important;', '{{WRAPPER}} .wpr-timeline-centered.wpr-both-sided-timeline .wpr-right-aligned .wpr-icon' => 'position: absolute; top: {{size}}{{UNIT}}; transform: translate(50%, -50%) !important;', '{{WRAPPER}} .wpr-timeline-centered.wpr-one-sided-timeline .wpr-right-aligned .wpr-icon' => 'position: absolute; top: {{size}}{{UNIT}}; transform: translate(-50%, -50%) !important;', '{{WRAPPER}} .wpr-timeline-centered .wpr-left-aligned .wpr-icon' => 'position: absolute; top: {{size}}{{UNIT}}; transform: translate(-50%, -50%) !important;', '{{WRAPPER}} .wpr-timeline-centered .wpr-extra-label' => 'top: {{size}}{{UNIT}};', '{{WRAPPER}} .wpr-centered .wpr-one-sided-timeline .wpr-data-wrap:after' => 'top: {{size}}{{UNIT}}; transform: translateY(-50%) !important;', ], 'condition' => [ 'timeline_layout' => ['centered'] ], 'render_type' => 'template' ] ); $this->end_controls_section(); $this->start_controls_section( 'navigation_button_styles', [ 'label' => esc_html__( 'Navigation', 'wpr-addons' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'timeline_layout' => ['horizontal', 'horizontal-bottom'] ] ] ); $this->start_controls_tabs( 'navigation_style_tabs' ); $this->start_controls_tab( 'navigation_style_normal_tab', [ 'label' => __( 'Normal', 'wpr-addons' ), ] ); $this->add_control( 'navigation_button_bg_color', [ 'label' => esc_html__( 'Background Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .wpr-button-prev' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-button-next' => 'background-color: {{VALUE}}', ], 'condition' => [ 'timeline_layout' => ['horizontal', 'horizontal-bottom'] ] ] ); $this->add_control( 'navigation_button_color', [ 'label' => esc_html__( 'Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#605BE5', 'selectors' => [ '{{WRAPPER}} .wpr-button-prev i' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-button-next i' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-button-prev svg' => 'fill: {{VALUE}}; cursor: pointer; z-index: 11;', '{{WRAPPER}} .wpr-button-next svg' => 'fill: {{VALUE}}; cursor: pointer; z-index: 11;', ], 'condition' => [ 'timeline_layout' => ['horizontal', 'horizontal-bottom'] ] ] ); $this->add_control( 'navigation_transition_duration', [ 'label' => esc_html__( 'Transition Duration', 'wpr-addons' ), 'type' => Controls_Manager::NUMBER, 'default' => 0.1, 'min' => 0, 'max' => 5, 'step' => 0.1, 'selectors' => [ '{{WRAPPER}} .wpr-button-prev' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-button-next' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-button-prev i' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-button-next i' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-button-prev svg' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-button-next svg' => 'transition-duration: {{VALUE}}s', ], 'separator' => 'before' ] ); $this->add_responsive_control( 'navigation_icon_size', [ 'label' => esc_html__( 'Icon Size', 'wpr-addons' ), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 10, 'max' => 100, ], ], 'default' => [ 'unit' => 'px', 'size' => 40, ], 'selectors' => [ '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-next' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-prev' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-next' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-prev' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-next svg' => 'width: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-prev svg' => 'width: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-next svg' => 'width: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-prev svg' => 'width: {{SIZE}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->add_responsive_control( 'navigation_icon_bg_size', [ 'label' => esc_html__( 'Box Size', 'wpr-addons' ), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 20, 'max' => 100, ], ], 'default' => [ 'unit' => 'px', 'size' => 40, ], 'selectors' => [ '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-next' => 'width: {{SIZE}}{{UNIT}}; text-align: center; height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-prev' => 'width: {{SIZE}}{{UNIT}}; text-align: center; height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-next' => 'width: {{SIZE}}{{UNIT}}; text-align: center; height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-prev' => 'width: {{SIZE}}{{UNIT}}; text-align: center; height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-next i' => 'width: {{SIZE}}{{UNIT}}; text-align: center; line-height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-prev i' => 'width: {{SIZE}}{{UNIT}}; text-align: center; line-height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal .wpr-button-next svg' => ' text-align: center; line-height: 1.5;', '{{WRAPPER}} .wpr-horizontal .wpr-button-prev svg' => ' text-align: center; line-height: 1.5;', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-next i' => 'width: {{SIZE}}{{UNIT}}; text-align: center; line-height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-prev i' => 'width: {{SIZE}}{{UNIT}}; text-align: center; line-height: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-next svg' => 'text-align: center; line-height: 1.5;', '{{WRAPPER}} .wpr-horizontal-bottom .wpr-button-prev svg' => 'text-align: center; line-height: 1.5;', '{{WRAPPER}} .wpr-swiper-pagination.swiper-pagination-progressbar' => 'width: calc(100% - ({{SIZE}}px + 15px)*2);', '{{WRAPPER}} .wpr-horizontal-bottom.swiper-container' => 'margin-left: {{SIZE}}px; margin-right: {{SIZE}}px;', '{{WRAPPER}} .wpr-horizontal.swiper-container' => 'margin-left: {{SIZE}}px; margin-right: {{SIZE}}px;', ], 'render_type' => 'template' ] ); $this->end_controls_tab(); $this->start_controls_tab( 'navigation_style_hover_tab', [ 'label' => __( 'Hover', 'wpr-addons' ), ] ); $this->add_control( 'navigation_button_bg_color_hover', [ 'label' => esc_html__( 'Background Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} .wpr-button-prev:hover' => 'background-color: {{VALUE}}; cursor: pointer;', '{{WRAPPER}} .wpr-button-next:hover' => 'background-color: {{VALUE}}; cursor: pointer;', ], 'condition' => [ 'timeline_layout' => ['horizontal', 'horizontal-bottom'] ] ] ); $this->add_control( 'navigation_button_color_hover', [ 'label' => esc_html__( 'Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#605BE1', 'selectors' => [ '{{WRAPPER}} .wpr-button-prev:hover i' => 'color: {{VALUE}}; cursor: pointer; z-index: 11;', '{{WRAPPER}} .wpr-button-next:hover i' => 'color: {{VALUE}}; cursor: pointer; z-index: 11;', '{{WRAPPER}} .wpr-button-prev:hover svg' => 'fill: {{VALUE}}; cursor: pointer; z-index: 11;', '{{WRAPPER}} .wpr-button-next:hover svg' => 'fill: {{VALUE}}; cursor: pointer; z-index: 11;', ], 'condition' => [ 'timeline_layout' => ['horizontal', 'horizontal-bottom'] ] ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); // Styles ==================== // Section: Pagination ------- $this->start_controls_section( 'section_style_pagination', [ 'label' => esc_html__( 'Pagination', 'wpr-addons' ), 'tab' => Controls_Manager::TAB_STYLE, 'show_label' => false, 'condition' => [ 'timeline_content' => 'dynamic', 'timeline_layout' => ['centered', 'one-sided', 'one-sided-left'] ], ] ); $this->start_controls_tabs( 'tabs_grid_pagination_style' ); $this->start_controls_tab( 'tab_grid_pagination_normal', [ 'label' => esc_html__( 'Normal', 'wpr-addons' ), ] ); $this->add_control( 'pagination_color', [ 'label' => esc_html__( 'Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination svg' => 'fill: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'color: {{VALUE}}', ], 'condition' => [ 'timeline_layout' => ['centered', 'one-sided', 'one-sided-left'] ] ] ); $this->add_control( 'pagination_bg_color', [ 'label' => esc_html__( 'Background Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#605BE5', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-pagination-finish' => 'color: {{VALUE}}', ] ] ); $this->add_control( 'pagination_border_color', [ 'label' => esc_html__( 'Border Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#E8E8E8', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'border-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'border-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'border-color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'pagination_box_shadow', 'selector' => '{{WRAPPER}} .wpr-grid-pagination a, {{WRAPPER}} .wpr-grid-pagination > div > span', ] ); $this->add_control( 'pagination_loader_color', [ 'label' => esc_html__( 'Loader Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#605BE5', 'selectors' => [ '{{WRAPPER}} .wpr-double-bounce .wpr-child' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-wave .wpr-rect' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-spinner-pulse' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-chasing-dots .wpr-child' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-three-bounce .wpr-child' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-fading-circle .wpr-circle:before' => 'background-color: {{VALUE}}', ], 'condition' => [ 'pagination_type' => [ 'load-more', 'infinite-scroll' ] ] ] ); $this->end_controls_tab(); $this->start_controls_tab( 'tab_grid_pagination_hover', [ 'label' => esc_html__( 'Hover', 'wpr-addons' ), ] ); $this->add_control( 'pagination_color_hr', [ 'label' => esc_html__( 'Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a:hover' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination a:hover svg' => 'fill: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span:not(.wpr-disabled-arrow):hover' => 'color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'pagination_bg_color_hr', [ 'label' => esc_html__( 'Background Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#4A45D2', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a:hover' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span:not(.wpr-disabled-arrow):hover' => 'background-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'background-color: {{VALUE}}', ] ] ); $this->add_control( 'pagination_border_color_hr', [ 'label' => esc_html__( 'Border Color', 'wpr-addons' ), 'type' => Controls_Manager::COLOR, 'default' => '#E8E8E8', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a:hover' => 'border-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination > div > span:not(.wpr-disabled-arrow):hover' => 'border-color: {{VALUE}}', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'border-color: {{VALUE}}', ] ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'pagination_box_shadow_hr', 'selector' => '{{WRAPPER}} .wpr-grid-pagination a:hover, {{WRAPPER}} .wpr-grid-pagination > div > span:not(.wpr-disabled-arrow):hover', 'separator' => 'after', ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'pagination_transition_duration', [ 'label' => esc_html__( 'Transition Duration', 'wpr-addons' ), 'type' => Controls_Manager::NUMBER, 'default' => 0.1, 'min' => 0, 'max' => 5, 'step' => 0.1, 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-grid-pagination svg' => 'transition-duration: {{VALUE}}s', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'transition-duration: {{VALUE}}s', ], 'separator' => 'after', ] ); ;$this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'loadmore_typography', 'label' => __( 'Typography', 'wpr-addons' ), 'selector' => '{{WRAPPER}} .wpr-load-more-btn', ] ); $this->add_control( 'pagination_border_type', [ 'label' => esc_html__( 'Border Type', 'wpr-addons' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'none' => esc_html__( 'None', 'wpr-addons' ), 'solid' => esc_html__( 'Solid', 'wpr-addons' ), 'double' => esc_html__( 'Double', 'wpr-addons' ), 'dotted' => esc_html__( 'Dotted', 'wpr-addons' ), 'dashed' => esc_html__( 'Dashed', 'wpr-addons' ), 'groove' => esc_html__( 'Groove', 'wpr-addons' ), ], 'default' => 'none', 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'border-style: {{VALUE}};', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'border-style: {{VALUE}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'border-style: {{VALUE}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'border-style: {{VALUE}}', ], 'separator' => 'before', ] ); $this->add_control( 'pagination_border_width', [ 'label' => esc_html__( 'Border Width', 'wpr-addons' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px' ], 'default' => [ 'top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1, ], 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'condition' => [ 'pagination_border_type!' => 'none', ], ] ); $this->add_responsive_control( 'pagination_distance_from_grid', [ 'label' => esc_html__( 'Distance From Timeline', 'wpr-addons' ), 'type' => Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'default' => [ 'unit' => 'px', 'size' => 25, ], 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination' => 'margin-top: {{SIZE}}{{UNIT}};', ], 'separator' => 'before' ] ); $this->add_responsive_control( 'pagination_padding', [ 'label' => esc_html__( 'Padding', 'wpr-addons' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px' ], 'default' => [ 'top' => 8, 'right' => 20, 'bottom' => 8, 'left' => 20, ], 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-disabled-arrow' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'pagination_wrapper_padding', [ 'label' => esc_html__( 'Wrapper Padding', 'wpr-addons' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px' ], 'default' => [ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, ], 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'pagination_radius', [ 'label' => esc_html__( 'Border Radius', 'wpr-addons' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%' ], 'default' => [ 'top' => 3, 'right' => 3, 'bottom' => 3, 'left' => 3, ], 'selectors' => [ '{{WRAPPER}} .wpr-grid-pagination a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination > div > span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', '{{WRAPPER}} .wpr-grid-pagination span.wpr-grid-current-page' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->end_controls_section(); } public function get_tax_query_args() { $settings = $this->get_settings(); $tax_query = []; if ( 'related' === $settings[ 'timeline_post_types' ] ) { $tax_query = [ [ 'taxonomy' => $settings['query_tax_selection'], 'field' => 'term_id', 'terms' => wp_get_object_terms( get_the_ID(), $settings['query_tax_selection'], array( 'fields' => 'ids' ) ), ] ]; } else { foreach ( get_object_taxonomies($settings[ 'timeline_post_types' ]) as $tax ) { if ( ! empty($settings[ 'query_taxonomy_'. $tax ]) ) { array_push( $tax_query, [ 'taxonomy' => $tax, 'field' => 'id', 'terms' => $settings[ 'query_taxonomy_'. $tax ] ] ); } } } return $tax_query; } // for frontend public function get_main_query_args() { $settings = $this->get_settings(); $author = ! empty( $settings[ 'query_author' ] ) ? implode( ',', $settings[ 'query_author' ] ) : ''; // Get Paged if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); } else { $paged = 1; } $posts_per_page = (!wpr_fs()->can_use_premium_code() && $settings['posts_per_page'] > 4) ? 4 : (empty($settings['posts_per_page']) ? 4 : $settings['posts_per_page']); // Dynamic $args = [ 'post_type' => $settings[ 'timeline_post_types' ], 'tax_query' => $this->get_tax_query_args(), 'post__not_in' => !empty($settings[ 'query_exclude_'. $settings[ 'timeline_post_types' ] ]) ? $settings[ 'query_exclude_'. $settings[ 'timeline_post_types' ] ] : '', 'posts_per_page' => $posts_per_page, 'orderby' => $settings[ 'order_posts' ], 'order' => $settings['order_direction'], 'author' => $author, 'paged' => $paged, ]; // Exclude Items without F/Image if ( 'yes' === $settings['query_exclude_no_images'] ) { $args['meta_key'] = '_thumbnail_id'; } // Manual if ( 'manual' === $settings[ 'query_selection' ] ) { $post_ids = ['']; if ( ! empty($settings[ 'query_manual_'. $settings[ 'timeline_post_types' ] ]) ) { $post_ids = $settings[ 'query_manual_'. $settings[ 'timeline_post_types' ] ]; } $args = [ 'post_type' => $settings[ 'timeline_post_types' ], 'post__in' => $post_ids, 'posts_per_page' => $posts_per_page, 'orderby' => '', // $settings[ 'query_randomize' ], 'paged' => $paged, ]; } return $args; } public function get_max_num_pages( $settings ) { $query = new \WP_Query( $this->get_main_query_args() ); $max_num_pages = intval( ceil( $query->max_num_pages ) ); // Reset wp_reset_postdata(); // $max_num_pages return $max_num_pages; } public $content_alignment = ''; public function content_and_animation_alignment($layout, $countItem, $settings) { if ( $layout != 'one-sided-left' ) { $this->content_alignment = "wpr-right-aligned"; } if ( $layout === 'one-sided-left' ) { $this->content_alignment = "wpr-left-aligned"; } if ( $layout == 'centered' ) { if ( $countItem % 2 == 0 ) { $this->content_alignment = "wpr-left-aligned"; } if ( preg_match('/right/i', $settings['timeline_animation']) ) { if ( 'wpr-left-aligned' === $this->content_alignment ) { $this->animation = preg_match('/right/i', $settings['timeline_animation']) ? str_replace('right', 'left', $settings['timeline_animation']) : $settings['timeline_animation']; } elseif ( 'wpr-right-aligned' === $this->content_alignment ) { $this->animation = preg_match('/left/i', $settings['timeline_animation']) ? str_replace('left', 'right', $settings['timeline_animation']) : $settings['timeline_animation']; } } if ( preg_match('/left/i', $settings['timeline_animation']) ) { if ( 'wpr-left-aligned' === $this->content_alignment ) { $this->animation = preg_match('/left/i', $settings['timeline_animation']) ? str_replace('left', 'right', $settings['timeline_animation']) : $settings['timeline_animation']; } elseif ( 'wpr-right-aligned' === $this->content_alignment ) { $this->animation = preg_match('/right/i', $settings['timeline_animation']) ? str_replace('right', 'left', $settings['timeline_animation']) : $settings['timeline_animation']; } } } if ( preg_match('/right/i', $settings['timeline_animation']) ) { $this->animation_loadmore_left = preg_match('/right/i', $settings['timeline_animation']) ? str_replace('right', 'left', $settings['timeline_animation']) : $settings['timeline_animation']; $this->animation_loadmore_right = preg_match('/left/i', $settings['timeline_animation']) ? str_replace('left', 'right', $settings['timeline_animation']) : $settings['timeline_animation']; } elseif ( preg_match('/left/i', $settings['timeline_animation']) ) { $this->animation_loadmore_left = preg_match('/left/i', $settings['timeline_animation']) ? str_replace('left', 'right', $settings['timeline_animation']) : $settings['timeline_animation']; $this->animation_loadmore_right = preg_match('/right/i', $settings['timeline_animation']) ? str_replace('right', 'left', $settings['timeline_animation']) : $settings['timeline_animation']; } } public function add_custom_horizontal_timeline_attributes($content, $settings, $index) { $this->timeline_description = $content['repeater_description']; $this->story_date_label = esc_html__($content['repeater_date_label']); $this->story_extra_label = esc_html__($content['repeater_extra_label']); $this->timeline_story_title = wp_kses_post($content['repeater_story_title']); $this->thumbnail_size = $content['wpr_thumbnail_size']; $this->thumbnail_custom_dimension = $content['wpr_thumbnail_custom_dimension']; $this->show_year_label = esc_html__($content['repeater_show_year_label']); $this->timeline_year = esc_html__($content['repeater_year']); $this->title_key = $this->get_repeater_setting_key( 'repeater_story_title', 'timeline_repeater_list', $index ); $this->year_key = $this->get_repeater_setting_key( 'repeater_year', 'timeline_repeater_list', $index ); $this->date_label_key = $this->get_repeater_setting_key( 'repeater_date_label', 'timeline_repeater_list', $index ); $this->extra_label_key = $this->get_repeater_setting_key( 'repeater_extra_label', 'timeline_repeater_list', $index ); $this->description_key = $this->get_repeater_setting_key( 'repeater_description', 'timeline_repeater_list', $index ); $this->background_image = $settings['content_layout'] === 'background' ? $content['repeater_image']['url'] : ''; $this->background_class = $settings['content_layout'] === 'background' ? 'story-with-background' : ''; $this->add_inline_editing_attributes( $this->title_key, 'none' ); $this->add_inline_editing_attributes( $this->year_key, 'none' ); $this->add_inline_editing_attributes( $this->date_label_key, 'none' ); $this->add_inline_editing_attributes( $this->extra_label_key, 'none' ); $this->add_inline_editing_attributes( $this->description_key, 'advanced' ); $this->add_render_attribute( $this->title_key, ['class'=> 'wpr-title']); $this->add_render_attribute( $this->year_key, ['class'=> 'wpr-year-label wpr-year']); $this->add_render_attribute( $this->date_label_key, ['class'=> 'wpr-label']); $this->add_render_attribute( $this->extra_label_key, ['class'=> 'wpr-sub-label']); $this->add_render_attribute( $this->description_key, ['class'=> 'wpr-description']); } public function render_image_or_icon($content) { if( ( isset($content['repeater_image']['id']) && $content['repeater_image']['id'] != "" ) ) { if($this->thumbnail_size == 'custom'){ $custom_size = [$this->thumbnail_custom_dimension['width'], $this->thumbnail_custom_dimension['height'] ]; $this->image= wp_get_attachment_image($content['repeater_image']['id'], $custom_size , true); } else{ $this->image= wp_get_attachment_image($content['repeater_image']['id'], $this->thumbnail_size, true); } } elseif (isset($content['repeater_image']['url']) && $content['repeater_image']['url'] != "") { $this->image = ''; } elseif ($content['repeater_timeline_item_icon'] != '') { ob_start(); \Elementor\Icons_Manager::render_icon( $content['repeater_timeline_item_icon'], [ 'aria-hidden' => 'true' ] ); $icon_image = ob_get_clean(); $this->image = $icon_image; } else { $this->image =''; } } public function wpr_render_swiper_navigation($settings) { echo '
'. \WprAddons\Classes\Utilities::get_wpr_icon( $settings['swiper_nav_icon'], '' ) .'
'. \WprAddons\Classes\Utilities::get_wpr_icon( $settings['swiper_nav_icon'], '' ) .'
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } public function render_pagination($settings, $paged) {} // Get Animation Class public function get_animation_class( $data, $object ) { $class = ''; // Animation Class if ( 'none' !== $data[ $object .'_animation'] ) { $class .= ' wpr-'. $object .'-'. $data[ $object .'_animation']; $class .= ' wpr-anim-size-'. $data[ $object .'_animation_size']; $class .= ' wpr-anim-timing-'. $data[ $object .'_animation_timing']; if ( 'yes' === $data[ $object .'_animation_tr'] ) { $class .= ' wpr-anim-transparency'; } } return $class; } public static function youtube_url ( $story_settings ) { if ( $story_settings['repeater_youtube_video_url'] != '' ) { preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $story_settings['repeater_youtube_video_url'], $matches); if ( isset($matches[1]) ) { $id = $matches[1]; $media = ''; } } elseif ( empty($story_settings['repeater_youtube_video_url']) ) { $media = ''; } else { $media = __("Wrong URL","wpr-addons"); } return $media; } public function horizontal_timeline_classes($settings) { $this->slidesToShow = isset($settings['slides_to_show']) && !empty($settings['slides_to_show']) ? $settings['slides_to_show'] : 2; if ( ! wpr_fs()->can_use_premium_code() && $this->slidesToShow > 4 ) { $this->slidesToShow = 4; } if ( $settings['timeline_layout'] == 'horizontal' ) { $horizontal_class = 'wpr-horizontal-wrapper'; } elseif ( $settings['timeline_layout'] == 'horizontal-bottom' ) { $horizontal_class = 'wpr-horizontal-bottom-wrapper'; } $this->horizontal_inner_class = $horizontal_class == 'wpr-horizontal-wrapper' ? 'wpr-horizontal' : 'wpr-horizontal-bottom'; $this->horizontal_timeline_class = $this->horizontal_inner_class == 'wpr-horizontal' ? 'wpr-horizontal-timeline' : 'wpr-horizontal-bottom-timeline'; $this->swiper_class = $this->horizontal_timeline_class === 'wpr-horizontal-timeline' ? 'swiper-slide-line-bottom' : 'swiper-slide-line-top'; } public function render_custom_vertical_timeline($layout, $settings, $data, $countItem ) { echo '
'; echo '
'; echo 'yes' === $this->timeline_fill ? '
' : ''; foreach ( $data as $index => $content ) { if ( ! wpr_fs()->can_use_premium_code() && $index === 4 ) { break; } $repeater_title_link = isset($content['repeater_title_link']) && !empty($content['repeater_title_link']['url']) ? $content['repeater_title_link'] : ''; if ( !empty( $content['repeater_title_link']['url'] ) ) { $this->add_link_attributes( 'repeater_title_link'. $this->item_url_count, $repeater_title_link ); } $this->content_and_animation_alignment($layout, $countItem, $settings); $this->thumbnail_size = $content['wpr_thumbnail_size']; $this->thumbnail_custom_dimension = $content['wpr_thumbnail_custom_dimension']; $this->show_year_label = esc_html__($content['repeater_show_year_label']); $this->timeline_year = esc_html__($content['repeater_year']); $this->render_image_or_icon($content); $background_image = $settings['content_layout'] === 'background' ? $content['repeater_image']['url'] : ''; $background_class = $settings['content_layout'] === 'background' ? 'story-with-background' : ''; if ( $content['repeater_show_year_label'] == 'yes' ) { echo ''; echo ''. esc_html__($content['repeater_year']) .''; echo ''; } echo '
'; if ( 'yes' === $content['repeater_show_extra_label'] ) { echo !empty($content['repeater_date_label']) || !empty($content['repeater_extra_label']) ? '' : ''; } echo '
'; echo '
'; \Elementor\Icons_Manager::render_icon( $content['repeater_story_icon'], [ 'aria-hidden' => 'true' ] ); echo '
'; echo '
'; $countItem = $countItem +1; $this->item_url_count++; } echo'
'; } // end of render_custom_vertical_timeline public function render_dynamic_vertical_timeline($settings, $arrow_bgcolor, $layout, $countItem, $paged ) { $layout_settings = [ 'pagination_type' => $settings['pagination_type'], ]; $this->add_render_attribute( 'grid-settings', [ 'data-settings' => wp_json_encode( $layout_settings ), ] ); wp_reset_postdata(); if(!$this->my_query->have_posts()) { echo '
'. esc_html__($settings['query_not_found_text']) .'
'; } if ( $this->my_query->have_posts() ) { echo '
'; echo '
'; echo '
'; echo 'yes' === $this->timeline_fill ? '
' : ''; while ( $this->my_query->have_posts() ) { global $wp_query; $counter = $wp_query->current_post++; $this->my_query->the_post(); $id = get_post_thumbnail_id(); $this->src = Group_Control_Image_Size::get_attachment_image_src( $id, 'wpr_thumbnail_dynamic', $settings ); $this->content_and_animation_alignment($layout, $countItem, $settings); $background_image = $settings['content_layout'] === 'background' ? get_the_post_thumbnail_url() : ''; $background_class = $settings['content_layout'] === 'background' ? 'story-with-background' : ''; echo '
'; if ( 'yes' === $settings['show_extra_label'] ) { echo ''; } echo '
'; echo '
'; \Elementor\Icons_Manager::render_icon( $settings['posts_icon'], [ 'aria-hidden' => 'true' ] ); echo '
'; echo ''; echo '
'; echo '
'; $countItem++; } echo'
'; echo '
'; // Pagination if(!($settings['posts_per_page'] >= wp_count_posts($settings['timeline_post_types'])->publish)) { $this->render_pagination($settings, $paged); } } } // end rendern_dynamic_vertical_timeline public function render_custom_horizontal_timeline( $settings, $autoplay, $loop, $dir, $data, $slidesHeight, $swiper_speed, $swiper_delay, $swiper_pause_on_hover ) { $this->horizontal_timeline_classes($settings); echo '
'; echo '
'; echo '
'; if ( is_array($data) ) { foreach( $data as $index => $content ) { if ( ! wpr_fs()->can_use_premium_code() && $index === 4 ) { break; } $repeater_title_link = isset($content['repeater_title_link']) && !empty($content['repeater_title_link']['url']) ? $content['repeater_title_link'] : ''; if ( ! empty( $content['repeater_title_link']['url'] ) ) { $this->add_link_attributes( 'repeater_title_link'. $this->item_url_count, $content['repeater_title_link'] ); } $this->add_custom_horizontal_timeline_attributes($content, $settings, $index); $this->thumbnail_custom_dimension = $content['wpr_thumbnail_custom_dimension']; $this->render_image_or_icon($content); echo '
'; if ( 'yes' === $content['repeater_show_extra_label'] ) { echo !empty($this->story_date_label) || !empty($this->story_extra_label) ? '
' : ''; echo !empty($this->story_date_label) ? 'get_render_attribute_string( $this->date_label_key ) .' >'. esc_html__($this->story_date_label) .'' : ''; echo !empty($this->story_extra_label) ? 'get_render_attribute_string( $this->extra_label_key ) .' >'. wp_kses_post($this->story_extra_label) .'' : ''; echo !empty($this->story_date_label) || !empty($this->story_extra_label) ? '
' : ''; } echo '
'; \Elementor\Icons_Manager::render_icon( $content['repeater_story_icon'], [ 'aria-hidden' => 'true' ] ); echo'
'; echo ''; echo '
'; $this->item_url_count++; } } $this->wpr_render_swiper_navigation($settings); echo '
'; } public function render_dynamic_horizontal_timeline ( $settings, $dir, $autoplay, $loop, $slidesHeight, $swiper_speed, $swiper_delay, $swiper_pause_on_hover ) { wp_reset_postdata(); $this->horizontal_timeline_classes($settings); if(!$this->my_query->have_posts()) { echo '
'. esc_html__($settings['query_not_found_text']) .'
'; } if( $this->my_query->have_posts() ) { echo '
'; echo '
'; while( $this->my_query->have_posts() ) { $this->my_query->the_post(); $id = get_post_thumbnail_id(); $this->src = Group_Control_Image_Size::get_attachment_image_src( $id, 'wpr_thumbnail_dynamic', $settings ); $background_image = $settings['content_layout'] === 'background' ? get_the_post_thumbnail_url() : ''; $background_class = $settings['content_layout'] === 'background' ? 'story-with-background' : ''; echo '
'; // TODO: apply animation class to other layouts as well echo ''; if ( 'yes' === $settings['show_extra_label'] ) { echo '
'. esc_html__(get_the_date($settings['date_format'])) .'
'; } echo '
'; \Elementor\Icons_Manager::render_icon( $settings['posts_icon'], [ 'aria-hidden' => 'true' ] ); echo'
'; echo '
'; } $this->wpr_render_swiper_navigation($settings); echo '
'; } } public function add_option_query_source() { $post_types = []; $post_types['post'] = esc_html__( 'Posts', 'wpr-addons' ); $post_types['page'] = esc_html__( 'Pages', 'wpr-addons' ); $custom_post_types = Utilities::get_custom_types_of( 'post', true ); foreach( $custom_post_types as $slug => $title ) { if ( 'product' === $slug || 'e-landing-page' === $slug ) { continue; } if ( !wpr_fs()->can_use_premium_code() ) { $post_types['pro-'. substr($slug, 0, 2)] = esc_html__( $title ) .' (Expert)'; } else { $post_types[$slug] = esc_html__( $title ); } } $post_types['current'] = esc_html__( 'Current Query', 'wpr-addons' ); $post_types['pro-rl'] = esc_html__( 'Related Query (Pro)', 'wpr-addons' ); return $post_types; } protected function render() { $settings = $this->get_settings_for_display(); global $paged; $paged = 1; $this->my_query = 'dynamic' === $settings['timeline_content'] ? new \WP_Query ($this->get_main_query_args()) : ''; $layout = $settings['timeline_layout']; $this->animation = $settings['timeline_animation']; $this->animation_loadmore_left = ''; $this->animation_loadmore_right = ''; $this->timeline_fill = $settings['timeline_fill']; $this->show_readmore = !empty($settings['show_readmore']) ? $settings['show_readmore'] : ''; $data = $settings['timeline_repeater_list']; $loop = ! wpr_fs()->can_use_premium_code() && !isset($settings['swiper_loop']) ? '' : $settings['swiper_loop']; $autoplay = ! wpr_fs()->can_use_premium_code() && !isset($settings['swiper_autoplay']) ? '' : $settings['swiper_autoplay']; // $this->pause_on_hover = ! wpr_fs()->can_use_premium_code() && !isset($settings['pause_on_hover']) ? '' : $settings['pause_on_hover']; $swiper_delay = ! wpr_fs()->can_use_premium_code() && !isset($settings['swiper_delay']) ? 0 : $settings['swiper_delay']; $swiper_pause_on_hover = ! wpr_fs()->can_use_premium_code() && !isset($settings['swiper_pause_on_hover']) ? '' : $settings['swiper_pause_on_hover']; $swiper_speed = $settings['swiper_speed']; $slidesHeight = $settings['equal_height_slides']; $this->pagination_type = !empty($settings['pagination_type']) ? $settings['pagination_type'] : ''; $this->pagination_max_pages = !empty($this->get_max_num_pages( $settings )) ? $this->get_max_num_pages( $settings ) : ''; $arrow_bgcolor = $settings['triangle_bgcolor']; $animation_settings = [ 'overlay_animation' => $settings['overlay_animation'], 'overlay_animation_size' => $settings['overlay_animation_size'], 'overlay_animation_timing' => $settings['overlay_animation_timing'], 'overlay_animation_tr' => $settings['overlay_animation_tr'], ]; $this->animation_class = $this->get_animation_class( $animation_settings, 'overlay' ); $isRTL = is_rtl(); $dir = ''; if($isRTL){ $dir = 'rtl'; } if ( 'one-sided' === $layout ){ $this->timeline_layout = "wpr-one-sided-timeline"; $this->timeline_layout_wrapper = "wpr-one-sided-wrapper"; } elseif ( 'centered' === $layout) { $this->timeline_layout = 'wpr-both-sided-timeline'; $this->timeline_layout_wrapper = 'wpr-centered'; } elseif ( 'one-sided-left' === $layout ) { $this->timeline_layout = "wpr-one-sided-timeline-left"; $this->timeline_layout_wrapper = "wpr-one-sided-wrapper-left"; } elseif ( 'horizontal' === $layout ) { $this->timeline_layout = "wpr-horizontal-timeline"; $this->timeline_layout_wrapper = "wpr-horizontal-wrapper"; } $countItem = !empty($countItem) ? $countItem : 0; $this->item_url_count = 0; if ( 'dynamic' === $settings['timeline_content'] && ('horizontal' === $layout || 'horizontal-bottom' === $layout) ) { $this->render_dynamic_horizontal_timeline ( $settings, $dir, $autoplay, $loop, $slidesHeight, $swiper_speed, $swiper_delay, $swiper_pause_on_hover ); } elseif ( 'custom' === $settings['timeline_content'] && ('horizontal' === $layout || 'horizontal-bottom' === $layout) ) { $this->render_custom_horizontal_timeline( $settings, $autoplay, $loop, $dir, $data, $slidesHeight, $swiper_speed, $swiper_delay, $swiper_pause_on_hover ); } else { if( 'dynamic' === $settings['timeline_content'] ) { $this->render_dynamic_vertical_timeline($settings, $arrow_bgcolor, $layout, $countItem, $paged ); } else { $this->render_custom_vertical_timeline($layout, $settings, $data, $countItem ); } } } } new Wpr_Posts_Timeline();