注册WordPress中可用的默认设置。

原型

register_initial_settings()

描述

此处注册的设置主要用于REST API,因此不包含WordPress中可用的所有设置。

源文件

路径:wp-includes/option.php

<?php
...
function register_initial_settings() {
	register_setting( 'general', 'blogname', array(
		'show_in_rest' => array(
			'name' => 'title',
		),
		'type'         => 'string',
		'description'  => __( 'Site title.' ),
	) );
	register_setting( 'general', 'blogdescription', array(
		'show_in_rest' => array(
			'name' => 'description',
		),
		'type'         => 'string',
		'description'  => __( 'Site tagline.' ),
	) );
	if ( ! is_multisite() ) {
		register_setting( 'general', 'siteurl', array(
			'show_in_rest' => array(
				'name'    => 'url',
				'schema'  => array(
					'format' => 'uri',
				),
			),
			'type'         => 'string',
			'description'  => __( 'Site URL.' ),
		) );
	}
	if ( ! is_multisite() ) {
		register_setting( 'general', 'admin_email', array(
			'show_in_rest' => array(
				'name'    => 'email',
				'schema'  => array(
					'format' => 'email',
				),
			),
			'type'         => 'string',
			'description'  => __( 'This address is used for admin purposes, like new user notification.' ),
		) );
	}
	register_setting( 'general', 'timezone_string', array(
		'show_in_rest' => array(
			'name' => 'timezone',
		),
		'type'         => 'string',
		'description'  => __( 'A city in the same timezone as you.' ),
	) );
	register_setting( 'general', 'date_format', array(
		'show_in_rest' => true,
		'type'         => 'string',
		'description'  => __( 'A date format for all date strings.' ),
	) );
	register_setting( 'general', 'time_format', array(
		'show_in_rest' => true,
		'type'         => 'string',
		'description'  => __( 'A time format for all time strings.' ),
	) );
	register_setting( 'general', 'start_of_week', array(
		'show_in_rest' => true,
		'type'         => 'integer',
		'description'  => __( 'A day number of the week that the week should start on.' ),
	) );
	register_setting( 'general', 'WPLANG', array(
		'show_in_rest' => array(
			'name' => 'language',
		),
		'type'         => 'string',
		'description'  => __( 'WordPress locale code.' ),
		'default'      => 'en_US',
	) );
	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 post comments on new articles.' ),
	) );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/register_initial_settings/