Coding Standards: Use a single input array on Permalink Settings screen.

This reduces the amount of code to edit in case of any changes to the default permalink structures.

Follow-up to [53706], [53710].

See #55647, #55498.
Built from https://develop.svn.wordpress.org/trunk@53713


git-svn-id: http://core.svn.wordpress.org/trunk@53272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-07-17 01:38:08 +00:00
parent 74b2659ce4
commit 0eff79af37
2 changed files with 17 additions and 23 deletions

View File

@ -238,49 +238,43 @@ if ( is_multisite() && ! is_subdomain_install() && is_main_site()
$tag_base = preg_replace( '|^/?blog|', '', $tag_base );
}
$default_structures = array(
0 => '',
1 => $index_php_prefix . '/%year%/%monthnum%/%day%/%postname%/',
2 => $index_php_prefix . '/%year%/%monthnum%/%postname%/',
3 => $index_php_prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
4 => $index_php_prefix . '/%postname%/',
);
$url_base = home_url( $blog_prefix . $index_php_prefix );
$default_structure_inputs = array(
0 => array(
$default_structures = array(
array(
'id' => 'plain',
'label' => __( 'Plain' ),
'value' => '',
'example' => home_url( '/?p=123' ),
'value' => $default_structures[0],
),
1 => array(
array(
'id' => 'day-name',
'label' => __( 'Day and name' ),
'value' => $index_php_prefix . '/%year%/%monthnum%/%day%/%postname%/',
'example' => $url_base . '/' . gmdate( 'Y/m/d' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
'value' => $default_structures[1],
),
2 => array(
array(
'id' => 'month-name',
'label' => __( 'Month and name' ),
'value' => $index_php_prefix . '/%year%/%monthnum%/%postname%/',
'example' => $url_base . '/' . gmdate( 'Y/m' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
'value' => $default_structures[2],
),
3 => array(
'id' => 'day-numeric',
array(
'id' => 'numeric',
'label' => __( 'Numeric' ),
'value' => $index_php_prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
'example' => $url_base . '/' . _x( 'archives', 'sample permalink base' ) . '/123',
'value' => $default_structures[3],
),
4 => array(
array(
'id' => 'post-name',
'label' => __( 'Post name' ),
'value' => $index_php_prefix . '/%postname%/',
'example' => $url_base . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/',
'value' => $default_structures[4],
),
);
$default_structure_values = wp_list_pluck( $default_structures, 'value' );
$available_tags = array(
/* translators: %s: Permalink structure tag. */
'year' => __( '%s (The year of the post, four digits, for example 2004.)' ),
@ -336,7 +330,7 @@ printf(
<td>
<fieldset class="structure-selection">
<legend class="screen-reader-text"><?php _e( 'Permalink structure' ); ?></legend>
<?php foreach ( $default_structure_inputs as $input ) : ?>
<?php foreach ( $default_structures as $input ) : ?>
<div class="row">
<input id="permalink-input-<?php echo $input['id']; ?>"
name="selection" aria-describedby="permalink-<?php echo $input['id']; ?>"
@ -355,7 +349,7 @@ printf(
<div class="row">
<input id="custom_selection"
name="selection" type="radio" value="custom"
<?php checked( ! in_array( $permalink_structure, $default_structures, true ) ); ?>
<?php checked( ! in_array( $permalink_structure, $default_structure_values, true ) ); ?>
/>
<div>
<label for="custom_selection"><?php _e( 'Custom Structure' ); ?></label>

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53712';
$wp_version = '6.1-alpha-53713';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.