Version 0.1.13 - Redirects items search properly.
This commit is contained in:
parent
7f0fad92d9
commit
7259927d71
|
@ -5,7 +5,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository, tainacan, blo
|
|||
Requires at least: 5.0
|
||||
Tested up to: 5.8.1
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 0.1.12
|
||||
Stable tag: 0.1.13
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
|
@ -58,6 +58,9 @@ License details: https://github.com/tainacan/blocksy-tainacan/blob/master/LICENS
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 0.1.13 =
|
||||
* Redirects search to items list if only Tainacan items post types are enabled
|
||||
|
||||
= 0.1.12 =
|
||||
* Fixes lack of --background-color variable due to recent versions of Blocksy
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Plugin Name: Tainacan Support for Blocksy
|
|||
Plugin URI: https://tainacan.org/
|
||||
Description: Tainacan plugin support for Blocksy theme
|
||||
Author: tainacan
|
||||
Version: 0.1.12
|
||||
Version: 0.1.13
|
||||
Text Domain: tainacan-blocksy
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
@ -15,7 +15,7 @@ if (! defined('WP_DEBUG') ) {
|
|||
}
|
||||
|
||||
/** Theme/plugin version */
|
||||
const TAINACAN_BLOCKSY_VERSION = '0.1.12';
|
||||
const TAINACAN_BLOCKSY_VERSION = '0.1.13';
|
||||
const TAINACAN_BLOCKSY_IS_CHILD_THEME = false;
|
||||
|
||||
/* Tools to define our next constants */
|
||||
|
|
|
@ -102,4 +102,43 @@ function tainacan_get_default_view_mode_choices() {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This function modifies the main WordPress query to include an array of
|
||||
* post types instead of the default 'post' post type.
|
||||
*
|
||||
* @param object $query The main WordPress query.
|
||||
*/
|
||||
function tainacan_blocksy_modify_search_query( ) {
|
||||
global $wp_query;
|
||||
|
||||
if (
|
||||
!is_post_type_archive() &&
|
||||
isset( $_GET['s'] ) &&
|
||||
$wp_query->is_main_query() &&
|
||||
$wp_query->is_search() &&
|
||||
!is_admin()
|
||||
) {
|
||||
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
|
||||
$searching_post_types = $wp_query->get( 'post_type' );
|
||||
|
||||
if ( !is_array($searching_post_types) )
|
||||
$searching_post_types = [ $searching_post_types ];
|
||||
|
||||
// If the search is going on post types other than Tainacan items...
|
||||
foreach($searching_post_types as $searching_post_type) {
|
||||
if ( !in_array($searching_post_type, $collections_post_types) )
|
||||
return;
|
||||
}
|
||||
|
||||
// If the search is in a single collection, go there
|
||||
if ( count($searching_post_types) === 1 )
|
||||
wp_redirect( get_post_type_archive_link( $searching_post_types[0] ) . '?search=' . $_GET['s'] );
|
||||
|
||||
// Otherwise, the Items Repository list should do the job
|
||||
else
|
||||
wp_redirect( \Tainacan\Theme_Helper::get_instance()->get_items_list_slug() . '?search=' . $_GET['s'] );
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'tainacan_blocksy_modify_search_query' );
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tainacan-blocksy",
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tainacan-blocksy",
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"description": "A Blocksy plugin/child theme compatible with Tainacan",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue