WC_Register_WP_Admin_Settings::register_setting()
Register a setting into the format expected for the Settings REST API.
Method of the class: WC_Register_WP_Admin_Settings{}
No Hooks.
Return
Array|true|false
.
Usage
$WC_Register_WP_Admin_Settings = new WC_Register_WP_Admin_Settings(); $WC_Register_WP_Admin_Settings->register_setting( $setting );
- $setting(array) (required)
- Setting data.
Changelog
Since 3.0.0 | Introduced. |
WC_Register_WP_Admin_Settings::register_setting() WC Register WP Admin Settings::register setting code WC 9.4.2
public function register_setting( $setting ) { if ( ! isset( $setting['id'] ) ) { return false; } $description = ''; if ( ! empty( $setting['desc'] ) ) { $description = $setting['desc']; } elseif ( ! empty( $setting['description'] ) ) { $description = $setting['description']; } $new_setting = array( 'id' => $setting['id'], 'label' => ( ! empty( $setting['title'] ) ? $setting['title'] : '' ), 'description' => $description, 'type' => $setting['type'], 'option_key' => $setting['option_key'], ); if ( isset( $setting['default'] ) ) { $new_setting['default'] = $setting['default']; } if ( isset( $setting['options'] ) ) { $new_setting['options'] = $setting['options']; } if ( isset( $setting['desc_tip'] ) ) { if ( true === $setting['desc_tip'] ) { $new_setting['tip'] = $description; } elseif ( ! empty( $setting['desc_tip'] ) ) { $new_setting['tip'] = $setting['desc_tip']; } } return $new_setting; }