Make WordPress Core

Changeset 41547 for trunk


Ignore:
Timestamp:
09/20/2017 03:15:19 AM (9 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-categories.php

    r41181 r41547  
    6060                        'orderby'      => 'name',
    6161                        'show_count'   => $c,
    62                         'hierarchical' => $h
     62                        'hierarchical' => $h,
    6363                );
    6464
    6565                if ( $d ) {
     66                        echo sprintf( '<form action="%s" method="get">', esc_url( home_url() ) );
    6667                        $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
    6768                        $first_dropdown = false;
    … …  
    8283                         */
    8384                        wp_dropdown_categories( apply_filters( 'widget_categories_dropdown_args', $cat_args ) );
     85
     86                        echo '</form>';
    8487                        ?>
    8588
    … …  
    9093        function onCatChange() {
    9194                if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
    92                         location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
     95                        dropdown.parentNode.submit();
    9396                }
    9497        }
Note: See TracChangeset for help on using the changeset viewer.