Skip to content

Commit

Permalink
Merge pull request #4 from ItinerisLtd/flush-rewrites-on-save
Browse files Browse the repository at this point in the history
flush rewrite rules on save
  • Loading branch information
danlapteacru authored Oct 25, 2022
2 parents 9620bc3 + 4ff18ab commit 5a97fed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/Types/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ public function getPageId(): int

return $this->customPageId ?? 0;
}

/**
* @param mixed $value
* @return int
*/
public function saveSettingsCallback($value): int
{
flush_rewrite_rules();
return intval($value);
}
}
4 changes: 2 additions & 2 deletions src/Types/CustomPostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function addSettingsField(WP_Post_Type $post_type): void
$setting_id,
[
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'sanitize_callback' => [$this, 'saveSettingsCallback'],
'default' => NULL,
]
);
Expand Down Expand Up @@ -200,7 +200,7 @@ public function customizerRegister(WP_Customize_Manager $wp_customize): void {
'type' => 'option',
'capability' => 'manage_options',
'default' => 0,
'sanitize_callback' => 'sanitize_text_field',
'sanitize_callback' => [$this, 'saveSettingsCallback'],
]);

$wp_customize
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function addSettingsField(): void
$setting_id,
[
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'sanitize_callback' => [$this, 'saveSettingsCallback'],
'default' => NULL,
]
);
Expand Down
2 changes: 1 addition & 1 deletion src/Types/ZeroFourZero.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function addSettingsField(): void
$setting_id,
[
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'sanitize_callback' => [$this, 'saveSettingsCallback'],
'default' => NULL,
]
);
Expand Down

0 comments on commit 5a97fed

Please sign in to comment.