/** * Return an instance of this class. * * @since 1.0.0 * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
public function log() { /** * Get user info */ global $current_user; $user_id = $current_user->ID; if (is_array($this->contents)) { /** * If the content is an array we need to build a complex * content based on custom fields. */ $content = $this->create_log(); } else { $content = wp_kses($this->contents, wp_kses_allowed_html('post')); } if ('' === $content) { return false; } $post = array('post_content' => $content, 'post_status' => 'publish', 'post_type' => 'ticket_history', 'post_author' => $user_id, 'ping_status' => 'closed', 'post_parent' => $this->post_id, 'comment_status' => 'closed'); /** * Remove the save_post hook now as we're going to trigger * a new one by inserting the reply (and logging the history later). */ if (is_admin()) { $admin = Awesome_Support_Admin::get_instance(); remove_action('save_post', array($admin, 'save_ticket')); } $log = wp_insert_post($post, true); return $log; }