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. git-svn-id: https://develop.svn.wordpress.org/trunk@41598 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2f878162a1
commit
f8f263cdb9
@ -1491,3 +1491,26 @@ function post_form_autocomplete_off() {
|
||||
echo ' autocomplete="off"';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display JavaScript on the page.
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @deprecated 4.9.0
|
||||
*/
|
||||
function options_permalink_add_js() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('.permalink-structure input:radio').change(function() {
|
||||
if ( 'custom' == this.value )
|
||||
return;
|
||||
jQuery('#permalink_structure').val( this.value );
|
||||
});
|
||||
jQuery( '#permalink_structure' ).on( 'click input', function() {
|
||||
jQuery( '#custom_selection' ).prop( 'checked', true );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
@ -86,28 +86,6 @@ function options_general_add_js() {
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display JavaScript on the page.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
function options_permalink_add_js() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('.permalink-structure input:radio').change(function() {
|
||||
if ( 'custom' == this.value )
|
||||
return;
|
||||
jQuery('#permalink_structure').val( this.value );
|
||||
});
|
||||
jQuery( '#permalink_structure' ).on( 'click input', function() {
|
||||
jQuery( '#custom_selection' ).prop( 'checked', true );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display JavaScript on the page.
|
||||
*
|
||||
|
@ -181,8 +181,28 @@ $('.contextual-help-tabs').delegate('a', 'click', function(e) {
|
||||
|
||||
var permalinkStructureFocused = false,
|
||||
$permalinkStructure = $( '#permalink_structure' ),
|
||||
$permalinkStructureInputs = $( '.permalink-structure input:radio' ),
|
||||
$permalinkCustomSelection = $( '#custom_selection' ),
|
||||
$availableStructureTags = $( '.form-table.permalink-structure .available-structure-tags button' );
|
||||
|
||||
// Change permalink structure input when selecting one of the common structures.
|
||||
$permalinkStructureInputs.on( 'change', function() {
|
||||
if ( 'custom' === this.value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permalinkStructure.val( this.value );
|
||||
|
||||
// Update button states after selection.
|
||||
$availableStructureTags.each( function() {
|
||||
changeStructureTagButtonState( $( this ) );
|
||||
} );
|
||||
} );
|
||||
|
||||
$permalinkStructure.on( 'click input', function() {
|
||||
$permalinkCustomSelection.prop( 'checked', true );
|
||||
} );
|
||||
|
||||
// Check if the permalink structure input field has had focus at least once.
|
||||
$permalinkStructure.on( 'focus', function( event ) {
|
||||
permalinkStructureFocused = true;
|
||||
@ -249,7 +269,7 @@ $availableStructureTags.on( 'click', function() {
|
||||
selectionStart = selectionEnd = permalinkStructureValue.length;
|
||||
}
|
||||
|
||||
$( '#custom_selection' ).prop( 'checked', true );
|
||||
$permalinkCustomSelection.prop( 'checked', true );
|
||||
|
||||
// Prepend and append slashes if necessary.
|
||||
if ( '/' !== permalinkStructureValue.substr( 0, selectionStart ).substr( -1 ) ) {
|
||||
|
@ -46,8 +46,6 @@ get_current_screen()->set_help_sidebar(
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
);
|
||||
|
||||
add_filter('admin_head', 'options_permalink_add_js');
|
||||
|
||||
$home_path = get_home_path();
|
||||
$iis7_permalinks = iis7_supports_permalinks();
|
||||
$permalink_structure = get_option( 'permalink_structure' );
|
||||
|
Loading…
Reference in New Issue
Block a user