diff --git a/php/classes/integrations/blocks/class-castos-blocks.php b/php/classes/integrations/blocks/class-castos-blocks.php
index 756ef393..fc7d8588 100644
--- a/php/classes/integrations/blocks/class-castos-blocks.php
+++ b/php/classes/integrations/blocks/class-castos-blocks.php
@@ -417,6 +417,14 @@ protected function register_playlist_player() {
'type' => 'string',
'default' => '-1',
),
+ 'availableTags' => array(
+ 'type' => 'array',
+ 'default' => $this->get_tags(),
+ ),
+ 'selectedTag' => array(
+ 'type' => 'string',
+ 'default' => '',
+ ),
// Use string everywhere instead of number because of the WP bug.
// It doesn't show the saved value in the admin after page refresh.
'limit' => array(
@@ -440,6 +448,10 @@ protected function register_playlist_player() {
$args['series'] = $this->get_term_slug_by_id( $podcast_id );
}
+ if ( ! empty( $attributes['selectedTag'] ) ) {
+ $args['tag'] = $attributes['selectedTag'];
+ }
+
if ( ! empty( $attributes['limit'] ) ) {
$args['limit'] = $attributes['limit'];
}
@@ -501,4 +513,23 @@ protected function get_podcast_settings() {
);
}, ssp_get_podcasts() ) );
}
+
+ /**
+ * @return array
+ */
+ protected function get_tags() {
+ return array_merge(
+ array(
+ array(
+ 'label' => __( '-- All --', 'seriously-simple-podcasting' ),
+ 'value' => '',
+ ),
+ ),
+ array_map( function ( $item ) {
+ return array(
+ 'label' => $item->name,
+ 'value' => $item->slug,
+ );
+ }, ssp_get_tags() ) );
+ }
}
diff --git a/php/includes/ssp-functions.php b/php/includes/ssp-functions.php
index a7bd3291..6f3af0f3 100644
--- a/php/includes/ssp-functions.php
+++ b/php/includes/ssp-functions.php
@@ -1726,6 +1726,26 @@ function ssp_get_podcasts( $hide_empty = false ) {
}
}
+/**
+ * Gets array of tags.
+ */
+if ( ! function_exists( 'ssp_get_tags' ) ) {
+ /**
+ * Gets array of tags.
+ *
+ * @param bool $hide_empty
+ *
+ * @return WP_Term[]
+ */
+ function ssp_get_tags( $hide_empty = false ) {
+ $tags = get_terms( 'post_tag', array(
+ 'post_type' => ssp_post_types(),
+ 'hide_empty' => $hide_empty,
+ ) );
+ return is_array( $tags ) ? $tags : array();
+ }
+}
+
/**
* Gets SSP Version.
*/
diff --git a/src/components/EditPlaylistPlayer.js b/src/components/EditPlaylistPlayer.js
index ee64b6ea..2a650325 100644
--- a/src/components/EditPlaylistPlayer.js
+++ b/src/components/EditPlaylistPlayer.js
@@ -20,6 +20,8 @@ class EditPlaylistPlayer extends Component {
const {
availablePodcasts,
+ availableTags,
+ selectedTag,
limit,
orderBy,
order,
@@ -45,6 +47,21 @@ class EditPlaylistPlayer extends Component {
}}
/>
+
+
+ {
+ setAttributes({
+ selectedTag: selectedTag
+ });
+ }}
+ />
+