Add taxonomies to shortcode partials
This commit is contained in:
parent
6a9e56eac5
commit
686469bd77
@ -82,7 +82,7 @@ if ( FICTIONEER_RELATIONSHIP_PURGE_ASSIST ) {
|
||||
*
|
||||
* @since Fictioneer 5.2.0
|
||||
*
|
||||
* @param array $attr Attributes of shortcode.
|
||||
* @param array $attr Attributes of the shortcode.
|
||||
*
|
||||
* @return array Array of found taxonomies.
|
||||
*/
|
||||
@ -120,6 +120,81 @@ function fictioneer_get_shortcode_taxonomies( $attr ) {
|
||||
return $taxonomies;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// GET SHORTCODE TAX QUERY
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Get shortcode Tax Query
|
||||
*
|
||||
* @since Fictioneer 5.2.0
|
||||
*
|
||||
* @param array $args Arguments of the shortcode partial.
|
||||
*
|
||||
* @return array Tax Query.
|
||||
*/
|
||||
|
||||
function fictioneer_get_shortcode_tax_query( $args ) {
|
||||
// Setup
|
||||
$tax_query = [];
|
||||
|
||||
// Are there taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
// Relationship?
|
||||
if ( count( $args['taxonomies'] ) > 1 ) {
|
||||
$tax_query['relation'] = $args['relation'];
|
||||
}
|
||||
|
||||
// Tags?
|
||||
if ( ! empty( $args['taxonomies']['tags'] ) ) {
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['tags']
|
||||
);
|
||||
}
|
||||
|
||||
// Categories?
|
||||
if ( ! empty( $args['taxonomies']['categories'] ) ) {
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['categories']
|
||||
);
|
||||
}
|
||||
|
||||
// Fandoms?
|
||||
if ( ! empty( $args['taxonomies']['fandoms'] ) ) {
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => 'fcn_fandom',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['fandoms']
|
||||
);
|
||||
}
|
||||
|
||||
// Characters?
|
||||
if ( ! empty( $args['taxonomies']['characters'] ) ) {
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => 'fcn_character',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['characters']
|
||||
);
|
||||
}
|
||||
|
||||
// Genres?
|
||||
if ( ! empty( $args['taxonomies']['genres'] ) ) {
|
||||
$tax_query[] = array(
|
||||
'taxonomy' => 'fcn_genre',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['genres']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $tax_query;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SHOWCASE SHORTCODE
|
||||
// =============================================================================
|
||||
|
@ -8,14 +8,16 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @internal $args['post_ids'] Comma-separated list of chapter IDs. Overrides count.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -38,6 +40,11 @@ $query_args = array(
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query chapters
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
@ -8,15 +8,17 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @internal $args['post_ids'] Comma-separated list of chapter IDs. Overrides count.
|
||||
* @internal $args['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -39,6 +41,11 @@ $query_args = array(
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query chapters
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
* @internal $args['count'] The number of posts provided by the shortcode. Default 1.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['classes'] Array of additional CSS classes. Default empty.
|
||||
*/
|
||||
?>
|
||||
@ -37,30 +38,7 @@ if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] =
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = [];
|
||||
|
||||
// Relationship?
|
||||
if ( count( $args['taxonomies'] ) > 1 ) {
|
||||
$query_args['tax_query']['relation'] = $args['relation'];
|
||||
}
|
||||
|
||||
// Tags?
|
||||
if ( ! empty( $args['taxonomies']['tags'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['tags']
|
||||
);
|
||||
}
|
||||
|
||||
// Categories?
|
||||
if ( ! empty( $args['taxonomies']['categories'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['categories']
|
||||
);
|
||||
}
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
|
@ -8,11 +8,13 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Comma-separated list of recommendation IDs. Overrides count.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -35,6 +37,11 @@ $query_args = array (
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query chapters
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
@ -8,12 +8,14 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Comma-separated list of recommendation IDs. Overrides count.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -36,6 +38,11 @@ $query_args = array (
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query recommendations
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
@ -8,12 +8,13 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['classes'] Array of additional CSS classes. Default empty.
|
||||
*/
|
||||
?>
|
||||
@ -37,57 +38,7 @@ if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] =
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = [];
|
||||
|
||||
// Relationship?
|
||||
if ( count( $args['taxonomies'] ) > 1 ) {
|
||||
$query_args['tax_query']['relation'] = $args['relation'];
|
||||
}
|
||||
|
||||
// Tags?
|
||||
if ( ! empty( $args['taxonomies']['tags'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['tags']
|
||||
);
|
||||
}
|
||||
|
||||
// Categories?
|
||||
if ( ! empty( $args['taxonomies']['categories'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['categories']
|
||||
);
|
||||
}
|
||||
|
||||
// Fandoms?
|
||||
if ( ! empty( $args['taxonomies']['fandoms'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_fandom',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['fandoms']
|
||||
);
|
||||
}
|
||||
|
||||
// Characters?
|
||||
if ( ! empty( $args['taxonomies']['characters'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_character',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['characters']
|
||||
);
|
||||
}
|
||||
|
||||
// Genres?
|
||||
if ( ! empty( $args['taxonomies']['genres'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_genre',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['genres']
|
||||
);
|
||||
}
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
|
@ -8,12 +8,13 @@
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.0
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['orderby'] Sorting of posts. Default 'date'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['classes'] Array of additional CSS classes. Default empty.
|
||||
*/
|
||||
?>
|
||||
@ -37,57 +38,7 @@ if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] =
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = [];
|
||||
|
||||
// Relationship?
|
||||
if ( count( $args['taxonomies'] ) > 1 ) {
|
||||
$query_args['tax_query']['relation'] = $args['relation'];
|
||||
}
|
||||
|
||||
// Tags?
|
||||
if ( ! empty( $args['taxonomies']['tags'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['tags']
|
||||
);
|
||||
}
|
||||
|
||||
// Categories?
|
||||
if ( ! empty( $args['taxonomies']['categories'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['categories']
|
||||
);
|
||||
}
|
||||
|
||||
// Fandoms?
|
||||
if ( ! empty( $args['taxonomies']['fandoms'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_fandom',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['fandoms']
|
||||
);
|
||||
}
|
||||
|
||||
// Characters?
|
||||
if ( ! empty( $args['taxonomies']['characters'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_character',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['characters']
|
||||
);
|
||||
}
|
||||
|
||||
// Genres?
|
||||
if ( ! empty( $args['taxonomies']['genres'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'fcn_genre',
|
||||
'field' => 'name',
|
||||
'terms' => $args['taxonomies']['genres']
|
||||
);
|
||||
}
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
|
@ -12,11 +12,13 @@
|
||||
* @since 4.3
|
||||
* @see fictioneer_remember_chapters_modified()
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['post_ids'] Comma-separated list of story IDs. Overrides count.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -41,6 +43,11 @@ $query_args = array(
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query stories
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
@ -13,12 +13,14 @@
|
||||
* @since 4.3
|
||||
* @see fictioneer_remember_chapters_modified()
|
||||
*
|
||||
* @internal $args['count'] The number of posts provided by the shortcode.
|
||||
* @internal $args['author'] The author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['post_ids'] Comma-separated list of story IDs. Overrides count.
|
||||
* @internal $args['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @internal $args['count'] Number of posts provided by the shortcode.
|
||||
* @internal $args['author'] Author provided by the shortcode.
|
||||
* @internal $args['order'] Order of posts. Default 'desc'.
|
||||
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
||||
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
||||
* @internal $args['relation'] Relationship between taxonomies.
|
||||
* @internal $args['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -42,6 +44,11 @@ $query_args = array(
|
||||
// Parameter for author?
|
||||
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
||||
|
||||
// Taxonomies?
|
||||
if ( ! empty( $args['taxonomies'] ) ) {
|
||||
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
||||
}
|
||||
|
||||
// Query stories
|
||||
$entries = new WP_Query( $query_args );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user