Make WordPress Core


Ignore:
Timestamp:
05/29/2024 08:51:04 AM (2 years ago)
Author:
ellatrix
Message:

Options: Add 'label' argument to register_setting.

The 'label' will displayed to users when editing core or custom settings via block editors. It avoids hardcoding Settings labels and improves extensibility.

Backports https://github.com/WordPress/gutenberg/pull/59243.

Props mamaduka, timothyblynjacobs, ellatrix.

Fixes #61023.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r58182 r58230  
    26602660                        ),
    26612661                        'type'         => 'string',
     2662                        'label'        => __( 'Title' ),
    26622663                        'description'  => __( 'Site title.' ),
    26632664                )
     
    26722673                        ),
    26732674                        'type'         => 'string',
     2675                        'label'        => __( 'Tagline' ),
    26742676                        'description'  => __( 'Site tagline.' ),
    26752677                )
     
    28022804                        'show_in_rest' => true,
    28032805                        'type'         => 'integer',
     2806                        'label'        => __( 'Maximum posts per page' ),
    28042807                        'description'  => __( 'Blog pages show at most.' ),
    28052808                        'default'      => 10,
     
    28132816                        'show_in_rest' => true,
    28142817                        'type'         => 'string',
     2818                        'label'        => __( 'Show on front' ),
    28152819                        'description'  => __( 'What to show on the front page' ),
    28162820                )
     
    28232827                        'show_in_rest' => true,
    28242828                        'type'         => 'integer',
     2829                        'label'        => __( 'Page on front' ),
    28252830                        'description'  => __( 'The ID of the page that should be displayed on the front page' ),
    28262831                )
     
    28612866                        ),
    28622867                        'type'         => 'string',
     2868                        'label'        => __( 'Allow comments on new posts' ),
    28632869                        'description'  => __( 'Allow people to submit comments on new posts.' ),
    28642870                )
     
    28752881 * @since 5.5.0 `$new_whitelist_options` was renamed to `$new_allowed_options`.
    28762882 *              Please consider writing more inclusive code.
     2883 * @since 6.6.0 Added the `label` argument.
    28772884 *
    28782885 * @global array $new_allowed_options
     
    28882895 *     @type string     $type              The type of data associated with this setting.
    28892896 *                                         Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'.
     2897 *     @type string     $label             A label of the data attached to this setting.
    28902898 *     @type string     $description       A description of the data attached to this setting.
    28912899 *     @type callable   $sanitize_callback A callback function that sanitizes the option's value.
     
    29082916                'type'              => 'string',
    29092917                'group'             => $option_group,
     2918                'label'             => '',
    29102919                'description'       => '',
    29112920                'sanitize_callback' => null,
Note: See TracChangeset for help on using the changeset viewer.