Display correct title in Archives widget if the type of archive was changed using the 'widget_archives_dropdown_args' filter.

props floriansimeth for initial patch.
fixes #31024.

git-svn-id: https://develop.svn.wordpress.org/trunk@31241 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-01-19 08:25:36 +00:00
parent 4a1cf7a38b
commit 352be0b432

View File

@ -287,8 +287,6 @@ class WP_Widget_Archives extends WP_Widget {
if ( $d ) {
?>
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php esc_attr_e( 'Select Month' ); ?></option>
<?php
/**
* Filter the arguments for the Archives widget drop-down.
@ -299,12 +297,34 @@ class WP_Widget_Archives extends WP_Widget {
*
* @param array $args An array of Archives widget drop-down arguments.
*/
wp_get_archives( apply_filters( 'widget_archives_dropdown_args', array(
$dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
'type' => 'monthly',
'format' => 'option',
'show_post_count' => $c
) ) );
?>
) );
switch ( $dropdown_args['type'] ) {
case 'yearly':
$label = __( 'Select Year' );
break;
case 'monthly':
$label = __( 'Select Month' );
break;
case 'daily':
$label = __( 'Select Day' );
break;
case 'weekly':
$label = __( 'Select Week' );
break;
default:
$label = __( 'Select Post' );
break;
}
?>
<option value=""><?php echo esc_attr( $label ); ?></option>
<?php wp_get_archives( $dropdown_args ); ?>
</select>
<?php
} else {