From 4a7f9b86b4402ffde3bf78ea643daa79363a50f0 Mon Sep 17 00:00:00 2001 From: Benno Bielmeier Date: Sat, 10 Aug 2024 13:00:25 +0200 Subject: [PATCH] fix: mess of naming plugin constants Using "ROTARACT_CLUB_FINDER_*" in preference of "ROTARACT_CLUBFINDER_*" is consistent with the naming convention of WordPress. (-> `ROTARACT_CLUB_FINDER_VERSION`) --- CHANGELOG.adoc | 7 ++++--- MIGRATION.adoc | 14 ++++++++++---- README.adoc | 6 +++--- ...ass-rotaract-club-finder-meilisearch-caller.php | 10 +++++----- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b827e88..af2ab6c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -12,9 +12,10 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog], a === Changed -* A new named constant has been created with the name ROTARACT_MEILISEARCH_SEARCHINDEX. This must be defined in wp-config.php. This allows to change the search index for Meilisearch quickly and easily -* The named constant ROTARACT_MEILISEARCH_API_KEY has been renamed to ROTARACT_MEILISEARCH_CLUBFINDER_API_KEY. The reason for this is that each Wordpress plugin should have its own API key. -* The 'limit' attribute has been added to the Meilisearch Fiter. This can be used to specify the number of data records found. The limit is currently set to 25. +* A new named constant has been created with the name `ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX`. This must be defined in wp-config.php. This allows to change the search index for Meilisearch quickly and easily. +* The named constant `ROTARACT_MEILISEARCH_API_KEY` has been renamed to `ROTARACT_CLUB_FINDER_MEILISEARCH_KEY`. The reason for this is that each WordPress plugin should have its own API key. +* The named constant `ROTARACT_MEILISEARCH_URL` has been renamed to `ROTARACT_CLUB_FINDER_MEILISEARCH_URL`. The reason for this is that each WordPress plugin should have the option to use its own Meilisearch instance.. +* The 'limit' attribute has been added to the Meilisearch filter. This can be used to specify the number of data records found. The limit is currently set to 25. == {compare}/v4.0.0\...main[Unreleased] diff --git a/MIGRATION.adoc b/MIGRATION.adoc index 90f7851..1009638 100644 --- a/MIGRATION.adoc +++ b/MIGRATION.adoc @@ -3,14 +3,20 @@ == Migrate from version 4.x to 5 -* Rename `ROTARACT_MEILISEARCH_API_KEY` to `ROTARACT_MEILISEARCH_CLUBFINDER_API_KEY` in your `wp-config.php`. +* Rename `ROTARACT_MEILISEARCH_API_KEY` to `ROTARACT_CLUB_FINDER_MEILISEARCH_KEY` in your `wp-config.php`. + .wp-config.php [source,diff] -define( 'ROTARACT_MEILISEARCH_API_KEY', '...' ); -+define( 'ROTARACT_MEILISEARCH_CLUBFINDER_API_KEY', '...' ); -* Set the newly introduced `ROTARACT_MEILISEARCH_SEARCHINDEX` in your `wp-config.php` to the name of the Meilisearch Index containing club information. ++define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_KEY', '...' ); +* Rename `ROTARACT_MEILISEARCH_URL` to `ROTARACT_CLUB_FINDER_MEILISEARCH_URL` in your `wp-config.php`. + .wp-config.php [source,diff] -+define( 'ROTARACT_MEILISEARCH_SEARCHINDEX', 'Club_public' ); +-define( 'ROTARACT_MEILISEARCH_URL', '...' ); ++define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_URL', '...' ); +* Set the newly introduced `ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX` in your `wp-config.php` to the name of the Meilisearch Index containing club information. ++ +.wp-config.php +[source,diff] ++define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX', '...' ); diff --git a/README.adoc b/README.adoc index 064e771..42191be 100644 --- a/README.adoc +++ b/README.adoc @@ -41,9 +41,9 @@ IMPORTANT: The plugin's latest version is already installed at https://hosting.r .snippet of `wp-config.php` [source, php] ---- -define( 'ROTARACT_MEILISEARCH_URL', 'https://search.rotaract.de' ); -define( 'ROTARACT_MEILISEARCH_CLUBFINDER_API_KEY', '' ); -define( 'ROTARACT_MEILISEARCH_SEARCHINDEX', 'Club_public'); +define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_URL', 'https://meilisearch.rotaract.de' ); +define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_KEY', '' ); +define( 'ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX', 'Club'); ---- * The Meilisearch API key is required to have `search` permission on index `Club` . Set OpenCage API key in your `wp-config.php`, used to convert geocode to geopoint data diff --git a/includes/callers/class-rotaract-club-finder-meilisearch-caller.php b/includes/callers/class-rotaract-club-finder-meilisearch-caller.php index dc01913..cd1138e 100644 --- a/includes/callers/class-rotaract-club-finder-meilisearch-caller.php +++ b/includes/callers/class-rotaract-club-finder-meilisearch-caller.php @@ -41,11 +41,11 @@ class Rotaract_Club_Finder_Meilisearch_Caller { */ public function __construct() { if ( - defined( 'ROTARACT_CLUBFINDER_MEILISEARCH_KEY' ) && - defined( 'ROTARACT_CLUBFINDER_MEILISEARCH_URL' ) && - defined( 'ROTARACT_CLUBFINDER_MEILISEARCH_SEARCHINDEX' ) + defined( 'ROTARACT_CLUB_FINDER_MEILISEARCH_KEY' ) && + defined( 'ROTARACT_CLUB_FINDER_MEILISEARCH_URL' ) && + defined( 'ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX' ) ) { - $this->client = new Client( ROTARACT_CLUBFINDER_MEILISEARCH_URL, ROTARACT_MEILISEARCH_CLUBFINDER_KEY ); + $this->client = new Client( ROTARACT_CLUB_FINDER_MEILISEARCH_URL, ROTARACT_CLUB_FINDER_MEILISEARCH_KEY ); } } @@ -73,7 +73,7 @@ private function meili_request( array $filter ) { if ( ! $this->isset_client() ) { return array(); } - return $this->client->index( ROTARACT_CLUBFINDER_MEILISEARCH_SEARCHINDEX )->search( '', $filter )->getHits(); + return $this->client->index( ROTARACT_CLUB_FINDER_MEILISEARCH_SEARCHINDEX )->search( '', $filter )->getHits(); } /**