mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Widgets: Pre-select currently viewed archive in the Archives dropdown widget, for consistency with the Categories widget.
Props robobot3000, audrasjb, afercia, Themonic. Fixes #40662. git-svn-id: https://develop.svn.wordpress.org/trunk@44897 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -58,7 +58,7 @@ class WP_Widget_Archives extends WP_Widget {
|
||||
$dropdown_id = "{$this->id_base}-dropdown-{$this->number}";
|
||||
?>
|
||||
<label class="screen-reader-text" for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo $title; ?></label>
|
||||
<select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
|
||||
<select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown">
|
||||
<?php
|
||||
/**
|
||||
* Filters the arguments for the Archives widget drop-down.
|
||||
@@ -104,6 +104,21 @@ class WP_Widget_Archives extends WP_Widget {
|
||||
<?php wp_get_archives( $dropdown_args ); ?>
|
||||
|
||||
</select>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
(function() {
|
||||
var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
|
||||
function onSelectChange() {
|
||||
if ( dropdown.options[ dropdown.selectedIndex ].value !== '' ) {
|
||||
document.location.href = this.options[ this.selectedIndex ].value;
|
||||
}
|
||||
}
|
||||
dropdown.onchange = onSelectChange;
|
||||
})();
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
||||
<?php } else { ?>
|
||||
<ul>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user