Skip to content

Commit 7f4388b

Browse files
committed
chore: sync Settings API and Hook Registry updates
1 parent a6688f3 commit 7f4388b

4 files changed

Lines changed: 11 additions & 20 deletions

File tree

includes/admin/settings/class-settings-api.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ public static function enqueue_scripts_styles( $prefix, $args = array() ) {
577577
wp_enqueue_script( "wz-{$prefix}-tom-select" );
578578

579579
$defaults = array(
580-
'action' => $prefix . '_taxonomy_search_tom_select',
581-
'nonce' => wp_create_nonce( $prefix . '_taxonomy_search_tom_select' ),
582580
'endpoint' => 'category',
583581
'strings' => array(
584582
'no_results' => 'No results found for "%s"',
@@ -730,11 +728,7 @@ public function settings_defaults() {
730728
}
731729
}
732730

733-
$upgraded_settings = $this->upgraded_settings;
734-
735-
if ( false !== $upgraded_settings ) {
736-
$options = array_merge( $options, $upgraded_settings );
737-
}
731+
$options = array_merge( $options, $this->upgraded_settings );
738732

739733
/**
740734
* Filters the default settings array.

includes/admin/settings/class-settings-sanitize.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public function sanitize_sensitive_field( $value, $key ) {
288288
/**
289289
* Sanitize repeater field.
290290
*
291-
* @param array $value Array of repeater values.
291+
* @param mixed $value Array of repeater values (may be non-array from form data).
292292
* @param array $field Field configuration array.
293293
* @return array Sanitized array
294294
*/
@@ -418,7 +418,7 @@ public static function str_putcsv( $input_array, $delimiter = ',', $enclosure =
418418
break;
419419
// Make sure sprintf has a good datatype to work with.
420420
case 'integer':
421-
$sp_format = '%i';
421+
$sp_format = '%d';
422422
break;
423423
case 'double':
424424
$sp_format = '%0.2f';

includes/admin/settings/class-settings-wizard-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function process_step() {
341341
// Initialise the current step based on the URL or stored option before processing the action.
342342
$this->current_step = $this->get_current_step();
343343

344-
$action = isset( $_POST['wizard_action'] ) ? sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) ) : '';
344+
$action = sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) );
345345

346346
switch ( $action ) {
347347
case 'next_step':

includes/util/class-hook-registry.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Hook_Registry {
2323
*
2424
* @var array
2525
*/
26-
private static $hooks = array();
26+
public static $hooks = array();
2727

2828
/**
2929
* Register a hook (action or filter).
@@ -36,20 +36,17 @@ class Hook_Registry {
3636
*
3737
* @return bool True if registered, false if duplicate or invalid hook.
3838
*/
39-
public static function register( $hook_type, $hook_name, $callback, $priority = 10, $args = 1 ) {
39+
public static function register( string $hook_type, string $hook_name, callable $callback, int $priority = 10, int $args = 1 ): bool {
4040
if ( ! in_array( $hook_type, array( 'action', 'filter' ), true ) ) {
4141
return false;
4242
}
43-
if ( ! is_string( $hook_name ) || empty( trim( $hook_name ) ) ) {
43+
if ( empty( trim( $hook_name ) ) ) {
4444
return false;
4545
}
46-
if ( ! is_callable( $callback ) ) {
46+
if ( $priority < 0 ) {
4747
return false;
4848
}
49-
if ( ! is_numeric( $priority ) || $priority < 0 ) {
50-
return false;
51-
}
52-
if ( ! is_numeric( $args ) || $args < 1 ) {
49+
if ( $args < 1 ) {
5350
return false;
5451
}
5552

@@ -220,7 +217,7 @@ public static function remove_all_hooks() {
220217
*
221218
* @return string Unique key.
222219
*/
223-
private static function create_hook_key( $hook_name, $callback, $priority, $closure_id = '' ) {
220+
public static function create_hook_key( $hook_name, $callback, $priority, $closure_id = '' ) {
224221
return md5( $hook_name . self::callback_to_string( $callback ) . $priority . $closure_id );
225222
}
226223

@@ -231,7 +228,7 @@ private static function create_hook_key( $hook_name, $callback, $priority, $clos
231228
*
232229
* @return string String representation of the callback.
233230
*/
234-
private static function callback_to_string( $callback ) {
231+
public static function callback_to_string( $callback ) {
235232
if ( is_string( $callback ) ) {
236233
return $callback;
237234
}

0 commit comments

Comments
 (0)