'AND'];
foreach ( $selectedTaxonomies as $taxonomy => $terms ){
if( count( $terms ) ){
$termsQuery[] = [
'taxonomy' => $taxonomy,
'field' => 'term_id',
'terms' => $terms,
];
}
}
$defaultPostQuery = 'post' === $postType ? [
'category__in' => $selectedCategories,
'tag__in' => $selectedTags ?? []
] : [];
$postsInclude = Functions::filterNaN( $postsInclude ?? [] );
$post__in = !empty( $postsInclude ) ? [ 'post__in' => $postsInclude ] : [];
$postsExclude = Functions::filterNaN( $postsExclude ?? [] );
$query = array_merge( [
'post_type' => $postType,
'posts_per_page' => $isPostsPerPageAll ? -1 : $postsPerPage,
'orderby' => $postsOrderBy,
'order' => $postsOrder,
'tax_query' => $termsQuery,
'offset' => $isPostsPerPageAll ? 0 : $postsOffset,
'post__not_in' => $isExcludeCurrent ? array_merge( [ get_the_ID() ], $postsExclude ) : $postsExclude,
'has_password' => false,
'post_status' => 'publish'
], $post__in, $defaultPostQuery );
if( Utils::isPro() ) {
$query = apply_filters( 'b_blocks_posts_query', $query );
}
return $query;
}
static function getPosts( $attributes, $pageNumber = 1 ){
extract( $attributes );
$attributes['isPostsPerPageAll'] = 'true' === $isPostsPerPageAll;
$attributes['isExcludeCurrent'] = 'true' === $isExcludeCurrent;
$newArgs = wp_parse_args( [ 'offset' => ( $postsPerPage * ( $pageNumber - 1 ) ) + $postsOffset ], self::query( $attributes ) );
$posts = Functions::arrangedPosts(
get_posts( $newArgs ),
$postType,
$fImgSize,
$metaDateFormat,
$isExcerptFromContent || 'true' === $isExcerptFromContent,
$excerptLength
);
return $posts;
}
static function skeletonArticle( $prefix ){
$articleEl = "