← All changes
|
core/settings/controllers/settings-controller.php
+28
-0
1.0.24
→
1.0.27
View file →
| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Booktics\Settings\Controllers; |
| 4 | 4 | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit; | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | use Booktics\Abstracts\Base_Rest_Controller; |
| 6 | 10 | use Booktics\Services\Schedule_Manager; |
| 7 | 11 | use Booktics\Settings\Settings; |
| 8 | 12 | use WP_Error; |
| @@ -171,8 +175,32 @@ | ||
| 171 | 175 | $params['wc_thankyou_page'] = in_array( $params['wc_thankyou_page'], array( 'woocommerce', 'booktics' ), true ) |
| 172 | 176 | ? $params['wc_thankyou_page'] |
| 173 | 177 | : 'woocommerce'; |
| 174 | 178 | } |
| 179 | + | |
| 180 | + /** | |
| 181 | + * Last chance to clean the settings payload before it is stored. | |
| 182 | + * | |
| 183 | + * Settings::update() writes what it is handed, so a feature adding a | |
| 184 | + * structured key of its own sanitizes it here. schedule, custom and | |
| 185 | + * holiday are not in $params: Schedule_Manager has already saved them. | |
| 186 | + * | |
| 187 | + * @since 1.0.26 | |
| 188 | + * | |
| 189 | + * @param array $params Settings payload from the request. | |
| 190 | + */ | |
| 191 | + $filtered = apply_filters( 'booktics_settings_update_params', $params ); | |
| 192 | + | |
| 193 | + if ( ! is_array( $filtered ) ) { | |
| 194 | + _doing_it_wrong( | |
| 195 | + __METHOD__, | |
| 196 | + esc_html__( 'The booktics_settings_update_params filter must return an array.', 'booktics' ), | |
| 197 | + '1.0.26' | |
| 198 | + ); | |
| 199 | + $filtered = $params; | |
| 200 | + } | |
| 201 | + | |
| 202 | + $params = $filtered; | |
| 175 | 203 | |
| 176 | 204 | Settings::update( $params ); |
| 177 | 205 | |
| 178 | 206 | $settings = Settings::get(); |