Skip to content

Commit

Permalink
Updated Settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Jun 27, 2024
1 parent 75a1853 commit cf21b25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions includes/admin/settings/class-metabox-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ class Metabox_API {
* @param array|string $args {
* Array or string of arguments. Default is blank array.
*
* @type string $settings_key Admin menu type. See add_custom_menu_page() for options.
* @type string $prefix Parent menu slug.
* @type string $post_type Admin menu slug.
* @type array $registered_settings Settings fields array.
* @type string $settings_key Settings key - is used to prepare the form fields. It is not the meta key.
* @type string $prefix Used to create the meta keys. The meta key format is _{$prefix}_{$setting_id}.
* @type string|array|\WP_Screen $post_type The post type(s) on which to show the box.
* @type array $registered_settings Settings fields array.
* @type string $checkbox_modified_text Text to show to indicate a checkbox has been modified from its default value.
* }
*/
public function __construct( $args ) {
Expand All @@ -99,9 +100,9 @@ public function __construct( $args ) {
$this->$name = $value;
}

add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( "save_post_{$this->post_type}", array( $this, 'save' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
}

/**
Expand Down Expand Up @@ -363,7 +364,7 @@ public function sanitize_post_meta( $settings ) {
}
}
$settings[ $fields['ids_field'] ] = join( ',', $ids );
$settings[ $key ] = \WebberZone\Top_Ten\Util\Helpers::str_putcsv( $names );
$settings[ $key ] = Settings_Sanitize::str_putcsv( $names );
} else {
$settings[ $fields['ids_field'] ] = '';
}
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/settings/class-settings-sanitize.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function sanitize_checkbox_field( $value ) {
/**
* Sanitize post_types fields
*
* @param array $value The field value.
* @param array|int $value The field value.
* @return string $value Sanitized value
*/
public function sanitize_posttypes_field( $value ) {
Expand All @@ -167,7 +167,7 @@ public function sanitize_posttypes_field( $value ) {
/**
* Sanitize post_types fields
*
* @param array $value The field value.
* @param array|int $value The field value.
* @return string $value Sanitized value
*/
public function sanitize_taxonomies_field( $value ) {
Expand Down

0 comments on commit cf21b25

Please sign in to comment.