From 2c18e4793c51c7194fe88efdeffaaf0ea7f774b0 Mon Sep 17 00:00:00 2001 From: Arthos Date: Thu, 27 Jul 2023 17:57:05 +0200 Subject: [PATCH] Use array_merge to allow to use another sanitize_callback function Merge the $setting array with defaults in order to be able to use another callback if needed --- src/Customize.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Customize.php b/src/Customize.php index 473e26e..ef5d704 100644 --- a/src/Customize.php +++ b/src/Customize.php @@ -259,7 +259,7 @@ public function register() */ public function page(string $identifier, $label, array $setting = [], array $control = []) { - $setting['sanitize_callback'] = 'absint'; + array_merge($setting, ['sanitize_callback' => 'absint']); $control['type'] = 'dropdown-pages'; return $this->text($identifier, $label, $setting, $control); @@ -379,7 +379,7 @@ public function text(string $identifier, string $label, array $setting = [], arr */ public function textarea(string $identifier, string $label, array $setting = [], array $control = []) { - $setting['sanitize_callback'] = 'wp_kses_post'; + array_merge($setting, ['sanitize_callback' => 'wp_kses_post']); $control['type'] = 'textarea'; return $this->text($identifier, $label, $setting, $control); @@ -396,7 +396,7 @@ public function textarea(string $identifier, string $label, array $setting = [], */ public function url(string $identifier, $label, array $setting = [], array $control = []) { - $setting['sanitize_callback'] = 'esc_url_raw'; + array_merge($setting, ['sanitize_callback' => 'esc_url_raw']); $control['type'] = 'url'; return $this->text($identifier, $label, $setting, $control);