Serialized settings in rest api

JSON Schema It’s supported if you explicitly register the object JSON schema as: $args = array( ‘show_in_rest’ => array( ‘schema’ => array( ‘type’ => ‘object’, ‘properties’ => array( ‘post’ => array( ‘type’ => ‘string’, ), ‘blog’ => array( ‘type’ => ‘string’, ), ) ), ), ); register_setting( ‘default_sidebars’, ‘default_sidebars’, $args ); Resulting in the following … Read more

How to Save Different Settings Options Using Settings API and/or the Theme Optimizer

I did something similar as an import/export facility. Essentially I created a Theme Options Import/Export page in the dashboard, then just export the theme options (using get_option()) to a file as a JSON encoded string and post it for the user to download. Then give them an upload facility the imports said file (using update_option()). … Read more

Theme customizer: How do you grab the value later?

I made one change… $wp_customize->add_setting( // ID ‘primm_slider_speed’, // Arguments array array( ‘default’ => ‘5000’, ‘type’ => ‘theme_mod’ <– made change right here. ) ); ‘type’ = ‘option’ just didn’t work. ‘type’ = ‘theme_mod’ totally nailed it. Option set manually to 6200, hit save. Refresh home page. Output now: Slider Timing: 6200string(4) “6200” Big Ouch… … Read more

Saving Plugin settings to the database

I would store the array to the options able as a serialized value. update_option(‘dw_quotes’, serialize($quotes)); and retrieve with: $quotes = get_option(‘dw_quotes’, null); if ($quotes !== null) { $quotes = unserialize($quotes); } Other things to consider: Add handling in case the quotes option does not exist. Also add handling to delete quotes from the option table … Read more

do_settings_sections() doesn’t escape quotes

I found the problem. You need to escape the values in the _render functions, using esc_attr, like this: function my_setting_render() { $options = get_option(‘my_option_name’); ?><input name=”my_option_name[my_setting]” value=”<?php echo esc_attr($options[‘my_setting’]);?>”> <?php }

Setting ‘autoload’ to ‘no’ with Settings API

The only way to accomplish this is to add the option to the database yourself before the Settings API does so. To do this, add a ‘sanitize_callback’ to the register_settings function: register_setting (‘my_options’, ‘my_option_name’, array (‘type’ => ‘string’, ‘sanitize_callback’ => ‘my_function_name’)); Then, in your function, update the option yourself: function my_function_name ($value) { update_option (‘my_option_name’, … Read more

How can I include a setting that has a variable number of values in a settings page using register_setting?

If you are using the Settings API correctly, you should be using the add_settings_field function. The 3rd argument in this function is for the callback function that will generate the HTML for the form field for the individual setting. The Codex states: Function that fills the field with the desired inputs as part of the … Read more

Settings API repeater fields

After you finish with following article, you will be able to add and get options from your admin with only a few lines of code. this will be creating options for a WordPress theme in this article . Titan Framework(WordPress option framework) Add new theme option function.php if (!class_exists(‘TitanFramework’)) { require_once( get_template_directory() . ‘/titan-framework/titan-framework.php’ ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)