Opened 10 years ago
Closed 10 years ago
#31024 closed enhancement (fixed)
Add a new hook to the first <option>-element of the archive widget dropdown
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Widgets | Keywords: | has-patch |
Focuses: | template | Cc: |
Description
Hey WP-Community,
I would kindly ask if it's possible to integrate a new filter into the default-widgets.php.
It should allow us to change the title of the first <option> element.
The problem is that if I hook into the widget_archives_dropdown_args and change the argument type
from monthly
to yearly
the script would always output "Select Month" instead of "Select Year".
Of course it's possible to hook into the gettext
filter but I think this is not the ideal solution as translated texts could be used elsewhere, too.
So what I mean is to change the following line:
<option value=""><?php esc_attr_e( 'Select Month' ); ?></option>
into something like this:
<option value=""><?php esc_attr_e( apply_filters( 'widget_archives_dropdown_first', 'Select Month' ) ); ?></option>
Thanks
Attachments (3)
Change History (11)
#4
@
10 years ago
Instead of:
<option value=""><?php esc_attr_e( apply_filters( 'widget_archives_dropdown_first', 'Select Month' ) ); ?></option>
It should actually do something like:
<option value=""><?php echo esc_attr( apply_filters( 'widget_archives_dropdown_first', __( 'Select Month' ) ) ); ?></option>
As otherwise the string won't get translated properly.
And the filter would probably be better named widget_archives_dropdown_first_option_label
.
#5
in reply to:
↑ description
@
10 years ago
- Milestone changed from Future Release to 4.2
Replying to floriansimeth:
The problem is that if I hook into the widget_archives_dropdown_args and change the argument
type
frommonthly
toyearly
the script would always output "Select Month" instead of "Select Year".
Instead of introducing a new filter, can we set the label contextually based on the passed type
value?
See 31024.patch.
#6
@
10 years ago
Hah. SergeyBiryukov and I had the same idea. 31024.patch and 31024.diff eliminate the need for the filter by selecting a title by switching on the $args['type']
That makes sense.
We should filter the localized version of the string though.