Improve shortcodes
Added function to get default args instead of doing it again in each shortcode.
This commit is contained in:
parent
527e7f1e6c
commit
bd0158a631
@ -547,6 +547,8 @@ Renders a two-column grid of small cards, showing the latest four chapters order
|
||||
* **source:** Set `false` to hide the author and story nodes. Default `true`.
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool.
|
||||
@ -579,6 +581,8 @@ Renders the last blog post or a list of blog posts, ignoring sticky posts, order
|
||||
* **author:** Only show posts of a specific author. Make sure to write the name right.
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool.
|
||||
@ -611,6 +615,8 @@ Renders a two-column grid of small cards, showing the latest four recommendation
|
||||
* **orderby:** The default is `date`, but you can also use `modified` and [more](https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters).
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool.
|
||||
@ -646,6 +652,8 @@ Renders a two-column grid of small cards, showing the latest four stories ordere
|
||||
* **orderby:** The default is `date`, but you can also use `modified` and [more](https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters).
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool.
|
||||
@ -680,6 +688,8 @@ Renders a two-column grid of small cards, showing the latest four updated storie
|
||||
* **order:** Either `desc` (descending) or `asc` (ascending). Default `desc`.
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool.
|
||||
@ -733,6 +743,8 @@ Renders dynamic grid of thumbnails with title, showing the latest eight posts of
|
||||
* **orderby:** The default is `date`, but you can also use `rand` and [more](https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters).
|
||||
* **post_ids:** Comma-separated list of post IDs, if you want to pick from a curated pool.
|
||||
* **ignore_protected:** Whether protected posts should be ignored or not. Default `false`.
|
||||
* **author_ids:** Only show posts of a comma-separated list of author IDs.
|
||||
* **exclude_author_ids:** Comma-separated list of author IDs to exclude.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs to exclude.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude.
|
||||
* **no_cap:** Set `true` if you want to hide the caption.
|
||||
|
18
FILTERS.md
18
FILTERS.md
@ -744,6 +744,8 @@ Filters the query arguments in the `fictioneer_blog` shortcode.
|
||||
* $ignore_protected (boolean) – Optional. Whether to ignore protected posts. Default `false`.
|
||||
* $author (boolean|string) – Limit posts to a specific author. Default `false`.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $relation (string) – Relationship between taxonomies. Default `'AND'`.
|
||||
@ -797,6 +799,8 @@ Filters the query arguments in the `fictioneer_latest_chapters` shortcode. The o
|
||||
* $spoiler (boolean) – Optional. Show preview un-obfuscated. Default `false`.
|
||||
* $source (boolean) – Optional. Show chapter source story. Default `true`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
@ -828,6 +832,8 @@ Filters the query arguments in the `fictioneer_latest_posts` shortcode. The opti
|
||||
* $count (int) – Maximum number of posts. Default `-1`.
|
||||
* $author (boolean|string) – Limit posts to a specific author. Default `false`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
@ -860,6 +866,8 @@ Filters the query arguments in the `fictioneer_latest_recommendations` shortcode
|
||||
* $order (string) – Order argument. Default `'DESC'`.
|
||||
* $orderby (string) – Orderby argument. Default `'date'`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
@ -920,6 +928,8 @@ Filters the query arguments in the `fictioneer_latest_stories` shortcode. The op
|
||||
* $order (string) – Order argument. Default `'DESC'`.
|
||||
* $orderby (string) – Orderby argument. Default `'date'`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
@ -956,7 +966,7 @@ Filters the query arguments in the `fictioneer_latest_updates` shortcode. The op
|
||||
* $order (string) – `$args['order']`
|
||||
* $orderby (string) – `'meta_value'`
|
||||
* $meta_key (string) – `'fictioneer_chapters_added'`
|
||||
* $posts_per_page (int) – `$args['count']`
|
||||
* $posts_per_page (int) – `$args['count'] + 4` (accounts for non-eligible posts)
|
||||
* $meta_query (array)
|
||||
* $relation (string) – `'OR'`
|
||||
* (array)
|
||||
@ -977,6 +987,8 @@ Filters the query arguments in the `fictioneer_latest_updates` shortcode. The op
|
||||
* $author (boolean|string) – Limit posts to a specific author. Default `false`.
|
||||
* $order (string) – Order argument. Default `'DESC'`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
@ -1005,12 +1017,14 @@ Filters the query arguments in the `fictioneer_showcase` shortcode. The optional
|
||||
* $no_found_rows (boolean) – `true`
|
||||
|
||||
**$args:**
|
||||
* $type (string) – Either `'fcn_collection'`, `'fcn_story'`, `'fcn_chapter'`, or `'fcn_recommendation'`.
|
||||
* $post_type (string) – Either `'fcn_collection'`, `'fcn_story'`, `'fcn_chapter'`, or `'fcn_recommendation'`.
|
||||
* $count (int) – Maximum number of posts. Default `-1`.
|
||||
* $author (boolean|string) – Limit posts to a specific author. Default `false`.
|
||||
* $order (string) – Order argument. Default `'DESC'`.
|
||||
* $orderby (string) – Orderby argument. Default `'date'`.
|
||||
* $post_ids (array) – Limit posts to specific post IDs. Default empty.
|
||||
* $author_ids (array) – Limit posts to specific author IDs. Default empty.
|
||||
* $excluded_authors (array) – Exclude specific author IDs. Default empty.
|
||||
* $excluded_tags (array) – Exclude specific tag names. Default empty.
|
||||
* $excluded_cats (array) – Exclude specific category names. Default empty.
|
||||
* $ignore_protected (boolean) – Whether to ignore protected posts. Default `false`.
|
||||
|
@ -117,6 +117,59 @@ if ( FICTIONEER_RELATIONSHIP_PURGE_ASSIST ) {
|
||||
add_action( 'save_post', 'fictioneer_update_shortcode_relationships', 10, 2 );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// GET SHORTCODE DEFAULT ARGS
|
||||
// =============================================================================
|
||||
|
||||
function fictioneer_get_default_shortcode_args( $attr, $def_count = -1 ) {
|
||||
//--- Sanitize attributes ----------------------------------------------------
|
||||
|
||||
$attr = is_array( $attr ) ?
|
||||
array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
|
||||
//--- Setup ------------------------------------------------------------------
|
||||
|
||||
$order = [sanitize_key( $attr['order'] ?? 'desc' )];
|
||||
$order = array_intersect( $order, ['desc', 'asc'] );
|
||||
$order = reset( $order ) ?: 'desc';
|
||||
$orderby = [sanitize_key( $attr['orderby'] ?? 'date' )];
|
||||
$orderby = array_intersect( $orderby, fictioneer_allowed_orderby() );
|
||||
$orderby = reset( $orderby ) ?: 'modified';
|
||||
|
||||
//--- Extract arguments ------------------------------------------------------
|
||||
|
||||
$args = array(
|
||||
'count' => max( -1, intval( $attr['count'] ?? $def_count ) ),
|
||||
'offset' => max( 0, intval( $attr['offset'] ?? 0 ) ),
|
||||
'order' => $order,
|
||||
'orderby' => $orderby,
|
||||
'page' => max( 1, get_query_var( 'page' ) ?: get_query_var( 'paged' ) ),
|
||||
'posts_per_page' => absint( $attr['per_page'] ?? 0 ) ?: get_option( 'posts_per_page' ),
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'author_ids' => fictioneer_explode_list( $attr['author_ids'] ?? '' ),
|
||||
'excluded_authors' => fictioneer_explode_list( $attr['exclude_author_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'ignore_sticky' => filter_var( $attr['ignore_sticky'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
//--- Fixes ------------------------------------------------------------------
|
||||
|
||||
// Update count if limited to post IDs
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
|
||||
//--- Finish -----------------------------------------------------------------
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// GET SHORTCODE TAXONOMIES
|
||||
// =============================================================================
|
||||
@ -270,59 +323,41 @@ function fictioneer_get_shortcode_tax_query( $args ) {
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_showcase( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
|
||||
// Abort if...
|
||||
if ( empty( $attr['for'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepare arguments
|
||||
$args = array(
|
||||
'count' => max( 1, intval( $attr['count'] ?? 8 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'orderby' => $attr['orderby'] ?? 'date',
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'no_cap' => filter_var( $attr['no_cap'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 8 );
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
// Specifics
|
||||
$args['no_cap'] = filter_var( $attr['no_cap'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||
|
||||
switch ( $attr['for'] ) {
|
||||
case 'collections':
|
||||
$args['type'] = 'fcn_collection';
|
||||
$args['post_type'] = 'fcn_collection';
|
||||
break;
|
||||
case 'chapters':
|
||||
$args['type'] = 'fcn_chapter';
|
||||
$args['post_type'] = 'fcn_chapter';
|
||||
break;
|
||||
case 'stories':
|
||||
$args['type'] = 'fcn_story';
|
||||
$args['post_type'] = 'fcn_story';
|
||||
break;
|
||||
case 'recommendations':
|
||||
$args['type'] = 'fcn_recommendation';
|
||||
$args['post_type'] = 'fcn_recommendation';
|
||||
break;
|
||||
}
|
||||
|
||||
// Abort if...
|
||||
if ( ! isset( $args['type'] ) ) {
|
||||
if ( ! isset( $args['post_type'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
$base = serialize( $args ) . serialize( $attr );
|
||||
$type = $args['type'];
|
||||
$type = $args['post_type'];
|
||||
$transient_key = "fictioneer_shortcode_showcase_{$type}_html_" . md5( $base );
|
||||
$transient = get_transient( $transient_key );
|
||||
|
||||
@ -379,34 +414,16 @@ add_shortcode( 'fictioneer_showcase', 'fictioneer_shortcode_showcase' );
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_chapters( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 4 );
|
||||
|
||||
// Specifics
|
||||
$args['simple'] = false;
|
||||
$args['spoiler'] = ( $attr['spoiler'] ?? false ) == 'true';
|
||||
$args['source'] = ( $attr['source'] ?? 'true' ) == 'true';
|
||||
|
||||
// Type
|
||||
$type = $attr['type'] ?? 'default';
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'simple' => false,
|
||||
'count' => max( 1, intval( $attr['count'] ?? 4 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'orderby' => $attr['orderby'] ?? 'date',
|
||||
'spoiler' => ( $attr['spoiler'] ?? false ) == 'true',
|
||||
'source' => ( $attr['source'] ?? 'true' ) == 'true',
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -474,31 +491,11 @@ add_shortcode( 'fictioneer_chapter_cards', 'fictioneer_shortcode_latest_chapters
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_stories( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 4 );
|
||||
|
||||
// Type
|
||||
$type = $attr['type'] ?? 'default';
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'count' => max( 1, intval( $attr['count'] ?? 4 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'orderby' => $attr['orderby'] ?? 'date',
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -563,30 +560,11 @@ add_shortcode( 'fictioneer_story_cards', 'fictioneer_shortcode_latest_stories' )
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_story_updates( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 4 );
|
||||
|
||||
// Type
|
||||
$type = $attr['type'] ?? 'default';
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'count' => max( 1, intval( $attr['count'] ?? 4 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -654,31 +632,11 @@ add_shortcode( 'fictioneer_update_cards', 'fictioneer_shortcode_latest_story_upd
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_recommendations( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 4 );
|
||||
|
||||
// Type
|
||||
$type = $attr['type'] ?? 'default';
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'count' => max( 1, intval( $attr['count'] ?? 4 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'orderby' => $attr['orderby'] ?? 'date',
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -739,26 +697,8 @@ add_shortcode( 'fictioneer_recommendation_cards', 'fictioneer_shortcode_latest_r
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_posts( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'count' => max( 1, intval( $attr['count'] ?? 1 ) ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr, 1 );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -1273,24 +1213,8 @@ add_shortcode( 'fictioneer_search', 'fictioneer_shortcode_search' );
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_blog( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
|
||||
// Setup
|
||||
$args = array(
|
||||
'posts_per_page' => absint( $attr['per_page'] ?? 0 ) ?: get_option( 'posts_per_page' ),
|
||||
'page' => max( 1, get_query_var( 'page' ) ?: get_query_var( 'paged' ) ),
|
||||
'ignore_sticky' => filter_var( $attr['ignore_sticky'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'author_ids' => fictioneer_explode_list( $attr['author_ids'] ?? '' ),
|
||||
'excluded_authors' => fictioneer_explode_list( $attr['exclude_author_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr );
|
||||
|
||||
// Query arguments
|
||||
$query_args = array(
|
||||
@ -1445,11 +1369,12 @@ add_shortcode( 'fictioneer_blog', 'fictioneer_shortcode_blog' );
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_article_cards( $attr ) {
|
||||
// Sanitize attributes
|
||||
$attr = is_array( $attr ) ? array_map( 'sanitize_text_field', $attr ) : sanitize_text_field( $attr );
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr );
|
||||
|
||||
// Post types...
|
||||
$post_types = fictioneer_explode_list( $attr['post_type'] ?? 'post' );
|
||||
// Post type(s)...
|
||||
$post_types = sanitize_text_field( $attr['post_type'] ?? 'post' );
|
||||
$post_types = fictioneer_explode_list( $post_types );
|
||||
|
||||
$allowed_post_types = array(
|
||||
'post' => 'post',
|
||||
@ -1481,31 +1406,8 @@ function fictioneer_shortcode_article_cards( $attr ) {
|
||||
$query_post_types = array_values( $query_post_types );
|
||||
$query_post_types = empty( $query_post_types ) ? ['post'] : $query_post_types;
|
||||
|
||||
// Args
|
||||
$args = array(
|
||||
'post_type' => $query_post_types,
|
||||
'ignore_sticky' => filter_var( $attr['ignore_sticky'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
|
||||
'count' => intval( $attr['count'] ?? -1 ),
|
||||
'author' => $attr['author'] ?? false,
|
||||
'order' => $attr['order'] ?? 'DESC',
|
||||
'orderby' => $attr['orderby'] ?? 'date',
|
||||
'page' => max( 1, get_query_var( 'page' ) ?: get_query_var( 'paged' ) ),
|
||||
'posts_per_page' => absint( $attr['per_page'] ?? 0 ) ?: get_option( 'posts_per_page' ),
|
||||
'post_ids' => fictioneer_explode_list( $attr['post_ids'] ?? '' ),
|
||||
'author_ids' => fictioneer_explode_list( $attr['author_ids'] ?? '' ),
|
||||
'excluded_authors' => fictioneer_explode_list( $attr['exclude_author_ids'] ?? '' ),
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND',
|
||||
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
|
||||
);
|
||||
|
||||
// Post IDs?
|
||||
if ( ! empty( $args['post_ids'] ) ) {
|
||||
$args['count']= count( $args['post_ids'] );
|
||||
}
|
||||
// ... add to args
|
||||
$args['post_type'] = $query_post_types;
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
|
@ -38,8 +38,8 @@ $query_args = array(
|
||||
'post_type' => 'fcn_chapter',
|
||||
'post_status' => 'publish',
|
||||
'post__in' => $args['post_ids'], // May be empty!
|
||||
'order' => $args['order'] ?? 'DESC',
|
||||
'orderby' => $args['orderby'] ?? 'date',
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'posts_per_page' => $args['count'] + 8, // Little buffer in case of unpublished parent story
|
||||
'meta_key' => 'fictioneer_chapter_hidden',
|
||||
'meta_value' => 0,
|
||||
@ -47,8 +47,15 @@ $query_args = array(
|
||||
'update_post_term_cache' => false
|
||||
);
|
||||
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
// Author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
@ -65,6 +72,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -48,11 +48,16 @@ $query_args = array(
|
||||
'update_post_term_cache' => false
|
||||
);
|
||||
|
||||
// Parameter for author?
|
||||
// Author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -68,6 +73,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -44,6 +44,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -59,6 +64,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -36,8 +36,8 @@ $query_args = array (
|
||||
'post_type' => 'fcn_recommendation',
|
||||
'post_status' => 'publish',
|
||||
'post__in' => $args['post_ids'], // May be empty!
|
||||
'orderby' => $args['orderby'] ?? 'date',
|
||||
'order' => $args['order'] ?? 'DESC',
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'posts_per_page' => $args['count'],
|
||||
'no_found_rows' => true
|
||||
);
|
||||
@ -47,6 +47,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -62,6 +67,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -47,6 +47,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -62,6 +67,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -62,11 +62,16 @@ if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
|
||||
);
|
||||
}
|
||||
|
||||
// Parameter for author?
|
||||
// Author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -82,6 +87,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -59,11 +59,16 @@ if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
|
||||
);
|
||||
}
|
||||
|
||||
// Parameter for author?
|
||||
// Author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -79,6 +84,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -42,7 +42,7 @@ $query_args = array(
|
||||
'order' => $args['order'],
|
||||
'orderby' => 'meta_value',
|
||||
'meta_key' => 'fictioneer_chapters_added',
|
||||
'posts_per_page' => $args['count'],
|
||||
'posts_per_page' => $args['count'] + 4, // Account for non-eligible posts!
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
@ -63,6 +63,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -78,6 +83,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -44,7 +44,7 @@ $query_args = array(
|
||||
'order' => $args['order'],
|
||||
'orderby' => 'meta_value',
|
||||
'meta_key' => 'fictioneer_chapters_added',
|
||||
'posts_per_page' => $args['count'],
|
||||
'posts_per_page' => $args['count'] + 4, // Account for non-eligible posts!
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
@ -64,6 +64,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -79,6 +84,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['type'] Post type if the showcase.
|
||||
* @internal $args['post_type'] Post type if the showcase.
|
||||
* @internal $args['count'] Maximum number of items. Default 8.
|
||||
* @internal $args['order'] Order direction. Default 'DESC'.
|
||||
* @internal $args['orderby'] Order argument. Default 'date'.
|
||||
@ -34,7 +34,7 @@ defined( 'ABSPATH' ) OR exit;
|
||||
// Prepare query
|
||||
$query_args = array (
|
||||
'fictioneer_query_name' => 'showcase',
|
||||
'post_type' => $args['type'],
|
||||
'post_type' => $args['post_type'],
|
||||
'post_status' => 'publish',
|
||||
'post__in' => $args['post_ids'], // May be empty!
|
||||
'order' => $args['order'],
|
||||
@ -49,6 +49,11 @@ if ( isset( $args['author'] ) && $args['author'] ) {
|
||||
$query_args['author_name'] = $args['author'];
|
||||
}
|
||||
|
||||
// Author IDs?
|
||||
if ( ! empty( $args['author_ids'] ) ) {
|
||||
$query_args['author__in'] = $args['author_ids'];
|
||||
}
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
@ -64,6 +69,11 @@ if ( ! empty( $args['excluded_cats'] ) ) {
|
||||
$query_args['category__not_in'] = $args['excluded_cats'];
|
||||
}
|
||||
|
||||
// Excluded authors?
|
||||
if ( ! empty( $args['excluded_authors'] ) ) {
|
||||
$query_args['author__not_in'] = $args['excluded_authors'];
|
||||
}
|
||||
|
||||
// Ignore protected?
|
||||
if ( $args['ignore_protected'] ) {
|
||||
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
@ -94,7 +104,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$landscape_image_id = fictioneer_get_field( 'fictioneer_landscape_image', get_the_ID() );
|
||||
|
||||
// Get list title and story ID (if any)
|
||||
switch ( $args['type'] ) {
|
||||
switch ( $args['post_type'] ) {
|
||||
case 'fcn_collection':
|
||||
$list_title = trim( fictioneer_get_field( 'fictioneer_collection_list_title' ) );
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user