register_setting()
2020-05-02 / 6099阅 / 悠然
如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款
register_setting( string $option_group, string $option_name, array $args = array() )
参数
- $option_group
(string)
(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
(string)
(Required)
The name of an option to sanitize and save.
- $args
(array)
(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 calling get_option().
Default value: array()