Ejemplo n.º 1
0
 /**
  * get the instance of this class
  * @return	object	the instance
  */
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 2
0
 static function ajax_save()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || !is_user_logged_in()) {
         wp_send_json_error();
     }
     do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug));
     $_POST['task']['modified_dt_gmt'] = Kanban_Utils::mysql_now_gmt();
     if (!isset($_POST['task']['user_id_author'])) {
         $_POST['task']['user_id_author'] = get_current_user_id();
     }
     $is_successful = self::_replace($_POST['task']);
     $task_id = isset($_POST['task']['id']) ? $_POST['task']['id'] : self::_insert_id();
     $post_data = self::get_row('id', $task_id);
     if (!$post_data) {
         wp_send_json_error();
     }
     do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug));
     if (!empty($_POST['comment'])) {
         do_action(sprintf('%s_before_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug));
         Kanban_Comment::add($_POST['comment'], 'system', $task_id);
         do_action(sprintf('%s_after_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug));
     }
     if (isset($_POST['status_id_old'])) {
         do_action(sprintf('%s_before_%s_ajax_status_change_save', Kanban::get_instance()->settings->basename, self::$slug));
         Kanban_Status_Change::add($task_id, $post_data->status_id, $_POST['status_id_old']);
         do_action(sprintf('%s_after_%s_ajax_status_change_save', Kanban::get_instance()->settings->basename, self::$slug));
     }
     if ($is_successful) {
         wp_send_json_success(array('message' => sprintf('%s saved', self::$slug), self::$slug => $post_data));
     } else {
         wp_send_json_error(array('message' => sprintf('Error saving %s', self::$slug)));
     }
 }