diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a2b5d9..1e4dd5b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog ## +### 2.6.0-dev ### +* Adds `is_solr_query` filter [[#588](https://github.com/pantheon-systems/solr-power/pull/588)] (props [@sboisvert](https://wordpress.org/support/users/sboisvert/)) + ### 2.5.3 (April 24, 2024) ### * Fixes a very old bug that would cause tax queries to be built incorrectly. [[#622](https://github.com/pantheon-systems/solr-power/pull/622)] (props [@offshorealert](https://wordpress.org/support/users/offshorealert/)) diff --git a/README.md b/README.md index 2d821e66..3128dafe 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ **Tags:** search **Requires at least:** 4.6 **Requires PHP:** 7.1 -**Tested up to:** 6.5.2 -**Stable tag:** 2.5.4-dev +**Tested up to:** 6.7.1 +**Stable tag:** 2.6.0-dev **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -194,6 +194,27 @@ Add the following to your `functions.php` file. } add_filter( 'solr_dismax_query', 'my_solr_dismax_query' ); +### `is_solr_query` Filter + +The `is_solr_query` filter controls whether Solr should be used for a specific query. + +Parameters: + +* $enabled (bool): Indicates whether Solr should be used for the query. Defaults to true if the query is a search or if solr_integrate is set in the query. +* $query (WP_Query): The current WordPress query object. + +Return: + +* bool: true to enable Solr for the query, false to disable it. + +```php +add_filter( 'is_solr_query', function( $enabled, $query ) { + if ( $query->is_category( 'news' ) ) { + return false; + } + return $enabled; +}, 10, 2 ); +``` ## Common issues ## diff --git a/composer.lock b/composer.lock index 6d2f86ca..d4c33a61 100644 --- a/composer.lock +++ b/composer.lock @@ -1165,13 +1165,13 @@ "version": "dev-master", "source": { "type": "git", - "url": "git@github.com:pantheon-systems/pantheon-wordpress-upstream-tests.git", - "reference": "004fc97a604950aef4f62773417691d23b3d75b0" + "url": "https://github.com/pantheon-systems/pantheon-wordpress-upstream-tests.git", + "reference": "1fa393d4d65a888cbd5f11a405827e9695fb0634" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pantheon-systems/pantheon-wordpress-upstream-tests/zipball/004fc97a604950aef4f62773417691d23b3d75b0", - "reference": "004fc97a604950aef4f62773417691d23b3d75b0", + "url": "https://api.github.com/repos/pantheon-systems/pantheon-wordpress-upstream-tests/zipball/1fa393d4d65a888cbd5f11a405827e9695fb0634", + "reference": "1fa393d4d65a888cbd5f11a405827e9695fb0634", "shasum": "" }, "require": { @@ -1193,7 +1193,11 @@ "email": "noreply@pantheon.io" } ], - "time": "2023-08-11T17:05:44+00:00" + "support": { + "issues": "https://github.com/pantheon-systems/pantheon-wordpress-upstream-tests/issues", + "source": "https://github.com/pantheon-systems/pantheon-wordpress-upstream-tests/tree/master" + }, + "time": "2024-09-23T20:47:25+00:00" }, { "name": "phar-io/manifest", @@ -4251,8 +4255,8 @@ }, "prefer-stable": true, "prefer-lowest": false, - "platform": [], - "platform-dev": [], + "platform": {}, + "platform-dev": {}, "platform-overrides": { "php": "7.1" }, diff --git a/package-lock.json b/package-lock.json index 9f010477..3550fd3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solr-power", - "version": "2.5.4-dev", + "version": "2.6.0-dev", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solr-power", - "version": "2.5.4-dev", + "version": "2.6.0-dev", "devDependencies": { "grunt": "^1.6.1", "grunt-autoprefixer": "~3.0.4", diff --git a/package.json b/package.json index b46ca2a9..78e05afb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solr-power", - "version": "2.5.4-dev", + "version": "2.6.0-dev", "repository": { "type": "git", "url": "https://github.com/pantheon-systems/solr-power.git" diff --git a/readme.txt b/readme.txt index 7c63b596..21e973e7 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: getpantheon, Outlandish Josh, 10up, collinsinternet, andrew.taylor Tags: search Requires at least: 4.6 Requires PHP: 7.1 -Tested up to: 6.5.2 -Stable tag: 2.5.4-dev +Tested up to: 6.7.1 +Stable tag: 2.6.0-dev License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -205,6 +205,25 @@ Add the following to your `functions.php` file. } add_filter( 'solr_dismax_query', 'my_solr_dismax_query' ); += ```is_solr_query``` Filter = + +The `is_solr_query` filter controls whether Solr should be used for a specific query. + +Parameters: + +* $enabled (bool): Indicates whether Solr should be used for the query. Defaults to true if the query is a search or if solr_integrate is set in the query. +* $query (WP_Query): The current WordPress query object. + +Return: + +* bool: true to enable Solr for the query, false to disable it. + + add_filter( 'is_solr_query', function( $enabled, $query ) { + if ( $query->is_category( 'news' ) ) { + return false; + } + return $enabled; + }, 10, 2 ); = Common issues = @@ -235,6 +254,10 @@ Please report security bugs found in the source code of the Solr Power plugin th == Changelog == + += 2.6.0-dev = +* Adds `is_solr_query` filter [[#588](https://github.com/pantheon-systems/solr-power/pull/588)] (props [@sboisvert](https://wordpress.org/support/users/sboisvert/)) + = 2.5.3 (April 24, 2024) = * Fixes a very old bug that would cause tax queries to be built incorrectly. [[#622](https://github.com/pantheon-systems/solr-power/pull/622)] (props [@offshorealert](https://wordpress.org/support/users/offshorealert/)) diff --git a/solr-power.php b/solr-power.php index d41224a6..77370fa5 100644 --- a/solr-power.php +++ b/solr-power.php @@ -2,7 +2,7 @@ /** * Plugin Name: Solr Power * Description: Allows WordPress sites to index and search content with ApacheSolr. - * Version: 2.5.4-dev + * Version: 2.6.0-dev * Author: Pantheon * Author URI: http://pantheon.io * Text Domain: solr-for-wordpress-on-pantheon @@ -10,7 +10,7 @@ * @package Solr_Power **/ -define( 'SOLR_POWER_VERSION', '2.5.4-dev' ); +define( 'SOLR_POWER_VERSION', '2.6.0-dev' ); /** * Copyright (c) 2011-2022 Pantheon, Matt Weber, Solr Power contributors