-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display settings 'label' defined by the 'register_setting' method (#5…
…9243) * Try: Add 'label' argument to the 'register_setting' method * Use title keyword * Fix route override * Use just a filter * Update getOrLoadEntitiesConfig * Temp update selectors * Finalize first iteration * Fix unit test * Feedback * Restore site entity shortcuts * Update 'getOrLoadEntitiesConfig' doc-block Unlinked contributors: itsmewatermelon. Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: adamziel <[email protected]> Co-authored-by: richtabor <[email protected]>
- Loading branch information
1 parent
a323eee
commit 959b616
Showing
9 changed files
with
183 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Options API changes for the Gutenberg plugin. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Updates arguments for default settings available in WordPress. | ||
* | ||
* Note: During the core sync, the updates will be made to `register_initial_settings`. | ||
*/ | ||
function gutenberg_update_initial_settings( $args, $defaults, $option_group, $option_name ) { | ||
$settings_label_map = array( | ||
'blogname' => __( 'Title' ), | ||
'blogdescription' => __( 'Tagline' ), | ||
'site_logo' => __( 'Logo' ), | ||
'site_icon' => __( 'Icon' ), | ||
'show_on_front' => __( 'Show on front' ), | ||
'page_on_front' => __( 'Page on front' ), | ||
'posts_per_page' => __( 'Maximum posts per page' ), | ||
'default_comment_status' => __( 'Allow comments on new posts' ), | ||
); | ||
|
||
if ( isset( $settings_label_map[ $option_name ] ) ) { | ||
$args['label'] = $settings_label_map[ $option_name ]; | ||
} | ||
|
||
// Don't update schema when label isn't provided. | ||
if ( ! isset( $args['label'] ) ) { | ||
return $args; | ||
} | ||
|
||
$schema = array( 'title' => $args['label'] ); | ||
if ( ! is_array( $args['show_in_rest'] ) ) { | ||
$args['show_in_rest'] = array( | ||
'schema' => $schema, | ||
); | ||
return $args; | ||
} | ||
|
||
if ( ! empty( $args['show_in_rest']['schema'] ) ) { | ||
$args['show_in_rest']['schema'] = array_merge( $args['show_in_rest']['schema'], $schema ); | ||
} else { | ||
$args['show_in_rest']['schema'] = $schema; | ||
} | ||
|
||
return $args; | ||
} | ||
add_filter( 'register_setting_args', 'gutenberg_update_initial_settings', 10, 4 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.