'', 'title' => '', 'description' => '', 'image' => '', 'tasks' => array(), ); $data = wp_parse_args( $data, $defaults ); $this->task_list = $task_list; $this->id = $data['id']; $this->title = $data['title']; $this->description = $data['description']; $this->image = $data['image']; $this->task_names = $data['task_names']; } /** * Returns if section is complete. * * @return boolean; */ private function is_complete() { $complete = true; foreach ( $this->task_names as $task_name ) { if ( null !== $this->task_list && isset( $this->task_list->task_class_id_map[ $task_name ] ) ) { $task = $this->task_list->get_task( $this->task_list->task_class_id_map[ $task_name ] ); if ( $task->can_view() && ! $task->is_complete() ) { $complete = false; break; } } } return $complete; } /** * Get the list for use in JSON. * * @return array */ public function get_json() { return array( 'id' => $this->id, 'title' => $this->title, 'description' => $this->description, 'image' => $this->image, 'tasks' => array_map( function( $task_name ) { if ( null !== $this->task_list && isset( $this->task_list->task_class_id_map[ $task_name ] ) ) { return $this->task_list->task_class_id_map[ $task_name ]; } return ''; }, $this->task_names ), 'isComplete' => $this->is_complete(), ); } }