diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a43851..809a14b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## Version [3.9.1] (2024-01-02) + +### Refactor + +- Remove strtolower check when validating value of UniformeProductnaam. +- Remove conversion to lowercase of meta '_owc_pdc_upl_naam' when validating the values. + ## Version [3.9] (2023-10-27) ### Feat diff --git a/pdc-base.php b/pdc-base.php index 3e9be72..3dcd71e 100644 --- a/pdc-base.php +++ b/pdc-base.php @@ -4,7 +4,7 @@ * Plugin Name: Yard | PDC Base * Plugin URI: https://www.openwebconcept.nl/ * Description: Acts as foundation for other PDC related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations. - * Version: 3.9 + * Version: 3.9.1 * Author: Yard | Digital Agency * Author URI: https://www.yard.nl/ * License: GPL-3.0 diff --git a/src/Base/Foundation/Plugin.php b/src/Base/Foundation/Plugin.php index 014767f..f79e98c 100644 --- a/src/Base/Foundation/Plugin.php +++ b/src/Base/Foundation/Plugin.php @@ -19,7 +19,7 @@ class Plugin * * @var string */ - public const VERSION = '3.9'; + public const VERSION = '3.9.1'; /** * Path to the root of the plugin. diff --git a/src/Base/UPL/CorrectItems.php b/src/Base/UPL/CorrectItems.php index f1e5197..2d3d860 100644 --- a/src/Base/UPL/CorrectItems.php +++ b/src/Base/UPL/CorrectItems.php @@ -6,7 +6,6 @@ class CorrectItems extends UPL { public function handle() { - $this->validateUPLNames(); $this->prepareItems(); $correctItems = $this->compareCorrectItems(); @@ -23,7 +22,7 @@ public function compareCorrectItems(): array protected function compareCorrectItem($item): bool { foreach ($this->uplOptions as $option) { - if ($item['uplName'] !== strtolower($option['UniformeProductnaam']['value']) || strtolower($item['uplUrl']) !== strtolower($option['URI']['value'])) { + if ($option['UniformeProductnaam']['value'] !== $item['uplName'] || strtolower($item['uplUrl']) !== strtolower($option['URI']['value'])) { continue; } diff --git a/src/Base/UPL/IncorrectItems.php b/src/Base/UPL/IncorrectItems.php index c9b970e..952fd87 100644 --- a/src/Base/UPL/IncorrectItems.php +++ b/src/Base/UPL/IncorrectItems.php @@ -6,7 +6,6 @@ class IncorrectItems extends UPL { public function handle() { - $this->validateUPLNames(); $this->prepareItems(); $incorrectItems = $this->compareIncorrectItems(); @@ -23,7 +22,7 @@ public function compareIncorrectItems(): array protected function compareIncorrectItem($item): bool { foreach ($this->uplOptions as $option) { - if ($item['uplName'] === strtolower($option['UniformeProductnaam']['value']) && strtolower($item['uplUrl']) === strtolower($option['URI']['value'])) { + if ($option['UniformeProductnaam']['value'] === $item['uplName'] && strtolower($item['uplUrl']) === strtolower($option['URI']['value'])) { return false; } } diff --git a/src/Base/UPL/UPL.php b/src/Base/UPL/UPL.php index f989d7c..0217a96 100644 --- a/src/Base/UPL/UPL.php +++ b/src/Base/UPL/UPL.php @@ -4,40 +4,15 @@ class UPL { + protected array $items; + protected array $uplOptions; + public function __construct(array $items, array $options) { $this->items = $items; $this->uplOptions = $options; } - protected function validateUPLNames(): void - { - foreach ($this->items as $item) { - $uplName = get_post_meta($item->ID, '_owc_pdc_upl_naam', true); - - if (empty($uplName) || ctype_lower($uplName)) { - continue; - } - - $this->UPLNameToLowerCase($item, $uplName); - } - } - - /** - * Update post meta when value is not in lowercase. - * Post meta should be in lowercase so let's fix this in advance. - */ - protected function UPLNameToLowerCase(\WP_Post $item, string $uplName): string - { - $result = update_post_meta($item->ID, '_owc_pdc_upl_naam', strtolower($uplName)); - - if (! $result) { - return $uplName; - } - - return strtolower($uplName); - } - protected function prepareItems(): void { $this->items = array_map(function ($item) {