/**
 * Check if a field should be displayed
 * @static
 *
 * @param $field
 *
 * @return bool
 */
function ctdl_check_field($field)
{
    global $CTDL_widget_settings, $CTDL_category_id;
    $permission = false;
    switch ($field) {
        case 'completed':
            $permission = CTDL_Loader::$settings['show_completed_date'] == 1 && get_post_meta(get_the_ID(), '_completed', true) != '0000-00-00 00:00:00' ? true : false;
            break;
        case 'planner':
            $permission = CTDL_Loader::$settings['post_planner'] == 1 && get_post_meta(get_the_ID(), '_planner', true) != null && PostPlanner_Lib::planner_exists(get_post_meta(get_the_ID(), '_planner', true)) ? true : false;
            break;
        case 'progress':
            $permission = CTDL_Loader::$settings['show_progress'] == 1 && get_post_meta(get_the_ID(), '_progress', true) != null ? true : false;
            break;
        case 'assigned':
            $data = get_post_meta(get_the_ID(), '_assign', true);
            $permission = CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 0 && current_user_can(CTDL_Loader::$settings['view_all_assigned_capability']) || CTDL_Loader::$settings['list_view'] != 0 && CTDL_Loader::$settings['show_only_assigned'] == 1 && CTDL_Loader::$settings['assign'] == 0 ? true : false;
            $permission = $permission == true && ($data != 0 && $data != null && $data != '-1' && !(is_array($data) && in_array('-1', $data))) ? true : false;
            break;
        case 'dashboard-deadline':
            $permission = CTDL_Loader::$settings['show_deadline'] == 1 && isset(CTDL_Loader::$dashboard_settings['show_dashboard_deadline']) && CTDL_Loader::$dashboard_settings['show_dashboard_deadline'] == 1 && get_post_meta(get_the_ID(), '_deadline', true) != null ? true : false;
            break;
        case 'dashboard-edit':
            $permission = CTDL_Loader::$dashboard_settings['show_edit_link'] == 1 && (current_user_can(CTDL_Loader::$settings['edit_capability']) || CTDL_Loader::$settings['list_view'] == 0) ? true : false;
            break;
        case 'dashboard-author':
            $permission = CTDL_Loader::$settings['list_view'] == 1 && isset(CTDL_Loader::$dashboard_settings['dashboard_author']) && CTDL_Loader::$dashboard_settings['dashboard_author'] == 0 ? true : false;
            break;
        case 'dashboard-category-heading':
            $data = get_the_terms(get_the_ID(), 'todocategories');
            $cat = '';
            if ($data != NULL) {
                foreach ($data as $category) {
                    $cat = $category->term_id;
                }
            }
            $permission = CTDL_Loader::$settings['categories'] == 1 && CTDL_Loader::$settings['sort_order'] == 'cat_id' && (0 == $CTDL_category_id || $cat != $CTDL_category_id) ? true : false;
            break;
        case 'dashboard-category':
            $data = get_the_terms(get_the_ID(), 'todocategories');
            $permission = CTDL_Loader::$settings['categories'] == 1 && CTDL_Loader::$settings['sort_order'] != 'cat_id' && $data != NULL ? true : false;
            break;
        case 'widget-deadline':
            $permission = CTDL_Loader::$settings['show_deadline'] == 1 && $CTDL_widget_settings['deadline'] == 1 && get_post_meta(get_the_ID(), '_deadline', true) != null ? true : false;
            break;
        case 'widget-progress':
            $permission = CTDL_Loader::$settings['show_progress'] == 1 && $CTDL_widget_settings['progress'] == 1 && get_post_meta(get_the_ID(), '_progress', true) != null ? true : false;
            break;
        case 'widget-assigned':
            $data = get_post_meta(get_the_ID(), '_assign', true);
            $permission = CTDL_Loader::$settings['assign'] == 0 && $CTDL_widget_settings['assigned_to'] == 1 && CTDL_Loader::$settings['list_view'] != 0 ? true : false;
            $permission = $permission == true && ($data != 0 && $data != null && $data != '-1' && !(is_array($data) && in_array('-1', $data))) ? true : false;
            break;
    }
    return $permission;
}
<?php

/**
 * Post Planner Plugin Planner Metabox
 *
 * Create the Post Planner metabox in Posts
 * @author C.M. Kendrick <*****@*****.**>
 * @package post-planner
 * @version 1.1
 */
global $post;
$planner_id = get_post_meta($post->ID, '_postplanner', true);
$planner_exists = PostPlanner_Lib::planner_exists($planner_id);
echo '<div class="post-planner-meta-control post-planner">';
echo '<input type="hidden" id="post-planner-post-id" value="' . absint($post->ID) . '" />';
do_action('post_planner_before_planner_metabox');
if ($planner_id != '' && $planner_exists == true) {
    $planner_type = get_post_meta($planner_id, '_pp_type', true);
    echo '<input type="hidden" id="post-planner-id" value="' . absint($planner_id) . '" />';
    echo '<input type="hidden" id="post-planner-type" value="' . esc_attr($planner_type) . '" />';
    PostPlanner::display_planner($planner_id);
    PostPlanner::display_status($planner_id);
    if (PostPlanner_Loader::$settings['duedate'] == 1) {
        PostPlanner::display_duedate($planner_id);
    }
    if (PostPlanner_Loader::$settings['assignments'] == 1) {
        PostPlanner::display_assignments($planner_id);
    }
    echo '<div class="clear"></div>';
    if (PostPlanner_Lib::check_for_content($planner_id) || PostPlanner_Loader::$settings['images'] == 1 || PostPlanner_Loader::$settings['files'] == 1 || PostPlanner_Loader::$settings['references'] == 1 || PostPlanner_Loader::$settings['checklist'] == 1 || PostPlanner_Loader::$settings['comments'] == 1) {
        ?>
 /**
  * Show the Post Planner
  * @param $planner
  * @since 3.2
  */
 public function show_planner($planner)
 {
     $this->list .= '<td class="todo-planner">';
     if ($planner != 0 && PostPlanner_Lib::planner_exists($planner)) {
         $url = admin_url('post.php?post=' . absint($planner) . '&action=edit');
         $this->list .= '<a href="' . esc_url($url) . '">' . get_the_title($planner) . '</a>';
     }
     $this->list .= '</td>';
 }
 /**
  * Associate Post Ajax Callback
  * @static
  * @since 1.0
  */
 public static function associate_post_callback()
 {
     check_ajax_referer('postplanner');
     $type = esc_attr($_POST['postplanner_type']);
     if ($type == 'post') {
         $permission = current_user_can('edit_posts');
     } elseif ($type == 'page') {
         $permission = current_user_can('edit_pages');
     } else {
         $permission = apply_filters('post_planner_associated_permissions', current_user_can('edit_posts'), $type);
     }
     if ($permission == true) {
         $planner_id = absint($_POST['postplanner_planner_id']);
         $post_id = absint($_POST['postplanner_post_id']);
         $existing = get_post_meta($post_id, '_postplanner', true);
         // if the post is already associated with another planner, return error message
         if ($existing != '' && $existing != $planner_id) {
             // check to make sure that the planner still exists
             $exists = PostPlanner_Lib::planner_exists($existing);
             if ($exists == true) {
                 $status = 2;
                 // else associate the post with the planner
             } else {
                 $status = update_post_meta($post_id, '_postplanner', $planner_id);
                 if ($status == true) {
                     $status = update_post_meta($planner_id, '_pp_postid', $post_id);
                 }
                 $status = $status == true ? 1 : -1;
             }
             // else associate the post with the planner
         } else {
             $status = update_post_meta($post_id, '_postplanner', $planner_id);
             if ($status == true) {
                 $status = update_post_meta($planner_id, '_pp_postid', $post_id);
             }
             $status = $status == true ? 1 : -1;
         }
     } else {
         $status = -1;
     }
     echo $status;
     die;
     // this is required to return a proper result
 }