Make WordPress Core

Changeset 41598


Ignore:
Timestamp:
09/26/2017 08:23:07 AM (7 years ago)
Author:
swissspidy
Message:

Permalinks: Change structure tag button state more reliably.

Changes the highlighted tag buttons accordingly when selecting one of the commong permalink settings.

Deprecates options_permalink_add_js() as that JavaScript isn't added inline anymore.

Fixes #29872.

Location:
trunk/src/wp-admin
Files:
4 edited

Legend:

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

    r41275 r41598  
    14921492    }
    14931493}
     1494
     1495/**
     1496 * Display JavaScript on the page.
     1497 *
     1498 * @since 3.5.0
     1499 * @deprecated 4.9.0
     1500 */
     1501function options_permalink_add_js() {
     1502    ?>
     1503    <script type="text/javascript">
     1504        jQuery(document).ready(function() {
     1505            jQuery('.permalink-structure input:radio').change(function() {
     1506                if ( 'custom' == this.value )
     1507                    return;
     1508                jQuery('#permalink_structure').val( this.value );
     1509            });
     1510            jQuery( '#permalink_structure' ).on( 'click input', function() {
     1511                jQuery( '#custom_selection' ).prop( 'checked', true );
     1512            });
     1513        });
     1514    </script>
     1515    <?php
     1516}
  • trunk/src/wp-admin/includes/options.php

    r40897 r41598  
    9292 * @since 3.5.0
    9393 */
    94 function options_permalink_add_js() {
    95     ?>
    96 <script type="text/javascript">
    97 jQuery(document).ready(function() {
    98     jQuery('.permalink-structure input:radio').change(function() {
    99         if ( 'custom' == this.value )
    100             return;
    101         jQuery('#permalink_structure').val( this.value );
    102     });
    103     jQuery( '#permalink_structure' ).on( 'click input', function() {
    104         jQuery( '#custom_selection' ).prop( 'checked', true );
    105     });
    106 });
    107 </script>
    108 <?php
    109 }
    110 
    111 /**
    112  * Display JavaScript on the page.
    113  *
    114  * @since 3.5.0
    115  */
    11694function options_reading_add_js() {
    11795?>
  • trunk/src/wp-admin/js/common.js

    r41183 r41598  
    182182var permalinkStructureFocused = false,
    183183    $permalinkStructure       = $( '#permalink_structure' ),
     184    $permalinkStructureInputs = $( '.permalink-structure input:radio' ),
     185    $permalinkCustomSelection = $( '#custom_selection' ),
    184186    $availableStructureTags   = $( '.form-table.permalink-structure .available-structure-tags button' );
     187
     188// Change permalink structure input when selecting one of the common structures.
     189$permalinkStructureInputs.on( 'change', function() {
     190    if ( 'custom' === this.value ) {
     191        return;
     192    }
     193
     194    $permalinkStructure.val( this.value );
     195
     196    // Update button states after selection.
     197    $availableStructureTags.each( function() {
     198        changeStructureTagButtonState( $( this ) );
     199    } );
     200} );
     201
     202$permalinkStructure.on( 'click input', function() {
     203    $permalinkCustomSelection.prop( 'checked', true );
     204} );
    185205
    186206// Check if the permalink structure input field has had focus at least once.
     
    250270    }
    251271
    252     $( '#custom_selection' ).prop( 'checked', true );
     272    $permalinkCustomSelection.prop( 'checked', true );
    253273
    254274    // Prepend and append slashes if necessary.
  • trunk/src/wp-admin/options-permalink.php

    r41182 r41598  
    4646    '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    4747);
    48 
    49 add_filter('admin_head', 'options_permalink_add_js');
    5048
    5149$home_path = get_home_path();
Note: See TracChangeset for help on using the changeset viewer.