/**
 * Register the metaboxes.
 *
 * The function below registers all the metaboxes used
 * in the ticket edit screen.
 *
 * @since 3.0.0
 */
function wpas_metaboxes()
{
    global $pagenow;
    /* Remove the publishing metabox */
    remove_meta_box('submitdiv', 'ticket', 'side');
    /**
     * Register the metaboxes.
     */
    /* Issue details, only available for existing tickets */
    if (isset($_GET['post'])) {
        add_meta_box('wpas-mb-message', __('Ticket', 'awesome-support'), 'wpas_metabox_callback', 'ticket', 'normal', 'high', array('template' => 'message'));
        $status = get_post_meta(intval($_GET['post']), '_wpas_status', true);
        if ('' !== $status) {
            add_meta_box('wpas-mb-replies', __('Ticket Replies', 'awesome-support'), 'wpas_metabox_callback', 'ticket', 'normal', 'high', array('template' => 'replies'));
        }
    }
    /* Ticket details */
    add_meta_box('wpas-mb-details', __('Ticket Details', 'awesome-support'), 'wpas_metabox_callback', 'ticket', 'side', 'high', array('template' => 'details'));
    /* Client profile */
    if ('post-new.php' !== $pagenow) {
        add_meta_box('wpas-mb-user-profile', __('User Profile', 'awesome-support'), 'wpas_metabox_callback', 'ticket', 'side', 'high', array('template' => 'user-profile'));
    }
    if (WPAS()->custom_fields->have_custom_fields()) {
        add_meta_box('wpas-mb-cf', __('Custom Fields', 'awesome-support'), 'wpas_metabox_callback', 'ticket', 'side', 'default', array('template' => 'custom-fields'));
    }
}
Exemplo n.º 2
0
 public function create_log()
 {
     $content = '';
     if (!empty($this->contents)) {
         /* Get custom fields */
         $fields = WPAS()->custom_fields->get_custom_fields();
         $content .= '<ul class="wpas-log-list">';
         foreach ($this->contents as $key => $update) {
             /* Make sure we have the minimum information required to log the action */
             if (!isset($update['action']) || !isset($update['label']) || !isset($update['field_id'])) {
                 continue;
             }
             /* Verify that the current field is actually registered */
             if (!array_key_exists($update['field_id'], $fields)) {
                 continue;
             }
             /* For custom fields, check if log function is enabled */
             if (false === $fields[$update['field_id']]['args']['log']) {
                 continue;
             }
             $action = $update['action'];
             $label = $update['label'];
             $value = isset($update['value']) ? $update['value'] : '';
             /**
              * Assignee is a specific case. We transform its value from ID to username
              */
             if ('assignee' == $update['field_id']) {
                 $assignee = get_user_by('id', $value);
                 $value = $assignee->display_name;
             }
             $content .= '<li>';
             switch ($action) {
                 case 'updated':
                     $content .= sprintf(_x('updated %s to %s', 'Custom field value was updated', 'awesome-support'), $label, $value);
                     break;
                 case 'deleted':
                     $content .= sprintf(_x('deleted %s', 'Custom field value was deleted', 'awesome-support'), $label);
                     break;
                 case 'added':
                     $content .= sprintf(_x('added %s to %s', 'Custom field value was added', 'awesome-support'), $value, $label);
                     break;
             }
             $content .= "</li>";
         }
         $content .= '</ul>';
     }
     /**
      * In case the $args was not empty but none of the fields were to be logged
      */
     if ('<ul></ul>' == $content) {
         $content = '';
     }
     return $content;
 }
 function setUp()
 {
     parent::setUp();
     /**
      * Add a text field.
      */
     wpas_add_custom_field('my_test_field', array('field_type' => 'text', 'capability' => 'create_ticket', 'sanitize' => 'sanitize_text_field', 'title' => 'Test Field', 'html5_pattern' => ''));
     /**
      * Add a test ticket.
      */
     $this->ticket_id = wpas_insert_ticket(array('post_title' => 'Test Ticket', 'post_name' => 'Test Ticket', 'post_author' => 1, 'post_content' => 'In hac habitasse platea dictumst. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Nullam cursus lacinia erat. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Donec vitae orci sed dolor rutrum auctor.'), false);
     /**
      * Get all the custom fields.
      */
     $this->fields = WPAS()->custom_fields->get_custom_fields();
     /**
      * Instantiate the custom fields objects.
      */
     $this->text_field = new WPAS_Custom_Field('my_test_field', $this->fields['my_test_field']);
 }
Exemplo n.º 4
0
<?php

/**
 * Ticket Status.
 *
 * This metabox is used to display the ticket current status
 * and change it in one click.
 *
 * For more details on how the ticket status is changed,
 *
 * @see   Awesome_Support_Admin::custom_actions()
 *
 * @since 3.0.0
 */
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}
?>

<div class="wpas-custom-fields">
	<?php 
do_action('wpas_mb_details_before_custom_fields');
WPAS()->custom_fields->submission_form_fields();
do_action('wpas_mb_details_after_custom_fields');
?>
</div>
Exemplo n.º 5
0
        private function includes()
        {
        }
        /**
         * Include all files used in admin only
         *
         * @since 3.2.5
         * @return void
         */
        private function includes_admin()
        {
            require WPAS_PATH . 'includes/admin/functions-notices.php';
        }
    }
}
/**
 * The main function responsible for returning the unique Awesome Support instance
 *
 * Use this function like you would a global variable, except without needing
 * to declare the global.
 *
 * @since 3.1.5
 * @return object Awesome_Support
 */
function WPAS()
{
    return Awesome_Support::instance();
}
// Get Awesome Support Running
WPAS();
Exemplo n.º 6
0
/**
 * Save ticket custom fields.
 *
 * This function will save all custom fields associated
 * to the ticket post type. Be it core custom fields
 * or user added custom fields.
 *
 * @param  (int) $post_id Current post ID
 *
 * @since  3.0.0
 */
function wpas_save_ticket($post_id)
{
    /* We should already being avoiding Ajax, but let's make sure */
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || wp_is_post_revision($post_id)) {
        return;
    }
    if (defined('DOING_AJAX') && DOING_AJAX) {
        return;
    }
    /* Now we check the nonce */
    if (!isset($_POST['wpas_cf']) || !wp_verify_nonce($_POST['wpas_cf'], 'wpas_update_cf')) {
        return;
    }
    /* Does the current user has permission? */
    if (!current_user_can('edit_ticket', $post_id)) {
        return;
    }
    global $current_user;
    /**
     * Store possible logs
     */
    $log = array();
    /**
     * If no ticket status is found we are in the situation where
     * the agent is creating a ticket on behalf of the user. There are
     * a couple of things that we need to do then.
     */
    if ('' === ($original_status = get_post_meta($post_id, '_wpas_status', true))) {
        /**
         * First of all, set the ticket as open. This is very important.
         */
        add_post_meta($post_id, '_wpas_status', 'open', true);
        /**
         * Send the confirmation e-mail to the user.
         *
         * @since  3.1.5
         */
        wpas_email_notify($post_id, 'submission_confirmation');
    }
    /* Save the possible ticket reply */
    if (isset($_POST['wpas_reply']) && isset($_POST['wpas_reply_ticket']) && '' !== $_POST['wpas_reply']) {
        /* Check for the nonce */
        if (wp_verify_nonce($_POST['wpas_reply_ticket'], 'reply_ticket')) {
            $user_id = $current_user->ID;
            $content = wp_kses_post($_POST['wpas_reply']);
            $data = apply_filters('wpas_post_reply_admin_args', array('post_content' => $content, 'post_status' => 'read', 'post_type' => 'ticket_reply', 'post_author' => $user_id, 'post_parent' => $post_id, 'ping_status' => 'closed', '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).
             */
            remove_action('save_post_ticket', 'wpas_save_ticket');
            /**
             * Fires right before a ticket reply is submitted
             *
             * @since 3.2.6
             *
             * @param int   $post_id Ticket ID
             * @param array $data    Data to be inserted as the reply
             */
            do_action('wpas_post_reply_admin_before', $post_id, $data);
            /* Insert the reply in DB */
            $reply = wpas_add_reply($data, $post_id);
            /**
             * Fires right after a ticket reply is submitted
             *
             * @since 3.2.6
             *
             * @param int      $post_id Ticket ID
             * @param array    $data    Data to be inserted as the reply
             * @param bool|int Reply    ID on success, false on failure
             */
            do_action('wpas_post_reply_admin_after', $post_id, $data, $reply);
            /* In case the insertion failed... */
            if (is_wp_error($reply)) {
                /* Set the redirection */
                $_SESSION['wpas_redirect'] = add_query_arg(array('wpas-message' => 'wpas_reply_error'), get_permalink($post_id));
            } else {
                /* E-Mail the client */
                new WPAS_Email_Notification($post_id, array('reply_id' => $reply, 'action' => 'reply_agent'));
                /* The agent wants to close the ticket */
                if (isset($_POST['wpas_do']) && 'reply_close' == $_POST['wpas_do']) {
                    /* Confirm the post type and close */
                    if ('ticket' == get_post_type($post_id)) {
                        /**
                         * wpas_ticket_before_close_by_agent hook
                         */
                        do_action('wpas_ticket_before_close_by_agent', $post_id);
                        /* Close */
                        wpas_close_ticket($post_id);
                        /* E-Mail the client */
                        new WPAS_Email_Notification($post_id, array('action' => 'closed'));
                        /**
                         * wpas_ticket_closed_by_agent hook
                         */
                        do_action('wpas_ticket_closed_by_agent', $post_id);
                    }
                }
            }
        }
    }
    /* Now we can save the custom fields */
    WPAS()->custom_fields->save_custom_fields($post_id, $_POST);
    /* Log the action */
    if (!empty($log)) {
        wpas_log($post_id, $log);
    }
    /* If this was a ticket update, we need to know where to go now... */
    if ('' !== $original_status) {
        /* Go back to the tickets list */
        if (isset($_POST['wpas_back_to_list']) && true === boolval($_POST['wpas_back_to_list']) || isset($_POST['where_after']) && 'back_to_list' === $_POST['where_after']) {
            $_SESSION['wpas_redirect'] = add_query_arg(array('post_type' => 'ticket'), admin_url('edit.php'));
        }
    }
}
/**
 * Add a new custom taxonomy.
 *
 * @since  3.0.0
 *
 * @param  string $name The ID of the custom field to add
 * @param  array  $args Additional arguments for the custom field
 *
 * @return boolean        Returns true on success or false on failure
 */
function wpas_add_custom_taxonomy($name, $args = array())
{
    /* Force the custom fields type to be a taxonomy. */
    $args['field_type'] = 'taxonomy';
    $args['column_callback'] = 'wpas_show_taxonomy_column';
    /* Add the taxonomy. */
    WPAS()->custom_fields->add_field($name, $args);
    return true;
}
/**
 * Get tickets list columns.
 *
 * Retrieve the columns to display on the list of tickets
 * in the client area. The columns include the 3 basic ones
 * (status, title and date), and also the custom fields that are
 * set to show on front-end (and that are not core CF).
 *
 * @since  3.0.0
 * @return array The list of columns with their title and callback
 */
function wpas_get_tickets_list_columns()
{
    $custom_fields = WPAS()->custom_fields->get_custom_fields();
    $columns = array('status' => array('title' => __('Status', 'awesome-support'), 'callback' => 'wpas_cf_display_status', 'column_attributes' => array('head' => array('sort-ignore' => true))), 'title' => array('title' => __('Title', 'awesome-support'), 'callback' => 'title'), 'date' => array('title' => __('Date', 'awesome-support'), 'callback' => 'date', 'column_attributes' => array('head' => array('type' => 'numeric', 'sort-initial' => 'descending'), 'body' => array('value' => 'wpas_get_the_time_timestamp'))));
    foreach ($custom_fields as $field) {
        /* Don't display core fields */
        if (true === $field['args']['core']) {
            continue;
        }
        /* Don't display fields that aren't specifically designed to */
        if (true === $field['args']['show_column']) {
            $column_title = apply_filters('wpas_custom_column_title', wpas_get_field_title($field), $field);
            $column_callback = 'taxonomy' === $field['args']['field_type'] && true === $field['args']['taxo_std'] ? 'taxonomy' : $field['args']['column_callback'];
            $columns[$field['name']] = array('title' => $column_title, 'callback' => $column_callback);
            if (!empty($field['args']['column_attributes']) && is_array($field['args']['column_attributes'])) {
                $columns[$field['name']] = $field['args']['column_attributes'];
            }
        }
    }
    return apply_filters('wpas_tickets_list_columns', $columns);
}
/**
 * Clean all notifications from session
 *
 * @since 3.2
 *
 * @param string $group Group of notifications to remove
 *
 * @return void
 */
function wpas_clean_notifications($group = 'notifications')
{
    WPAS()->session->clean($group);
}
 /**
  * Actions run on plugin initialization.
  *
  * A certain number of things can possibly run after
  * the plugin initialized. Those actions are fired from here
  * if the trigger is present.
  *
  * @since  3.0.0
  * @return void
  */
 public function init()
 {
     /**
      * Log user in.
      *
      * If we have a login in the post data we try to log the user in.
      * The login process relies on the WordPress core functions. If the login
      * is successful, the user is redirected to the page he was requesting,
      * otherwise the standard WordPress error messages are returned.
      *
      * @since 3.0.0
      */
     if (isset($_POST['wpas_login'])) {
         add_action('wp', 'wpas_try_login');
     }
     /**
      * Register a new account.
      *
      * If wpas_registration is passed we trigger the account registration function.
      * The registration function will do a certain number of checks and if all of them
      * are successful, a new user is created using the WordPress core functions.
      *
      * The reason why we are not using a simpler process is to keep full control over
      * what's returned to the user and where the user is returned.
      *
      * @since 3.0.0
      */
     if (isset($_POST['wpas_registration'])) {
         add_action('wp', 'wpas_register_account', 10, 0);
     }
     /**
      * Run custom actions.
      *
      * The plugin can run a number of custom actions triggered by a URL parameter.
      * If the $action parameter is set in the URL we run this method.
      *
      * @since  3.0.0
      */
     if (isset($_GET['action'])) {
         add_action('wp', array($this, 'custom_actions'));
     }
     /**
      * Open a new ticket.
      *
      * If a ticket title is passed in the post we trigger the function that adds
      * new tickets. The function does a certain number of checks and has several
      * action hooks and filters. Post-insertion actions like adding post metas
      * and redirecting the user are run from here.
      *
      * @since  3.0.0
      */
     if (!is_admin() && isset($_POST['wpas_title'])) {
         // Verify the nonce first
         if (!isset($_POST['wpas_nonce']) || !wp_verify_nonce($_POST['wpas_nonce'], 'new_ticket')) {
             /* Save the input */
             wpas_save_values();
             // Redirect to submit page
             wpas_add_error('nonce_verification_failed', __('The authenticity of your submission could not be validated. If this ticket is legitimate please try submitting again.', 'awesome-support'));
             wp_redirect(wp_sanitize_redirect(home_url($_POST['_wp_http_referer'])));
             exit;
         }
         $ticket_id = wpas_open_ticket(array('title' => $_POST['wpas_title'], 'message' => $_POST['wpas_message']));
         /* Submission failure */
         if (false === $ticket_id) {
             /* Save the input */
             wpas_save_values();
             /**
              * Redirect to the newly created ticket
              */
             wpas_add_error('submission_error', __('The ticket couldn\'t be submitted for an unknown reason.', 'awesome-support'));
             wp_redirect(wp_sanitize_redirect(home_url($_POST['_wp_http_referer'])));
             exit;
         } else {
             /**
              * Empty the temporary sessions
              */
             WPAS()->session->clean('submission_form');
             /**
              * Redirect to the newly created ticket
              */
             wpas_redirect('ticket_added', get_permalink($ticket_id), $ticket_id);
             exit;
         }
     }
     /**
      * Save a new reply.
      *
      * This adds a new reply to an existing ticket. The ticket
      * can possibly be closed by the user in which case we update
      * the post meta if the reply submission is successful.
      *
      * @since 3.0.0
      */
     if (isset($_POST['wpas_user_reply'])) {
         // Get parent ticket ID
         $parent_id = filter_input(INPUT_POST, 'ticket_id', FILTER_SANITIZE_NUMBER_INT);
         if ('ticket' !== get_post_type($parent_id)) {
             wpas_add_error('reply_added_failed', __('Something went wrong. We couldn&#039;t identify your ticket. Please try again.', 'awesome-support'));
             wpas_redirect('reply_added_failed', get_permalink($parent_id));
             exit;
         }
         // Define if the ticket must be closed
         $close = isset($_POST['wpas_close_ticket']) ? true : false;
         if (!empty($_POST['wpas_user_reply'])) {
             /* Sanitize the data */
             $data = array('post_content' => wp_kses($_POST['wpas_user_reply'], wp_kses_allowed_html('post')));
             /* Add the reply */
             $reply_id = wpas_add_reply($data, $parent_id);
         }
         /* Possibly close the ticket */
         if ($close) {
             wpas_close_ticket($parent_id);
             // Redirect now if no reply was posted
             if (!isset($reply_id)) {
                 wpas_add_notification('ticket_closed', __('The ticket was successfully closed', 'awesome-support'));
                 wpas_redirect('ticket_closed', get_permalink($parent_id));
                 exit;
             }
         }
         if (isset($reply_id)) {
             if (false === $reply_id) {
                 wpas_add_error('reply_added_failed', __('Your reply could not be submitted for an unknown reason.', 'awesome-support'));
                 wpas_redirect('reply_added_failed', get_permalink($parent_id));
                 exit;
             } else {
                 if ($close) {
                     wpas_add_notification('reply_added_closed', __('Thanks for your reply. The ticket is now closed.', 'awesome-support'));
                 } else {
                     wpas_add_notification('reply_added', __('Your reply has been submitted. Your agent will reply ASAP.', 'awesome-support'));
                 }
                 if (false !== ($link = wpas_get_reply_link($reply_id))) {
                     wpas_redirect('reply_added', $link);
                     exit;
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 /**
  * This is used to pre-populate a field.
  *
  * The method checks for URL vars and values
  * possibly saved in session.
  *
  * @since 3.2.0
  * @return mixed Field value
  */
 public function populate()
 {
     $value = $this->get_field_value();
     if (empty($value)) {
         if (isset($_GET[$this->get_field_id()])) {
             $value = is_array($_GET[$this->get_field_id()]) ? filter_input(INPUT_GET, $this->get_field_id(), FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY) : filter_input(INPUT_GET, $this->get_field_id(), FILTER_SANITIZE_STRING);
         }
         $fields = WPAS()->session->get('submission_form');
         if (isset($fields) && is_array($fields) && array_key_exists($this->get_field_id(), $fields)) {
             $value = $this->get_sanitized_value($fields[$this->get_field_id()]);
         }
         if (!empty($this->field_args['default'])) {
             $value = $this->get_sanitized_value($this->field_args['default']);
         }
     }
     return $value;
 }
Exemplo n.º 12
0
echo true === boolval(wpas_get_option('enable_closed')) ? '<span class="wpas-alert-success">Enabled</span>' : '<span class="wpas-alert-danger">Disabled</span>';
?>
			</td>
		</tr>
	</tbody>
</table>
<table class="widefat wpas-system-status-table" id="wpas-system-status-custom-fields">
	<thead>
		<tr>
			<th data-override="key" class="row-title">Custom Fields</th>
			<th data-override="value"></th>
		</tr>
	</thead>
	<tbody>
		<?php 
$fields = WPAS()->custom_fields->get_custom_fields();
if (empty($fields)) {
    ?>
			<td colspan="2">None</td>	
		<?php 
} else {
    $cf_tr_class = 'alt';
    foreach ($fields as $field_id => $field) {
        $cf_tr_class = 'alt' === $cf_tr_class ? '' : 'alt';
        $values = array();
        $attributes = array(__('Capability', 'awesome-support') => '<code>' . $field['args']['capability'] . '</code>');
        $attributes[__('Core', 'wpas')] = true === boolval($field['args']['core']) ? __('Yes', 'awesome-support') : __('No', 'awesome-support');
        $attributes[__('Required', 'wpas')] = true === boolval($field['args']['required']) ? __('Yes', 'awesome-support') : __('No', 'awesome-support');
        $attributes[__('Logged', 'wpas')] = true === boolval($field['args']['log']) ? __('Yes', 'awesome-support') : __('No', 'awesome-support');
        $attributes[__('Show Column', 'wpas')] = true === boolval($field['args']['show_column']) ? __('Yes', 'awesome-support') : __('No', 'awesome-support');
        if ('taxonomy' === $field['args']['field_type']) {
Exemplo n.º 13
0
 /**
  * Maybe initiate the product sync class
  *
  * @since 3.3
  * @return bool
  */
 public function init_sync()
 {
     if (is_null($this->plugin) || !isset($this->plugins[$this->plugin]) || false === $this->synced) {
         return false;
     }
     $plugin = wp_parse_args($this->plugins[$this->plugin], $this->integration_defaults());
     // Instantiate the product sync class
     WPAS()->products_sync = new WPAS_Product_Sync($plugin['post_type'], $plugin['taxonomy'], $plugin['append']);
     return true;
 }
/**
 * Add free addon notice
 *
 * After the plugin has been activated, we display a notice to admins telling them that they can get a free addon for
 * Awesome Support.
 *
 * @since 3.3.3
 * @return void
 */
function wpas_free_addon_notice()
{
    // Only show this message to admins
    if (!current_user_can('administrator')) {
        return;
    }
    // Don't show the notice if user already claimed the addon
    if (wpas_is_free_addon_page_dismissed()) {
        return;
    }
    // Only show the notice on the plugin pages
    if (!wpas_is_plugin_page()) {
        return;
    }
    // No need to show the notice on the free addon page itself
    if (isset($_GET['page']) && 'wpas-optin' === $_GET['page']) {
        return;
    }
    WPAS()->admin_notices->add_notice('updated', 'wpas_get_free_addon', wp_kses(sprintf(__('Hey! Did you know you can get a <strong>free add-on for unlimited sites</strong> (a $61.00 USD value) for Awesome Support? <a href="%1$s">Click here to read more</a>.', 'awesome-support'), add_query_arg(array('post_type' => 'ticket', 'page' => 'wpas-optin'), admin_url('edit.php'))), array('strong' => array(), 'a' => array('href' => array()))));
}
/**
 * Save form values.
 *
 * If the submission fails we save the form values in order to
 * pre-populate the form on page reload. This will avoid asking the user
 * to fill all the fields again.
 *
 * @since  3.0.0
 * @return void
 */
function wpas_save_values()
{
    $fields = array();
    foreach ($_POST as $key => $value) {
        if (!empty($value)) {
            $fields[$key] = $value;
        }
    }
    WPAS()->session->add('submission_form', $fields);
}
Exemplo n.º 16
0
/**
 * Get the link to a ticket reply
 *
 * @since 3.2
 *
 * @param int $reply_id ID of the reply to get the link to
 *
 * @return string|bool Reply link or false if the reply doesn't exist
 */
function wpas_get_reply_link($reply_id)
{
    $reply = get_post($reply_id);
    if (empty($reply)) {
        return false;
    }
    if ('ticket_reply' !== $reply->post_type || 0 === (int) $reply->post_parent) {
        return false;
    }
    $replies = wpas_get_replies($reply->post_parent, array('read', 'unread'));
    if (empty($replies)) {
        return false;
    }
    $position = 0;
    foreach ($replies as $key => $post) {
        if ($reply_id === $post->ID) {
            $position = $key + 1;
        }
    }
    // We have more replies that what's displayed on one page, so let's set a session var to force displaying all replies
    if ($position > wpas_get_option('replies_per_page', 10)) {
        WPAS()->session->add('force_all_replies', true);
    }
    $link = get_permalink($reply->post_parent) . "#reply-{$reply_id}";
    return esc_url($link);
}
Exemplo n.º 17
0
/**
 * Clear all custom taxonomies terms.
 *
 * @since  3.0.0
 * @return boolean True if terms were deleted, false otherwise
 */
function wpas_clear_taxonomies()
{
    $taxonomies = (array) WPAS()->custom_fields->get_custom_fields();
    $deleted = false;
    if (empty($taxonomies)) {
        return false;
    }
    foreach ($taxonomies as $taxonomy) {
        if ('taxonomy' !== $taxonomy['args']['callback']) {
            continue;
        }
        if (wpas_clear_taxonomy($taxonomy['name']) && false === $deleted) {
            $deleted = true;
        }
    }
    return $deleted;
}
Exemplo n.º 18
0
 */
do_action('wpas_frontend_ticket_content_after', $post->ID, $post);
?>

				</td>

			</tr>

			<?php 
// Set the number of replies
$replies_per_page = wpas_get_option('replies_per_page', 10);
$force_all_replies = WPAS()->session->get('force_all_replies');
// Check if we need to force displaying all the replies (direct link to a specific reply for instance)
if (true === $force_all_replies) {
    $replies_per_page = -1;
    WPAS()->session->clean('force_all_replies');
    // Clean the session
}
$args = array('posts_per_page' => $replies_per_page, 'no_found_rows' => false);
$replies = wpas_get_replies($post->ID, array('read', 'unread'), $args, 'wp_query');
if ($replies->have_posts()) {
    while ($replies->have_posts()) {
        $replies->the_post();
        $user = get_userdata($post->post_author);
        $user_role = get_the_author_meta('roles');
        $user_role = $user_role[0];
        $time_ago = human_time_diff(get_the_time('U', $post->ID), current_time('timestamp'));
        wpas_get_template('partials/ticket-reply', array('time_ago' => $time_ago, 'user' => $user, 'post' => $post));
    }
}
wp_reset_query();
Exemplo n.º 19
0
function wpas_get_registered_addons()
{
    return WPAS()->addons;
}