[wp-trac] [WordPress Trac] #38731: Allow publicly readable settings within WP_REST_Settings_Controller
WordPress Trac
noreply at wordpress.org
Thu Jul 9 13:29:41 UTC 2020
#38731: Allow publicly readable settings within WP_REST_Settings_Controller
------------------------------------------+------------------------------
Reporter: davecpage | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Changes (by spacedmonkey):
* keywords: => needs-patch needs-unit-tests
Comment:
I think we should make the settings endpoint public and have a
`auth_callback` callback on the setting schema.
{{{#!php
register_setting(
'general',
'blogname',
array(
'show_in_rest' => array(
'name' => 'title',
'auth_callback' => 'manage_options',
),
'type' => 'string',
'description' => __( 'Site title.' ),
)
);
}}}
This callback would be called all registered settings, to see if should be
displayed or not. To make a setting public, all that would be required
would be.
{{{#!php
'auth_callback' => '__return_true',
}}}
By default, we would have to make `'auth_callback' => 'manage_options', `
to stop existing options going public.
I know this ticket would be especially useful to the gutenberg team to get
data out of WordPress.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38731#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list