_audit = $audit; return $this; } public function setPost($post) { $this->_post = $post; return $this; } /** * Get all the focus pages data */ public function init() { //get data from DB with the completed tasks $this->_dbtasks = json_decode(get_option(SQ_TASKS), true); //Add filters for tasks, color and value add_filter('sq_assistant_tasks', array($this, 'parseTasks')); //parse the category add_filter('sq_assistant_categories', array($this, 'parseCategory')); } /** * Set all Tasks from all Assistant Classes * Extend and add the current assistant tasks * @param $tasks * @return mixed */ public function setTasks($tasks) { return $this->_tasks = $tasks; } /** * Get all tasks * @return mixed */ public function getTasks() { return $this->_tasks; } /** * Get all saved statuses from database * @return array */ public function getDbTasks() { return $this->_dbtasks; } /** * Get the task value if exists * Set false by default * @return bool */ public function getValue() { return false; } /** * If data integrity is affected, return error * @return bool */ public function isError() { return $this->_error; } /** * Get the task color * @param $complete * @return string */ public function getColor($complete) { if ($this->_error) { return self::TASK_ERROR; } elseif (!$complete) { return self::TASK_INCOMPLETE; } elseif ($this->_pattern) { return self::TASK_PATTERN; } elseif ($complete) { return self::TASK_COMPLETE; } return self::TASK_INCOMPLETE; } public function getTitle($title) { if ($this->_error) { $title = __("We are gathering data for this category", _SQ_PLUGIN_NAME_); } return $title; } /** * Parse tasks for each category * @param $tasks * @param $category * @return mixed */ public function parseTasks($tasks, $category = null) { if (!isset($category)) { $category = $this->_category; } //$this->_error = false; $this->setTasks($tasks); if (isset($this->_tasks[$category])) { foreach ($this->_tasks[$category] as $name => &$task) { $task['completed'] = true; $task['pattern'] = $task['error'] = $task['error_message'] = false; //Set task status from DB or active $task['active'] = true; if (isset($this->_dbtasks[$category][$name]['active'])) { $task['active'] = $this->_dbtasks[$category][$name]['active']; } /// //set the current task if ($task['active']) { if (method_exists($this, 'check' . ucfirst($name))) { $task = @call_user_func_array(array($this, 'check' . ucfirst($name)), array($task)); //Check if the task has errors if ($task['error']) { $task['completed'] = false; $task['error_message'] = (isset($task['error_message']) && $task['error_message'] <> '' ? $task['error_message'] : __("Not enough data to process this task", _SQ_PLUGIN_NAME_)); } else { //If the task has value if (isset($task['value'])) { $task['description'] = '