/** * Display a to-do list * @param int $completed * @return void */ public function display($completed = 0) { list($this->url, $action) = CTDL_Lib::set_variables(); if (is_admin()) { $completed = 1; } if (is_admin()) { $this->list .= '<div class="wrap"><div class="icon32"><img src="' . CTDL_PLUGIN_URL . '/images/cleverness-todo-icon.png" alt="" /></div> <h2>' . apply_filters('ctdl_todo_list', esc_html__('To-Do List', 'cleverness-to-do-list')) . '</h2>'; } // get the existing to-do data and show the edit form if editing a to-do item if ($action == 'edit-todo') { $this->edit_todo_item($this->url); return; } // otherwise, display the list of to-do items $this->list .= $this->show_heading(); $this->list .= '<table id="todo-list" class="todo-table widefat">'; $this->show_table_headings(); $this->loop_through_todos(); $this->list .= '</table>'; /* Show completed items in admin */ if ($completed == 1) { wp_reset_postdata(); $this->list .= $this->show_completed_heading(); $this->list .= '<table id="todo-list-completed" class="todo-table widefat">'; $this->show_table_headings(1); $this->loop_through_todos(1); $this->list .= '</table>'; } $this->list .= $this->create_new_todo_form(); if (is_admin()) { $this->list .= '</div>'; } wp_reset_postdata(); }
/** * Display the To-Do List */ public function display($complete = 0) { $atts = shortcode_atts(array('title' => '', 'type' => 'list', 'priorities' => 1, 'assigned' => 1, 'deadline' => 1, 'progress' => 1, 'addedby' => 1, 'date' => 0, 'completed' => '', 'completed_title' => '', 'list_type' => 'ol', 'category' => '0'), $this->atts, 'todolist'); $this->list = ''; $category = $atts['category'] == 'all' ? $category = '0' : $atts['category']; list($this->url, $this->action) = CTDL_Lib::set_variables(); if ($atts['completed'] != 'only') { if ($atts['type'] == 'table') { $this->list .= '<table id="todo-list" class="todo-table todolist">'; if ($atts['title'] != '') { $this->list .= '<caption>' . $atts['title'] . '</caption>'; } $this->show_table_headings(); $this->loop_through_todos(0, $category); $this->list .= '</table>'; } elseif ($atts['type'] == 'list') { if ($atts['title'] != '') { $this->list .= '<h3 class="todo-title">' . esc_html($atts['title']) . '</h3>'; } if (CTDL_Loader::$settings['categories'] == 0 || CTDL_Loader::$settings['sort_order'] != 'cat_id') { $this->list .= '<' . $atts['list_type'] . ' class="todolist">'; } $this->loop_through_todos(0, $category); $this->list .= '</' . $atts['list_type'] . '>'; } } if ($atts['completed'] == 'show' || $atts['completed'] == 1 || $atts['completed'] == 'only') { wp_reset_postdata(); $this->cat_id = ''; if ($atts['type'] == 'table') { $this->list .= '<table id="todo-list-completed" class="todo-table todolist">'; if ($atts['completed_title'] != '') { $this->list .= '<caption>' . $atts['completed_title'] . '</caption>'; } $this->show_table_headings(1); $this->loop_through_todos(1, $category); $this->list .= '</table>'; } elseif ($atts['type'] == 'list') { /** @var $completed_title string */ if ($atts['completed_title'] != '') { $this->list .= '<h3 class="todo-title">' . esc_html($atts['completed_title']) . '</h3>'; } $this->list .= '<div class="refresh">'; if (CTDL_Loader::$settings['categories'] == 0 || CTDL_Loader::$settings['sort_order'] != 'cat_id') { $this->list .= '<' . $atts['list_type'] . ' class="todolist todolist-completed">'; } $this->loop_through_todos(1, $category); $this->list .= '</' . $atts['list_type'] . '></div>'; } } wp_reset_postdata(); }