From 9cb246b0c301834cc7c58a8471be4278d47aab8e Mon Sep 17 00:00:00 2001 From: Pedro Cruz Date: Fri, 13 Sep 2024 09:47:51 +0200 Subject: [PATCH] Fix settings namespace issues v2 (#326) * Fix settings namespace issues * Replace old translations namespace * Update version --- .../doofinder-for-woocommerce.php | 51 +++++++++++++- .../includes/class-post.php | 2 +- .../includes/class-settings.php | 70 ++----------------- doofinder-for-woocommerce/readme.txt | 7 +- package-lock.json | 4 +- package.json | 2 +- 6 files changed, 64 insertions(+), 72 deletions(-) diff --git a/doofinder-for-woocommerce/doofinder-for-woocommerce.php b/doofinder-for-woocommerce/doofinder-for-woocommerce.php index e2492e4..0b409c1 100644 --- a/doofinder-for-woocommerce/doofinder-for-woocommerce.php +++ b/doofinder-for-woocommerce/doofinder-for-woocommerce.php @@ -3,7 +3,7 @@ * Plugin Name: DOOFINDER Search and Discovery for WP & WooCommerce * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html - * Version: 2.5.3 + * Version: 2.5.4 * Requires at least: 5.6 * Requires PHP: 7.0 * Author: Doofinder @@ -38,7 +38,7 @@ class Doofinder_For_WordPress { * @var string */ - public static $version = '2.5.3'; + public static $version = '2.5.4'; /** * The only instance of Doofinder_For_WordPress @@ -449,7 +449,52 @@ function () { * @return array List of previous schedules + DooFinder ones. */ public static function add_schedules( $schedules ) { - return Settings::add_schedules( $schedules ); + $df_schedules = array( + 'wp_doofinder_each_5_minutes' => array( + /* translators: %s is replaced with an integer number representing the minutes. */ + 'display' => sprintf( __( 'Each %s minutes', 'wordpress-doofinder' ), 5 ), + 'interval' => MINUTE_IN_SECONDS * 5, + ), + 'wp_doofinder_each_15_minutes' => array( + /* translators: %s is replaced with an integer number representing the minutes. */ + 'display' => sprintf( __( 'Each %s minutes', 'wordpress-doofinder' ), 15 ), + 'interval' => MINUTE_IN_SECONDS * 15, + ), + 'wp_doofinder_each_30_minutes' => array( + /* translators: %s is replaced with an integer number representing the minutes. */ + 'display' => sprintf( __( 'Each %s minutes', 'wordpress-doofinder' ), 30 ), + 'interval' => MINUTE_IN_SECONDS * 30, + ), + 'wp_doofinder_each_60_minutes' => array( + 'display' => __( 'Each hour', 'wordpress-doofinder' ), + 'interval' => HOUR_IN_SECONDS, + ), + 'wp_doofinder_each_2_hours' => array( + /* translators: %s is replaced with an integer number representing the hours. */ + 'display' => sprintf( __( 'Each %s hours', 'wordpress-doofinder' ), 2 ), + 'interval' => HOUR_IN_SECONDS * 2, + ), + 'wp_doofinder_each_6_hours' => array( + /* translators: %s is replaced with an integer number representing the hours. */ + 'display' => sprintf( __( 'Each %s hours', 'wordpress-doofinder' ), 6 ), + 'interval' => HOUR_IN_SECONDS * 6, + ), + 'wp_doofinder_each_12_hours' => array( + /* translators: %s is replaced with an integer number representing the hours. */ + 'display' => sprintf( __( 'Each %s hours', 'wordpress-doofinder' ), 12 ), + 'interval' => HOUR_IN_SECONDS * 12, + ), + 'wp_doofinder_each_day' => array( + 'display' => __( 'Once a day', 'wordpress-doofinder' ), + 'interval' => DAY_IN_SECONDS, + ), + 'wp_doofinder_disabled' => array( + 'display' => __( 'Disabled', 'wordpress-doofinder' ), + 'interval' => DAY_IN_SECONDS, + ), + ); + + return array_merge( $schedules, $df_schedules ); } } diff --git a/doofinder-for-woocommerce/includes/class-post.php b/doofinder-for-woocommerce/includes/class-post.php index 7a3224d..fb56644 100755 --- a/doofinder-for-woocommerce/includes/class-post.php +++ b/doofinder-for-woocommerce/includes/class-post.php @@ -94,7 +94,7 @@ public static function add_additional_settings() { function () { add_meta_box( 'doofinder-for-wp-visibility-settings', - __( 'Doofinder - Indexing', 'doofinder_for_wp' ), + __( 'Doofinder - Indexing', 'wordpress-doofinder' ), function () { self::render_html_indexing_visibility(); }, diff --git a/doofinder-for-woocommerce/includes/class-settings.php b/doofinder-for-woocommerce/includes/class-settings.php index a77dae7..c3a340f 100755 --- a/doofinder-for-woocommerce/includes/class-settings.php +++ b/doofinder-for-woocommerce/includes/class-settings.php @@ -37,7 +37,7 @@ class Settings { * * @var string */ - public static $top_level_menu = 'doofinder_for_wp'; + public static $top_level_menu = 'wordpress-doofinder'; /** * List of keys that are reserved for custom attributes fields @@ -137,14 +137,14 @@ private function __construct() { self::$tabs = array( 'authentication' => array( - 'label' => __( 'General Settings', 'doofinder_for_wp' ), + 'label' => __( 'General Settings', 'wordpress-doofinder' ), 'fields_cb' => 'add_general_settings', ), ); if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { self::$tabs['product_data'] = array( - 'label' => __( 'Product Data', 'doofinder_for_wp' ), + 'label' => __( 'Product Data', 'wordpress-doofinder' ), 'fields_cb' => 'add_product_data_settings', ); } @@ -166,7 +166,7 @@ function () { add_settings_error( 'doofinder_for_wp_messages', 'doofinder_for_wp_message', - __( 'Custom Attributes updated successfully.
Please, keep in mind that you need to reindex in order for the changes to be reflected in the search layer.', 'doofinder_for_wp' ), + __( 'Custom Attributes updated successfully.
Please, keep in mind that you need to reindex in order for the changes to be reflected in the search layer.', 'wordpress-doofinder' ), 'success' ); }, @@ -185,15 +185,15 @@ public static function get_additional_attributes_options() { $fields = include_once 'settings/attributes.php'; $option_groups = array( 'base_attribute' => array( - 'title' => __( 'Basic attributes', 'doofinder_for_wp' ), + 'title' => __( 'Basic attributes', 'wordpress-doofinder' ), 'options' => array(), ), 'wc_attribute' => array( - 'title' => __( 'Product attributes', 'doofinder_for_wp' ), + 'title' => __( 'Product attributes', 'wordpress-doofinder' ), 'options' => array(), ), 'metafield' => array( - 'title' => __( 'Metafields', 'doofinder_for_wp' ), + 'title' => __( 'Metafields', 'wordpress-doofinder' ), 'options' => array(), ), ); @@ -258,60 +258,4 @@ private static function filter_product_rest_attributes( $rest_attributes ) { ); return array_diff( $rest_attributes, static::RESERVED_CUSTOM_ATTRIBUTES_NAMES ); } - - /** - * Method that adds some custom schedules to be used in WP Cron. - * - * @param array $schedules Current WP Schedules as array. - * - * @return array List of previous schedules + DooFinder ones. - */ - public static function add_schedules( $schedules ) { - $df_schedules = array( - 'wp_doofinder_each_5_minutes' => array( - /* translators: %s is replaced with an integer number representing the minutes. */ - 'display' => sprintf( __( 'Each %s minutes', 'doofinder_for_wp' ), 5 ), - 'interval' => MINUTE_IN_SECONDS * 5, - ), - 'wp_doofinder_each_15_minutes' => array( - /* translators: %s is replaced with an integer number representing the minutes. */ - 'display' => sprintf( __( 'Each %s minutes', 'doofinder_for_wp' ), 15 ), - 'interval' => MINUTE_IN_SECONDS * 15, - ), - 'wp_doofinder_each_30_minutes' => array( - /* translators: %s is replaced with an integer number representing the minutes. */ - 'display' => sprintf( __( 'Each %s minutes', 'doofinder_for_wp' ), 30 ), - 'interval' => MINUTE_IN_SECONDS * 30, - ), - 'wp_doofinder_each_60_minutes' => array( - 'display' => __( 'Each hour', 'doofinder_for_wp' ), - 'interval' => HOUR_IN_SECONDS, - ), - 'wp_doofinder_each_2_hours' => array( - /* translators: %s is replaced with an integer number representing the hours. */ - 'display' => sprintf( __( 'Each %s hours', 'doofinder_for_wp' ), 2 ), - 'interval' => HOUR_IN_SECONDS * 2, - ), - 'wp_doofinder_each_6_hours' => array( - /* translators: %s is replaced with an integer number representing the hours. */ - 'display' => sprintf( __( 'Each %s hours', 'doofinder_for_wp' ), 6 ), - 'interval' => HOUR_IN_SECONDS * 6, - ), - 'wp_doofinder_each_12_hours' => array( - /* translators: %s is replaced with an integer number representing the hours. */ - 'display' => sprintf( __( 'Each %s hours', 'doofinder_for_wp' ), 12 ), - 'interval' => HOUR_IN_SECONDS * 12, - ), - 'wp_doofinder_each_day' => array( - 'display' => __( 'Once a day', 'doofinder_for_wp' ), - 'interval' => DAY_IN_SECONDS, - ), - 'wp_doofinder_disabled' => array( - 'display' => __( 'Disabled', 'doofinder_for_wp' ), - 'interval' => DAY_IN_SECONDS, - ), - ); - - return array_merge( $schedules, $df_schedules ); - } } diff --git a/doofinder-for-woocommerce/readme.txt b/doofinder-for-woocommerce/readme.txt index 38f3c10..45bcd13 100644 --- a/doofinder-for-woocommerce/readme.txt +++ b/doofinder-for-woocommerce/readme.txt @@ -1,11 +1,11 @@ === DOOFINDER Search and Discovery for WP & WooCommerce === Contributors: Doofinder Tags: search, autocomplete -Version: 2.5.3 +Version: 2.5.4 Requires at least: 5.6 Tested up to: 6.6.1 Requires PHP: 7.0 -Stable tag: 2.5.3 +Stable tag: 2.5.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -126,6 +126,9 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro == Changelog == += 2.5.4 = +- Fixed other Settings namespace issues. + = 2.5.3 = - Fixed issues with Settings namespace. diff --git a/package-lock.json b/package-lock.json index 9fae619..e4132e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "doofinder-woocommerce", - "version": "2.5.3", + "version": "2.5.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "doofinder-woocommerce", - "version": "2.5.3", + "version": "2.5.4", "license": "MIT", "devDependencies": { "grunt": "^1.0.1", diff --git a/package.json b/package.json index ee71dcd..aa59417 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "doofinder-woocommerce", - "version": "2.5.3", + "version": "2.5.4", "description": "Integrate Doofinder in your WooCommerce site with (almost) no effort.", "main": "index.js", "scripts": {