From 3a5538e1daed6366edce936dd7c10a97b6b0775d Mon Sep 17 00:00:00 2001 From: rvdforst Date: Mon, 19 Feb 2024 16:45:49 +0100 Subject: [PATCH] Update Settings.php --- includes/Settings.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/Settings.php b/includes/Settings.php index 484a52e5..2ab72008 100644 --- a/includes/Settings.php +++ b/includes/Settings.php @@ -13,6 +13,11 @@ class Settings protected $settings; public function __construct() + { + add_action('rrze_wp_settings_after_update_option', [$this, 'flushRewriteRules']); + } + + public function loaded() { $this->settings = new OptionsSettings(__('Calendar Settings', 'rrze-calendar'), 'rrze-calendar'); @@ -59,12 +64,19 @@ public function __construct() $this->settings->build(); } + public function flushRewriteRules($optionName) + { + if ($optionName === self::OPTION_NAME) { + flush_rewrite_rules(false); + } + } + public function validateEndpointSlug($value) { - if ($validation = strlen(sanitize_title($value)) > 4) { - flush_rewrite_rules(); + if (mb_strlen(sanitize_title($value)) < 4) { + return false; } - return $validation; + return true; } public function getOption($option)