[wp-trac] [WordPress Trac] #29319: filter dayswithposts in widget calendar
WordPress Trac
noreply at wordpress.org
Fri Aug 22 14:28:54 UTC 2014
#29319: filter dayswithposts in widget calendar
-----------------------------+-----------------------------
Reporter: kkarpieszuk | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Hello
here is Konrad, WPML developer. We are fighting now with bug related
WordPress calendar widget: it always displays all posts, and we want to
filter its results regarding to language of post.
Steps to reproduce:
1. install WPML
2. publish some post in En language July 1st
3. translate this post July 2nd to Polish language
4. activate calendar widget
Result: calendar will show that there are posts in July 1st and 2nd.
Expected result: when user displays English posts, calendar should display
only July 1st. When user switches to Polish language, calndar should
display only July 2nd.
We want to fix this in WPML but we need filter inside of get_calendar()
function.
Wordpress gets days with posts by this query inside of get_calendar():
{{{
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01
00:00:00'
AND post_type = 'post' AND post_status = 'publish'
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
ARRAY_N);
}}}
The result should be able to filter, then WPML will hook here.
I am attaching proposed diff file.
(I see that we can hook into get_calendar filter but this variable has
full html output of calendar. This will unefficient to parse this HTML)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29319>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list