Advertisement
daymobrew

FF Shortcode generates Polylang warning

May 5th, 2015
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <?php
  2.  
  3. // Shortcode to display fastforests_status CPT
  4. add_shortcode('fastforests_status', 'fastforests_status_listing');
  5. function fastforests_status_listing($atts, $content, $code) {
  6.     $ds_args = array(
  7.       'post_type' => 'fastforests_status',
  8.       'no_found_rows' => true,
  9.       'post_status' => 'publish',
  10.       'ignore_sticky_posts' => true,
  11.       'posts_per_page' => -1,
  12.     );
  13.  
  14.  
  15.     $ds = new WP_Query( $ds_args );
  16.     if ($ds->have_posts()) {
  17.         $current_date = time();
  18.         $due_date_close = 60 * 60 *24 * 40; // 40 days.
  19.         $status_table = '<table id="fastforests_status" class="tablesorter"><thead><tr><th>Task</th><th>Owner</th><th>% complete</th><th>Due Date</th></tr></thead><tbody>';
  20.  
  21.         while ( $ds->have_posts() ) : $ds->the_post();
  22.           $task_class = 'task_ok';
  23.           $date_due = DateTime::createFromFormat('Ymd', get_field('date_due'));
  24.           $percent_complete = get_field('percent_complete');
  25.          
  26.           $time_until_task_due = $date_due->getTimestamp() - $current_date;
  27.          
  28.           if ($percent_complete == 100) {
  29.               $task_class = 'task_complete';
  30.           } elseif ($time_until_task_due < $due_date_close) {
  31.               $task_class = 'task_nearly_due';
  32.               if ($time_until_task_due < 0) {
  33.                   $task_class = 'task_overdue';
  34.               }
  35.           }
  36.           $status_table .= sprintf('<tr class="%s"><td>%s</td><td>%s</td><td>%s %%</td><td>%s</td></tr>%s', $task_class, get_the_title(), get_field('who'), $percent_complete, $date_due->format('d-m-Y'), "\n");
  37.         endwhile;
  38.        
  39.        
  40.         $status_table .= '</tbody></table>';
  41.     }
  42.  
  43.     wp_reset_postdata();
  44.     return $status_table;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement