| @@ -128,8 +128,9 @@ | ||
| 128 | 128 | $this->add_group_control( |
| 129 | 129 | Group_Control_Image_Size::get_type(), |
| 130 | 130 | [ |
| 131 | 131 | 'name' => 'primary_thumbnail', |
| 132 | + // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. | |
| 132 | 133 | 'exclude' => [ 'custom' ], |
| 133 | 134 | 'default' => 'medium', |
| 134 | 135 | ] |
| 135 | 136 | ); |
| @@ -139,9 +140,9 @@ | ||
| 139 | 140 | // Query Settings |
| 140 | 141 | $this->start_controls_section( |
| 141 | 142 | 'section_post_query_builder', |
| 142 | 143 | [ |
| 143 | - 'label' => __( 'Query', 'ultimate-post-kit' ) . BDTUPK_NC, | |
| 144 | + 'label' => __( 'Query', 'ultimate-post-kit' ), | |
| 144 | 145 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 145 | 146 | ] |
| 146 | 147 | ); |
| 147 | 148 | |
| @@ -158,8 +159,11 @@ | ||
| 158 | 159 | ], |
| 159 | 160 | 'default' => [ |
| 160 | 161 | 'size' => 3, |
| 161 | 162 | ], |
| 163 | + 'condition' => [ | |
| 164 | + 'posts_source!' => 'current_query', | |
| 165 | + ] | |
| 162 | 166 | ] |
| 163 | 167 | ); |
| 164 | 168 | |
| 165 | 169 | $this->register_query_builder_controls(); |
| @@ -168,9 +172,9 @@ | ||
| 168 | 172 | |
| 169 | 173 | $this->start_controls_section( |
| 170 | 174 | 'section_content_additional', |
| 171 | 175 | [ |
| 172 | - 'label' => esc_html__( 'Additional', 'ultimate-post-kit' ), | |
| 176 | + 'label' => esc_html__( 'Additional Options', 'ultimate-post-kit' ), | |
| 173 | 177 | ] |
| 174 | 178 | ); |
| 175 | 179 | |
| 176 | 180 | $this->add_control( |
| @@ -209,8 +213,23 @@ | ||
| 209 | 213 | 'label' => __('Separator', 'ultimate-post-kit'), |
| 210 | 214 | 'type' => Controls_Manager::TEXT, |
| 211 | 215 | 'default' => '//', |
| 212 | 216 | 'label_block' => false, |
| 217 | + 'conditions' => [ | |
| 218 | + 'relation' => 'or', | |
| 219 | + 'terms' => [ | |
| 220 | + [ | |
| 221 | + 'name' => 'show_category', | |
| 222 | + 'operator' => '===', | |
| 223 | + 'value' => 'yes', | |
| 224 | + ], | |
| 225 | + [ | |
| 226 | + 'name' => 'show_author', | |
| 227 | + 'operator' => '===', | |
| 228 | + 'value' => 'yes', | |
| 229 | + ], | |
| 230 | + ], | |
| 231 | + ], | |
| 213 | 232 | ] |
| 214 | 233 | ); |
| 215 | 234 | |
| 216 | 235 | //Global Date Controls |
| @@ -731,20 +750,33 @@ | ||
| 731 | 750 | $this->register_pagination_controls(); |
| 732 | 751 | } |
| 733 | 752 | |
| 734 | 753 | /** |
| 735 | - * Main query render for this widget | |
| 736 | - * @param $posts_per_page number item query limit | |
| 754 | + * Get post query builder arguments | |
| 737 | 755 | */ |
| 738 | 756 | public function query_posts( $posts_per_page ) { |
| 739 | - | |
| 740 | - $default = $this->getGroupControlQueryArgs(); | |
| 741 | - if ( $posts_per_page ) { | |
| 757 | + $settings = $this->get_settings(); | |
| 758 | + $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; | |
| 759 | + $args = $this->getGroupControlQueryArgs(); | |
| 760 | + $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); | |
| 761 | + | |
| 762 | + if ( $is_current_query ) { | |
| 763 | + unset( $args['offset'] ); | |
| 764 | + unset( $args['no_found_rows'] ); | |
| 765 | + $posts_per_page = 0; | |
| 766 | + } | |
| 767 | + | |
| 768 | + if ( $posts_per_page > 0 ) { | |
| 742 | 769 | $args['posts_per_page'] = $posts_per_page; |
| 743 | - $args['paged'] = max( 1, get_query_var( 'paged' ), get_query_var( 'page' ) ); | |
| 770 | + } else { | |
| 771 | + $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); | |
| 744 | 772 | } |
| 745 | - $args = array_merge( $default, $args ); | |
| 746 | - $this->_query = new WP_Query( $args ); | |
| 773 | + | |
| 774 | + if ( $settings['show_pagination'] ) { | |
| 775 | + $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); | |
| 776 | + } | |
| 777 | + | |
| 778 | + $this->_query = new \WP_Query( $args ); | |
| 747 | 779 | } |
| 748 | 780 | |
| 749 | 781 | public function render_author() { |
| 750 | 782 | |
| @@ -808,16 +840,16 @@ | ||
| 808 | 840 | <div class="upk-meta"> |
| 809 | 841 | <?php $this->render_category(); ?> |
| 810 | 842 | |
| 811 | 843 | <?php if ($settings['show_author']) : ?> |
| 812 | - <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 844 | + <div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 813 | 845 | <?php $this->render_author(); ?> |
| 814 | 846 | </div> |
| 815 | 847 | <?php endif; ?> |
| 816 | 848 | <?php if (_is_upk_pro_activated()) : |
| 817 | 849 | if ('yes' === $settings['show_reading_time']) : ?> |
| 818 | - <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>"> | |
| 819 | - <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'] ) ); ?> | |
| 850 | + <div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> | |
| 851 | + <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> | |
| 820 | 852 | </div> |
| 821 | 853 | <?php endif; ?> |
| 822 | 854 | <?php endif; ?> |
| 823 | 855 | </div> |