$term_ids, 'hide_empty' => false, ] ); $tax_terms_map = []; foreach ($terms as $term) { $taxonomy = $term->taxonomy; $tax_terms_map[$taxonomy][] = $term->term_id; } return $tax_terms_map; } function query_args() { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified in the load-more AJAX handler (check_ajax_referer 'upk-site') before this runs. if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified in the load-more AJAX handler (check_ajax_referer 'upk-site') before this runs. extract( map_deep( wp_unslash( $_POST['settings'] ), 'sanitize_text_field' ) ); } // This handler is reachable unauthenticated (wp_ajax_nopriv_*). Clamp the // page size to a sane positive maximum so a request cannot ask for -1 // ("all posts") or a huge value and turn load-more into a DoS amplifier. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified in the load-more AJAX handler (check_ajax_referer 'upk-site') before this runs. $per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : 0; $per_page = max( 1, min( 100, $per_page ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified in the load-more AJAX handler (check_ajax_referer 'upk-site') before this runs. $offset = isset( $_POST['offset'] ) ? absint( $_POST['offset'] ) : 0; // setmeta args $args = [ 'posts_per_page' => $per_page, 'post_status' => 'publish', 'suppress_filters' => false, 'orderby' => $posts_orderby, 'order' => $posts_order, 'offset' => $offset, ]; /** * set feature image * */ if (isset($posts_only_with_featured_image) && $posts_only_with_featured_image === 'yes') { // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Elementor widget query built from user-configured controls; expected behaviour. $args['meta_query'] = [ [ 'key' => '_thumbnail_id', 'compare' => 'EXISTS', ], ]; } /** * set taxonomy query */ /** * set date query */ $selected_date = $posts_select_date; if (!empty($selected_date)) { $date_query = []; switch ($selected_date) { case 'today': $date_query['after'] = '-1 day'; break; case 'week': $date_query['after'] = '-1 week'; break; case 'month': $date_query['after'] = '-1 month'; break; case 'quarter': $date_query['after'] = '-3 month'; break; case 'year': $date_query['after'] = '-1 year'; break; case 'exact': $after_date = $posts_date_after; if (!empty($after_date)) { $date_query['after'] = $after_date; } $before_date = $posts_date_before; if (!empty($before_date)) { $date_query['before'] = $before_date; } $date_query['inclusive'] = true; break; } if (!empty($date_query)) { $args['date_query'] = $date_query; } } $exclude_by = isset($posts_exclude_by) ? $posts_exclude_by : []; $include_by = isset($posts_include_by) ? $posts_include_by : []; $include_users = []; $exclude_users = []; // print_r($exclude_by); /** * ignore sticky post */ if (!empty($exclude_by) && $posts_source === 'post' && $posts_ignore_sticky_posts === 'yes') { $args['ignore_sticky_posts'] = true; if (in_array('current_post', $exclude_by)) { // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- Elementor widget query built from user-configured controls; expected behaviour. $args['post__not_in'] = [get_the_ID()]; } } /** * set post type */ if ($posts_source === 'manual_selection') { /** * Set Including Manually */ $selected_ids = $posts_selected_ids; $selected_ids = wp_parse_id_list($selected_ids); $args['post_type'] = 'any'; if (!empty($selected_ids)) { $args['post__in'] = $selected_ids; } $args['ignore_sticky_posts'] = 1; } elseif ('current_query' === $posts_source) { /** * Make Current Query */ $args = $GLOBALS['wp_query']->query_vars; $args = apply_filters('ultimate_post_kit/query/get_query_args/current_query', $args); } elseif ('_related_post_type' === $posts_source) { /** * Set Related Query */ $post_id = get_queried_object_id(); $related_post_id = is_singular() && (0 !== $post_id) ? $post_id : null; $args['post_type'] = get_post_type($related_post_id); // $include_by = $this->getGroupControlQueryParamBy('include'); if (in_array('authors', $include_by)) { $args['author__in'] = wp_parse_id_list($settings['posts_include_author_ids']); } else { $args['author__in'] = get_post_field('post_author', $related_post_id); } // $exclude_by = $this->getGroupControlQueryParamBy('exclude'); if (in_array('authors', $exclude_by)) { $args['author__not_in'] = wp_parse_id_list($posts_exclude_author_ids); } if (in_array('current_post', $exclude_by)) { // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- Elementor widget query built from user-configured controls; expected behaviour. $args['post__not_in'] = [get_the_ID()]; } $args['ignore_sticky_posts'] = 1; $args = apply_filters('ultimate_post_kit/query/get_query_args/related_query', $args); } else { // This runs on wp_ajax_nopriv_* and $posts_source comes straight from $_POST, // so restrict it to post types this site already exposes to anonymous visitors. // Without this a request can enumerate published entries of post types that are // deliberately hidden from anonymous access (e.g. Elementor's elementor_library). $args['post_type'] = ultimate_post_kit_sanitize_public_post_type( $posts_source ); $current_post = []; /** * Set Taxonomy && Set Authors */ $include_terms = []; $exclude_terms = []; $terms_query = []; /** * Set exclude Terms */ if (!empty($exclude_by)) { if (in_array('authors', $exclude_by)) { $exclude_users = wp_parse_id_list($posts_exclude_author_ids); $include_users = array_diff($include_users, $exclude_users); } if (!empty($exclude_users)) { $args['author__not_in'] = $exclude_users; } if (in_array('current_post', $exclude_by) && is_singular()) { $current_post[] = get_the_ID(); } if (in_array('manual_selection', $exclude_by)) { $exclude_ids = $posts_exclude_ids; // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- Elementor widget query built from user-configured controls; expected behaviour. $args['post__not_in'] = array_merge($current_post, wp_parse_id_list($exclude_ids)); } if (in_array('terms', $exclude_by)) { $exclude_terms = wp_parse_id_list($posts_exclude_term_ids); $include_terms = array_diff($include_terms, $exclude_terms); } if (!empty($exclude_terms)) { $tax_terms_map = $this->mapGroupControlQuery($exclude_terms); foreach ($tax_terms_map as $tax => $terms) { $terms_query[] = [ 'taxonomy' => $tax, 'field' => 'term_id', 'terms' => $terms, 'operator' => 'NOT IN', ]; } } } /** * Set include Terms */ if (!empty($include_by)) { if (in_array('authors', $include_by)) { $include_users = wp_parse_id_list($posts_include_author_ids); } if (!empty($include_users)) { $args['author__in'] = $include_users; } if (in_array('terms', $include_by)) { $include_terms = wp_parse_id_list($posts_include_term_ids); } $tax_terms_map = $this->mapGroupControlQuery($include_terms); foreach ($tax_terms_map as $tax => $terms) { $terms_query[] = [ 'taxonomy' => $tax, 'field' => 'term_id', 'terms' => $terms, 'operator' => 'IN', ]; } } if (!empty($terms_query)) { // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Elementor widget query built from user-configured controls; expected behaviour. $args['tax_query'] = $terms_query; $args['tax_query']['relation'] = 'AND'; } } $ajaxposts = new \WP_Query($args); return $ajaxposts; } /** * Render Ajax LoadMore */ function render_ajax_loadmore() { $settings = $this->get_settings_for_display(); if (!$this->get_settings('ajax_loadmore_enable')) { return; } ?>
', esc_url($placeholder_image_src), esc_attr(get_the_title())); } else { print(wp_get_attachment_image( $image_id, $size, false, [ 'class' => 'upk-img', 'alt' => esc_attr(get_the_title()) ] )); } } /** * Old Image Render Method * Not Using Anymore * @return void */ function __render_image($image_id, $size) { $placeholder_image_src = Utils::get_placeholder_image_src(); $image_src = wp_get_attachment_image_src($image_id, $size); if (!$image_src) { $image_src = $placeholder_image_src; } else { $image_src = $image_src[0]; } ?> <?php echo esc_attr(get_the_title()); ?> get_settings_for_display(); if (!$this->get_settings('show_title')) { return; } // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. apply_filters('upk/' . $widget_name . '/before/title', ''); $title = get_the_title(); printf( '<%1$s class="upk-title">%3$s', esc_attr(Utils::get_valid_html_tag($settings['title_tags'])), esc_url( get_permalink() ), esc_html( $title ), esc_attr($settings['title_style']), esc_attr( $title ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. apply_filters('upk/' . $widget_name . '/after/title', ''); } function render_category() { if (!$this->get_settings('show_category')) { return; } ?>
get_settings('posts_source')) ); ?>
get_settings_for_display(); if (!$this->get_settings('show_date')) { return; } $meta_separator = isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '.'; ?>
get_settings_for_display(); if (!$this->get_settings('show_excerpt')) { return; } $strip_shortcode = $this->get_settings_for_display('strip_shortcode'); $ellipsis = isset($settings['ellipsis']) ? $settings['ellipsis'] : '' ; ?>
get_settings_for_display(); if (!$settings['show_post_format']) { return; } ?>