diff --git a/src/admin/js/wp-media-frames.js b/src/admin/js/wp-media-frames.js index fa94d444c..602c2513f 100644 --- a/src/admin/js/wp-media-frames.js +++ b/src/admin/js/wp-media-frames.js @@ -65,7 +65,7 @@ export default { var l10n = _wpMediaViewsL10n; wp.media.view.settings.post = { - id: this.params.relatedPostId + id: null } this.params.flex_width = 0; @@ -87,7 +87,7 @@ export default { title: this.params.button_labels.frame_title, library: wp.media.query({ type: 'image', - uploadedTo: this.params.relatedPostId + uploadedTo: null }), multiple: false, date: false, @@ -125,7 +125,7 @@ export default { var l10n = _wpMediaViewsL10n; wp.media.view.settings.post = { - id: this.params.relatedPostId + id: null } this.params.flex_width = tainacan_plugin.custom_header_support[0].flex_width ? 1 : 0; this.params.flex_height = tainacan_plugin.custom_header_support[0].flex_height ? 1 : 0; @@ -140,7 +140,7 @@ export default { }, library: wp.media.query({ type: 'image', - uploadedTo: this.params.relatedPostId + uploadedTo: null }), uploader: true, content: 'upload', // First view that is opened @@ -149,7 +149,7 @@ export default { title: this.params.button_labels.frame_title, library: wp.media.query({ type: 'image', - uploadedTo: this.params.relatedPostId + uploadedTo: null }), multiple: false, date: false, @@ -198,7 +198,7 @@ export default { new wp.media.controller.Library({ title: this.params.button_labels.frame_title, library: wp.media.query({ - uploadedTo: this.params.relatedPostId + uploadedTo: null }), multiple: false, date: false, diff --git a/src/theme-helper/template-tags.php b/src/theme-helper/template-tags.php index 6758c2c5d..287dd9c88 100644 --- a/src/theme-helper/template-tags.php +++ b/src/theme-helper/template-tags.php @@ -48,6 +48,70 @@ function tainacan_get_collection_id() { return false; } +/** + * When visiting a collection archive or single, returns the current collection object + * + * @uses tainacan_get_collection_id() + * @return \Tainacan\Entities\Collection | false + */ +function tainacan_get_collection() { + $collection_id = tainacan_get_collection_id(); + if ( $collection_id ) { + $TainacanCollections = Repositories\Collections::get_instance(); + $collection = $TainacanCollections->fetch($collection_id); + if ( $collection instanceof Entities\Collection ) { + return $collection; + } + return false; + } +} + +/** + * When visiting a collection archive or single, returns the collection name + * + * @return string + */ +function tainacan_get_the_collection_name() { + $collection = tainacan_get_collection(); + $name = ''; + if ( $collection ) { + $name = $collection->get_name(); + } + return $name; +} + +/** + * When visiting a collection archive or single, prints the collection name + * + * @return void + */ +function tainacan_the_collection_name() { + echo tainacan_get_the_collection_name(); +} + +/** + * When visiting a collection archive or single, returns the collection description + * + * @return string + */ +function tainacan_get_the_collection_description() { + $collection = tainacan_get_collection(); + $description = ''; + if ( $collection ) { + $description = $collection->get_description(); + } + return $description; +} + +/** + * When visiting a collection archive or single, prints the collection description + * + * @return void + */ +function tainacan_the_collection_description() { + echo tainacan_get_the_collection_description(); +} + /** * When visiting a term archive, returns the current term object *