/**
  * Generate the To-Do List
  * @param $todo_items
  * @param int $completed
  * @param int $visible
  * @return array $posts_to_exclude
  */
 protected function show_todo_list_items($todo_items, $completed = 0, $visible = 0)
 {
     $atts = shortcode_atts(array('title' => '', 'type' => 'list', 'priorities' => 1, 'assigned' => 1, 'deadline' => 1, 'progress' => 1, 'addedby' => 1, 'date' => 0, 'list_type' => 'ol', 'category' => '0', 'completed_date' => 0), $this->atts, 'todolist');
     while ($todo_items->have_posts()) {
         $todo_items->the_post();
         $id = get_the_ID();
         $posts_to_exclude[] = $id;
         if ($visible == 0) {
             list($the_priority, $assign_meta, $deadline_meta, $completed_meta, $progress_meta) = CTDL_Lib::get_todo_meta($id);
             $priority_class = CTDL_Lib::set_priority_class($the_priority);
             if ($atts['type'] == 'list' && CTDL_Loader::$settings['categories'] == 1 && CTDL_Loader::$settings['sort_order'] == 'cat_id') {
                 $this->show_category_headings(get_the_terms($id, 'todocategories'), $atts['list_type'], $completed);
             }
             if ($atts['type'] == 'table') {
                 $this->list .= '<tr id="todo-' . esc_attr($id) . '"' . $priority_class . '>';
             } else {
                 $this->list .= '<li' . $priority_class . '>';
             }
             $this->show_todo_text(get_the_content(), $atts['type']);
             if (($atts['priorities'] == 'show' || $atts['priorities'] == 1) && $atts['type'] == 'table') {
                 $this->show_priority($the_priority);
             }
             if (($atts['progress'] == 'show' || $atts['progress'] == 1) && CTDL_Loader::$settings['show_progress'] == 1) {
                 $this->show_progress($progress_meta, $atts['type'], $completed);
             }
             if ($atts['category'] == 0 && $atts['type'] == 'table' && CTDL_Loader::$settings['categories'] == 1) {
                 $this->show_category(get_the_terms($id, 'todocategories'));
             }
             if (($atts['assigned'] == 'show' || $atts['assigned'] == 1) && ((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)) {
                 $this->show_assigned($assign_meta, $atts['type']);
             }
             if (($atts['addedby'] == 'show' || $atts['addedby'] == 1) && CTDL_Loader::$settings['list_view'] == 1 && CTDL_Loader::$settings['todo_author'] == 0) {
                 $this->show_addedby(get_the_author(), $atts['type']);
             }
             if (($atts['deadline'] == 'show' || $atts['deadline'] == 1) && CTDL_Loader::$settings['show_deadline'] == 1) {
                 $this->show_deadline($deadline_meta, $atts['type']);
             }
             if ($atts['date'] == 1 && CTDL_Loader::$settings['show_date_added'] == 1) {
                 $this->show_date_added(get_the_date('Ymd'), get_the_date(CTDL_Loader::$settings['date_format']), $atts['type']);
             }
             if ($atts['completed_date'] == 1 && CTDL_Loader::$settings['show_completed_date'] && $completed == 1) {
                 $this->show_completed($completed_meta, $atts['type']);
             }
             $this->list .= do_action('ctdl_list_items');
             if ($atts['type'] == 'table') {
                 $this->list .= '</tr>';
             } else {
                 $this->list .= '</li>';
             }
         }
     }
     wp_reset_postdata();
     return $posts_to_exclude;
 }
    /**
     * Creates the HTML for the form used to edit a to-do item
     * @param $todo_item
     * @return string Form HTML
     */
    protected function create_edit_todo_form($todo_item)
    {
        $id = $todo_item->ID;
        list($priority, $assign_meta, $deadline_meta, $completed_meta, $progress_meta, $planner_meta) = CTDL_Lib::get_todo_meta($id);
        if (is_admin()) {
            $url = 'admin.php?page=cleverness-to-do-list';
        } else {
            $url = strtok($this->url, "?");
        }
        $this->form = '';
        if (is_admin()) {
            $this->form .= apply_filters('ctdl_edit_heading', '<h3>' . esc_html__('Edit To-Do Item', 'cleverness-to-do-list') . '</h3>');
        }
        $this->form .= '<form name="edittodo" id="edittodo" action="' . $url . '" method="post"><table class="todo-form form-table">';
        $this->create_priority_field($priority);
        $this->create_deadline_field($deadline_meta);
        $this->create_category_field(get_the_terms($id, 'todocategories'));
        if (CTDL_PP) {
            $this->create_planner_field($planner_meta);
        }
        $this->create_assign_field($assign_meta);
        $this->create_progress_field($progress_meta);
        $this->form .= do_action('ctdl_edit_form_action');
        $this->form = apply_filters('ctdl_edit_form', $this->form);
        $this->create_todo_text_field($todo_item->post_content);
        $this->form .= '</table>' . wp_nonce_field('todoupdate', 'todoupdate', true, false) . '<input type="hidden" name="action" value="updatetodo" />
        	    <p class="submit"><input type="submit" name="submit" class="button-primary" value="' . apply_filters('ctdl_edit_text', esc_attr__('Save Changes', 'cleverness-to-do-list')) . '" /></p>
				<input type="hidden" name="id" value="' . absint($id) . '" />';
        $this->form .= '</form>';
        return $this->form;
    }