Make WordPress Core

Ticket #29872: 29872.2.diff

File 29872.2.diff, 3.6 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 1472dd9..644adb0 100644
    table.form-table td .updated p { 
    940940        vertical-align: middle;
    941941}
    942942
     943.form-table.permalink-structure .available-shortcode-tags li {
     944        float: left;
     945        margin-right: 5px;
     946}
     947
     948.form-table.permalink-structure .available-shortcode-tags button {
     949        background: none;
     950        border: none;
     951        padding: 0;
     952}
     953
     954.form-table.permalink-structure .available-shortcode-tags code {
     955        margin: 0;
     956        cursor: pointer;
     957}
     958
    943959/*------------------------------------------------------------------------------
    944960  21.0 - Network Admin
    945961------------------------------------------------------------------------------*/
  • src/wp-admin/js/common.js

    diff --git src/wp-admin/js/common.js src/wp-admin/js/common.js
    index 200d3e4..272e467 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( e ) {
     182        var $permalinkStructure = $( '#permalink_structure' ),
     183            textToAppend        = $( this ).find( 'code' ).text() + '/';
     184
     185        e.preventDefault();
     186
     187        $( '#custom_selection' ).prop( 'checked', true );
     188
     189        if ( '/' !== $permalinkStructure.val().substr( -1 ) ) {
     190                textToAppend = '/' + textToAppend;
     191        }
     192        $permalinkStructure.val( $( '#permalink_structure' ).val() + textToAppend );
     193} )
     194
    178195$document.ready( function() {
    179196        var checks, first, last, checked, sliced, mobileEvent, transitionTimeout, focusedRowActions,
    180197                lastClicked = false,
  • src/wp-admin/options-permalink.php

    diff --git src/wp-admin/options-permalink.php src/wp-admin/options-permalink.php
    index b6c52c5..c2e3641 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                        <p>
     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                                _e( 'Available tags:' );
     234                                echo '<ul class="available-shortcode-tags">';
     235                                foreach ( $available_tags as $tag => $explanation ) {
     236                                        printf( '<li><button><code>%1$s</code><span class="screen-reader-text">%2$s</span></button></li>', $tag, $explanation );
     237                                }
     238                                echo '</ul>';
     239                                ?>
     240                        </p>
    209241                </td>
    210242        </tr>
    211243</table>