Widgets: Add Customizer preview support to the Category widget when navigating to a category via dropdown.
Switch to using a `form` that is submitted as opposed to making a direct JavaScript call to change the `window.location`. This ensures the Customizer is able to inject the customized state into the request. Fixes #41671. Built from https://develop.svn.wordpress.org/trunk@41547 git-svn-id: http://core.svn.wordpress.org/trunk@41380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f2589e222e
commit
067970ca82
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41522';
|
||||
$wp_version = '4.9-alpha-41547';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -59,10 +59,11 @@ class WP_Widget_Categories extends WP_Widget {
|
|||
$cat_args = array(
|
||||
'orderby' => 'name',
|
||||
'show_count' => $c,
|
||||
'hierarchical' => $h
|
||||
'hierarchical' => $h,
|
||||
);
|
||||
|
||||
if ( $d ) {
|
||||
echo sprintf( '<form action="%s" method="get">', esc_url( home_url() ) );
|
||||
$dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
|
||||
$first_dropdown = false;
|
||||
|
||||
|
@ -81,6 +82,8 @@ class WP_Widget_Categories extends WP_Widget {
|
|||
* @param array $cat_args An array of Categories widget drop-down arguments.
|
||||
*/
|
||||
wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
|
||||
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
<script type='text/javascript'>
|
||||
|
@ -89,7 +92,7 @@ class WP_Widget_Categories extends WP_Widget {
|
|||
var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
|
||||
function onCatChange() {
|
||||
if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
|
||||
location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
|
||||
dropdown.parentNode.submit();
|
||||
}
|
||||
}
|
||||
dropdown.onchange = onCatChange;
|
||||
|
|
Loading…
Reference in New Issue