Make WordPress Core

Ticket #29872: 29872.3.diff

File 29872.3.diff, 3.9 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/css/forms.css

    diff --git src/wp-admin/css/forms.css src/wp-admin/css/forms.css
    index 7cc0801..33c73db 100644
    table.form-table td .updated p { 
    925925        vertical-align: middle;
    926926}
    927927
     928.form-table.permalink-structure .available-shortcode-tags li {
     929        float: left;
     930        margin-right: 5px;
     931}
     932
     933.form-table.permalink-structure .available-shortcode-tags button {
     934        background: none;
     935        border: 1px solid transparent;
     936        padding: 0;
     937        outline: none;
     938}
     939
     940.form-table.permalink-structure .available-shortcode-tags button:focus {
     941        border-color: #5b9dd9;
     942        -webkit-box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 );
     943        box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 );
     944}
     945
     946.form-table.permalink-structure .available-shortcode-tags code {
     947        margin: 0;
     948        cursor: pointer;
     949}
     950
    928951/*------------------------------------------------------------------------------
    929952  21.0 - Network Admin
    930953------------------------------------------------------------------------------*/
  • src/wp-admin/js/common.js

    diff --git src/wp-admin/js/common.js src/wp-admin/js/common.js
    index 43a8f09..1992607 100644
    $('.contextual-help-tabs').delegate('a', 'click', function(e) { 
    175175        panel.addClass('active').show();
    176176});
    177177
     178/**
     179 * Custom permalink structures.
     180 */
     181$( '.form-table.permalink-structure .available-shortcode-tags button' ).on( 'click', function() {
     182        var $permalinkStructure = $( '#permalink_structure' ),
     183            textToAppend        = $( this ).find( 'code' ).text() + '/';
     184
     185        $( '#custom_selection' ).prop( 'checked', true );
     186
     187        if ( '/' !== $permalinkStructure.val().substr( -1 ) ) {
     188                textToAppend = '/' + textToAppend;
     189        }
     190        $permalinkStructure.val( $( '#permalink_structure' ).val() + textToAppend );
     191} )
     192
    178193$document.ready( function() {
    179194        var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
    180195                lastClicked = false,
  • src/wp-admin/options-permalink.php

    diff --git src/wp-admin/options-permalink.php src/wp-admin/options-permalink.php
    index b6c52c5..32c2ed6 100644
    $structures = array( 
    206206                <td>
    207207                        <code><?php echo get_option('home') . $blog_prefix; ?></code>
    208208                        <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
     209                        <div class="available-shortcode-tags hide-if-no-js">
     210                                <?php
     211                                $available_tags = array(
     212                                        '%year%'     => __( 'The year of the post, four digits, for example 2004' ),
     213                                        '%monthnum%' => __( 'Month of the year, for example 05' ),
     214                                        '%day%'      => __( 'Day of the month, for example 28' ),
     215                                        '%hour%'     => __( 'Hour of the day, for example 15' ),
     216                                        '%minute%'   => __( 'Minute of the hour, for example 43' ),
     217                                        '%second%'   => __( 'Second of the minute, for example 33' ),
     218                                        '%post_id%'  => __( 'The unique ID of the post, for example 423' ),
     219                                        '%postname%' => __( 'The sanitized post title (slug)' ),
     220                                        '%category%' => __( 'Category slug. Nested sub-categories appear as nested directories in the URI.' ),
     221                                        '%author%'   => __( 'A sanitized version of the author name.' ),
     222                                );
     223
     224                                /**
     225                                 * Filters the list of available permalink structure tags on the Permalinks settings page.
     226                                 *
     227                                 * @since 4.7.0
     228                                 *
     229                                 * @param array $available_tags A key => value pair of available permalink structure tags.
     230                                 */
     231                                $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
     232
     233                                if ( ! empty( $available_tags ) ) {
     234                                        echo '<p>';
     235                                        _e( 'Available tags:' );
     236                                        echo '</p>';
     237                                        echo '<ul>';
     238                                        foreach ( $available_tags as $tag => $explanation ) {
     239                                                printf( '<li><button type="button"><code>%1$s</code><span class="screen-reader-text">%2$s</span></button></li>', $tag, $explanation );
     240                                        }
     241                                        echo '</ul>';
     242                                }
     243                                ?>
     244                        </div>
    209245                </td>
    210246        </tr>
    211247</table>