Summery Summery
Registers a setting and its data.
Syntax Syntax
Parameters Parameters
- $option_group
-
(Required) A settings group name. Should correspond to a whitelisted option key name. Default whitelisted option key names include 'general', 'discussion', 'media', 'reading', 'writing', 'misc', 'options', and 'privacy'.
- $option_name
-
(Required) The name of an option to sanitize and save.
- $args
-
(Optional) Data used to describe the setting when registered.
- 'type'
(string) The type of data associated with this setting. Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'. - 'description'
(string) A description of the data attached to this setting. - 'sanitize_callback'
(callable) A callback function that sanitizes the option's value. - 'show_in_rest'
(bool|array) Whether data associated with this setting should be included in the REST API. When registering complex settings, this argument may optionally be an array with a 'schema' key. - 'default'
(mixed) Default value when callingget_option()
.
Default value: array()
- 'type'
Source Source
File: wp-includes/option.php
) ); register_setting( 'writing', 'use_smilies', array( 'show_in_rest' => true, 'type' => 'boolean', 'description' => __( 'Convert emoticons like :-) and :-P to graphics on display.' ), 'default' => true, ) ); register_setting( 'writing', 'default_category', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'Default post category.' ), ) ); register_setting( 'writing', 'default_post_format', array( 'show_in_rest' => true, 'type' => 'string', 'description' => __( 'Default post format.' ), ) ); register_setting( 'reading', 'posts_per_page', array( 'show_in_rest' => true, 'type' => 'integer', 'description' => __( 'Blog pages show at most.' ), 'default' => 10, ) ); register_setting( 'discussion', 'default_ping_status', array( 'show_in_rest' => array( 'schema' => array( 'enum' => array( 'open', 'closed' ), ), ), 'type' => 'string', 'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ), ) ); register_setting( 'discussion', 'default_comment_status', array( 'show_in_rest' => array( 'schema' => array( 'enum' => array( 'open', 'closed' ), ), ), 'type' => 'string', 'description' => __( 'Allow people to submit comments on new posts.' ), ) ); } /** * Registers a setting and its data.
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.7.0 | $args can be passed to set flags on the setting, similar to register_meta() . |
2.7.0 | Introduced. |