' ' . esc_attr($attributes['className']) : '') . '">'; // possible values for "Time Range" and "Order by" $time_units = ['minute', 'hour', 'day', 'week', 'month']; $range_values = ['daily', 'last24hours', 'weekly', 'last7days', 'monthly', 'last30days', 'all', 'custom']; $order_by_values = ['comments', 'views', 'avg']; $theme_data = $this->themer->get_theme($theme); if ( ! isset($theme_data['json']) ) { $theme = ''; } $query_args = [ 'title' => strip_tags($title), // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags -- We want the behavior of strip_tags 'limit' => ( ! empty($limit) && Helper::is_number($limit) && $limit > 0 ) ? $limit : 10, 'offset' => ( ! empty($offset) && Helper::is_number($offset) && $offset >= 0 ) ? $offset : 0, 'range' => ( in_array($range, $range_values) ) ? $range : 'daily', 'time_quantity' => ( ! empty($time_quantity) && Helper::is_number($time_quantity) && $time_quantity > 0 ) ? $time_quantity : 24, 'time_unit' => ( in_array($time_unit, $time_units) ) ? $time_unit : 'hour', 'freshness' => empty($freshness) ? false : $freshness, 'order_by' => ( in_array($order_by, $order_by_values) ) ? $order_by : 'views', 'post_type' => empty($post_type) ? 'post' : $post_type, 'pid' => rtrim(preg_replace('|[^0-9,]|', '', $pid), ','), /** Deprecated */ 'exclude' => rtrim(preg_replace('|[^0-9,]|', '', $exclude), ','), 'taxonomy' => empty($tax) ? 'category' : $tax, 'term_id' => rtrim(preg_replace('|[^0-9,;-]|', '', $term_id), ','), 'author' => rtrim(preg_replace('|[^0-9,]|', '', $author), ','), 'shorten_title' => [ 'active' => ( (bool) $attributes['shorten_title'] && ! empty($title_length) && Helper::is_number($title_length) && $title_length > 0 ), 'length' => ( ! empty($title_length) && Helper::is_number($title_length) ) ? $title_length : 0, 'words' => (( ! empty($title_by_words) && Helper::is_number($title_by_words) && $title_by_words > 0 )), ], 'post-excerpt' => [ 'active' => ( (bool) $attributes['display_post_excerpt'] && ! empty($excerpt_length) && Helper::is_number($excerpt_length) && $excerpt_length > 0 ), 'length' => ( ! empty($excerpt_length) && Helper::is_number($excerpt_length) ) ? $excerpt_length : 0, 'keep_format' => ( ! empty($excerpt_format) && Helper::is_number($excerpt_format) && $excerpt_format > 0 ), 'words' => ( ! empty($excerpt_by_words) && Helper::is_number($excerpt_by_words) && $excerpt_by_words > 0 ), ], 'thumbnail' => [ 'active' => ( 'predefined' == $thumbnail_build && (bool) $attributes['display_post_thumbnail'] ) ? true : ( ! empty($thumbnail_width) && Helper::is_number($thumbnail_width) && $thumbnail_width > 0 ), 'width' => ( ! empty($thumbnail_width) && Helper::is_number($thumbnail_width) && $thumbnail_width > 0 ) ? $thumbnail_width : 0, 'height' => ( ! empty($thumbnail_height) && Helper::is_number($thumbnail_height) && $thumbnail_height > 0 ) ? $thumbnail_height : 0, 'build' => 'predefined' == $thumbnail_build ? 'predefined' : 'manual', 'size' => empty($thumbnail_size) ? '' : $thumbnail_size, ], 'rating' => (bool) $attributes['rating'], 'stats_tag' => [ 'comment_count' => (bool) $attributes['stats_comments'], 'views' => (bool) $attributes['stats_views'], 'author' => (bool) $attributes['stats_author'], 'date' => [ 'active' => (bool) $attributes['stats_date'], 'format' => empty($stats_date_format) ? 'F j, Y' : $stats_date_format ], 'taxonomy' => [ 'active' => (bool) $attributes['stats_taxonomy'], 'name' => empty($taxonomy) ? 'category' : $taxonomy, ] ], 'markup' => [ 'custom_html' => (bool) $attributes['custom_html'], 'wpp-start' => empty($wpp_start) ? '' : $wpp_start, 'wpp-end' => empty($wpp_end) ? '' : $wpp_end, 'title-start' => empty($header_start) ? '' : $header_start, 'title-end' => empty($header_end) ? '' : $header_end, 'post-html' => empty($post_html) ? '
  • {thumb} {title} {stats}
  • ' : $post_html ], 'theme' => [ 'name' => empty($theme) ? '' : $theme ] ]; // Post / Page / CTP filter $query_args['exclude'] = $query_args['pid']; $ids = array_filter(explode(',', $query_args['exclude']), 'is_numeric'); // Got no valid IDs, clear if ( empty($ids) ) { $query_args['pid'] = ''; $query_args['exclude'] = ''; } // Taxonomy filter $ids = array_filter(explode(',', $query_args['term_id']), 'is_numeric'); // Got no valid term IDs, clear if ( empty($ids) ) { $query_args['term_id'] = ''; } // Author filter $ids = array_filter(explode(',', $query_args['author']), 'is_numeric'); // Got no valid IDs, clear if ( empty($ids) ) { $query_args['author'] = ''; } // Has the user set a title? if ( ! empty($query_args['title']) && ! empty($query_args['markup']['title-start']) && ! empty($query_args['markup']['title-end']) ) { $header_html = htmlspecialchars_decode($query_args['markup']['title-start'], ENT_QUOTES) . $query_args['title'] . htmlspecialchars_decode($query_args['markup']['title-end'], ENT_QUOTES); $header_html = apply_filters('wpp_custom_header_html', $header_html, $query_args); $header_html = Helper::sanitize_html($header_html, $query_args); $html .= $header_html; } $isAdmin = isset($_GET['isSelected']) ? $_GET['isSelected'] : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- isSelected is a boolean from wp-admin if ( $this->config['tools']['ajax'] && ! is_customize_preview() && ! $isAdmin ) { $html .= ''; $html .= '
    '; return $html . ''; } $popular_posts = $this->maybe_query($query_args); $this->output->set_data($popular_posts->get_posts()); $this->output->set_public_options($query_args); $this->output->build_output(); $html .= $this->output->get_output(); $html .= ''; return $html; } /** * Parses attributes. * * @since 5.4.0 * @param array * @return array */ private function parse_attributes(array $atts = []) { $out = array(); foreach ( $this->defaults as $name => $default ) { $out[$name] = array_key_exists($name, $atts) ? trim($atts[$name]) : $default; } return $out; } }