Skip to content

Commit

Permalink
Update Settings.php
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdforst committed Feb 19, 2024
1 parent 0462692 commit 3a5538e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions includes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3a5538e

Please sign in to comment.