get_settings_schema(); foreach ( $settings_schema as $section => $section_props ) { $options = $section_props['properties']; foreach ( $options as $option => $schema_value ) { $value = $schema_value['default']; if ( isset( $saved_settings[ $section ][ $option ] ) ) { $value = $saved_settings[ $section ][ $option ]; } $user_settings[ $section ][ $option ] = $value; } } return $user_settings; } /** * Save user settings * * @since 2.0.0 * * @param int $user_id * @param array $settings * * @return array */ public function save( $user_id, $settings ) { $updated_settings = []; $current_settings = wp_console()->user_settings->get( $user_id ); foreach ( $current_settings as $section => $options ) { foreach ( $options as $option => $value) { $updated_settings[ $section ][ $option ] = isset( $settings[ $section ][ $option ] ) ? $settings[ $section ][ $option ] : $value; } } update_user_meta( $user_id, 'wp_console_user_settings', $updated_settings ); return $updated_settings; } }