Created
March 27, 2015 12:39
-
-
Save mohsinrasool/6f86fb8901946c2656b0 to your computer and use it in GitHub Desktop.
Displays Assigned Cleverness todos in WP Full Calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Displays Assigned Cleverness todos in WP Full Calendar | |
* | |
* @return $items | |
* @author Mohsin Rasool | |
**/ | |
add_filter( 'wpfc_events', 'wpfc_add_tasks' ); | |
add_filter( 'wpfc_ajax', 'wpfc_add_tasks' ); | |
function wpfc_add_tasks($items) { | |
foreach ($items as $key => $item) { | |
$items[$key]['color'] = '#006400'; | |
$items[$key]['borderColor'] = '#006400'; | |
} | |
$current_user = wp_get_current_user(); | |
$args = array( | |
'post_type' => 'todo', | |
'meta_query' => array( | |
array( | |
'key' => '_assign', | |
'value' => $current_user->ID | |
), | |
array( | |
'key' => '_status', | |
'value' => '0' | |
), | |
array( | |
'relation' => 'AND', | |
array( | |
'key' => '_deadline', | |
'value' => $_GET['start'], | |
'compare' => '>=' | |
), | |
array( | |
'key' => '_deadline', | |
'value' => $_GET['end'], | |
'compare' => '<=' | |
), | |
), | |
), | |
); | |
$todos = new WP_Query($args); | |
while ($todos->have_posts()) { | |
global $post; | |
$todos->the_post(); | |
$post_timestamp = get_post_meta(get_the_ID(), '_deadline',true); | |
$items[] = array ( | |
"allDay" => true, | |
"title" => get_the_title(), | |
"color" => '#1e285c', | |
"start" => date('Y-m-d\TH:i:s', $post_timestamp), | |
"end" => date('Y-m-d\TH:i:s', $post_timestamp), | |
"url" => '#', | |
'post_id' => get_the_ID() | |
); | |
} | |
return $items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment