/**
 * Get the URL to re-open a ticket.
 *
 * @since  3.0.0
 *
 * @param  integer $ticket_id ID of the ticket to re-open
 *
 * @return string             The URL to trigger re-opening the ticket
 */
function wpas_get_reopen_url($ticket_id = null)
{
    global $wp_query;
    if (is_null($ticket_id)) {
        $ticket_id = intval($wp_query->post->ID);
    }
    $url = wpas_do_url(get_permalink($ticket_id), 'reopen_ticket', array('ticket_id' => $ticket_id));
    return apply_filters('wpas_reopen_url', esc_url($url), $ticket_id);
}
Пример #2
0
/**
 * Get link to close a ticket
 *
 * @param int $ticket_id
 *
 * @return string
 */
function wpas_get_close_ticket_url($ticket_id)
{
    $url = add_query_arg('post_type', 'ticket', admin_url('edit.php'));
    return wpas_do_url($url, 'admin_close_ticket', array('post' => $ticket_id));
}
Пример #3
0
 /**
  * Display all the custom notices
  *
  * @since 3.1.5
  * @return void
  */
 public function display_notices()
 {
     $notices = $this->get_notices();
     if (empty($notices) || is_null($notices)) {
         return;
     }
     foreach ($notices as $notice_id => $notice) {
         if (wpas_is_notice_dismissed($notice_id)) {
             continue;
         }
         $url = wpas_do_url(add_query_arg($_GET, ''), 'dismiss_notice', array('notice_id' => $notice_id));
         printf('<div class="%s"><p>%s <a href="%s"><small>(%s)</small></a></p></div>', $notice[0], $notice[1], esc_url($url), _x('Dismiss', 'Dismiss link for admin notices', 'awesome-support'));
     }
 }
Пример #4
0
/**
 * Multiple products support.
 *
 * Ask the user to choose if the support site will manage
 * multiple products or not.
 *
 * @since  3.0.0
 * @return void
 */
function wpas_ask_support_products()
{
    global $pagenow;
    $args_single = $args_multiple = $_GET;
    if (!isset($get) || !is_array($get)) {
        $get = array();
    }
    $args_single['products'] = 'single';
    $args_multiple['products'] = 'multiple';
    ?>
	<div class="updated">
		<p><?php 
    _e('Will you be supporting multiple products on this support site? You can activate multi-products support now. <small>(This setting can be modified later)</small>', 'awesome-support');
    ?>
</p>

		<p>
			<a href="<?php 
    echo wp_sanitize_redirect(wpas_do_url(admin_url($pagenow), 'admin_products_option', $args_single));
    ?>
"
			   class="button-secondary"><?php 
    _e('Single Product', 'awesome-support');
    ?>
</a>
			<a href="<?php 
    echo wp_sanitize_redirect(wpas_do_url(admin_url($pagenow), 'admin_products_option', $args_multiple));
    ?>
"
			   class="button-secondary"><?php 
    _e('Multiple Products', 'awesome-support');
    ?>
</a>
		</p>
	</div>
<?php 
}
Пример #5
0
 */
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}
global $pagenow, $post;
/* Current status */
$ticket_status = get_post_meta(get_the_ID(), '_wpas_status', true);
/** 
 * Status action link
 * 
 * @var string
 * @see admin/class-awesome-support-admin.php
 */
$base_url = add_query_arg(array('action' => 'edit', 'post' => $post->ID), admin_url('post.php'));
$action = in_array($ticket_status, array('closed', '')) ? wpas_do_url($base_url, 'admin_open_ticket') : wpas_do_url($base_url, 'admin_close_ticket');
/**
 * Get available statuses.
 */
$statuses = wpas_get_post_status();
/* Get post status */
$post_status = isset($post) ? $post->post_status : '';
/* Get the date */
$date_format = get_option('date_format') . ' ' . get_option('time_format');
$date = get_the_date($date_format);
/* Get time */
if (isset($post)) {
    $dateago = human_time_diff(get_the_time('U', $post->ID), current_time('timestamp'));
}
?>
<div class="wpas-ticket-status submitbox">
/**
 * Add ticket reply controls
 *
 * @since 3.2.6
 *
 * @param array   $controls  List of existing controls
 * @param int     $ticket_id ID of the ticket current reply belongs to
 * @param WP_Post $reply     Reply post object
 *
 * @return array
 */
function wpas_ticket_reply_controls($controls, $ticket_id, $reply)
{
    if (0 !== $ticket_id && get_current_user_id() == $reply->post_author) {
        $_GET['del_id'] = $reply->ID;
        $url = add_query_arg($_GET, admin_url('post.php'));
        $url = remove_query_arg('message', $url);
        $delete = wpas_do_url(admin_url('post.php'), 'admin_trash_reply', array('post' => $ticket_id, 'action' => 'edit', 'reply_id' => $reply->ID));
        $edit = wp_nonce_url(add_query_arg(array('post' => $ticket_id, 'rid' => $reply->ID, 'action' => 'edit_reply'), admin_url('post.php')), 'delete_reply_' . $reply->ID);
        $controls['delete_reply'] = sprintf('<a class="%1$s" href="%2$s" title="%3$s">%3$s</a>', 'wpas-delete', esc_url($delete), esc_html_x('Delete', 'Link to delete a ticket reply', 'awesome-support'));
        $controls['edit_reply'] = sprintf('<a class="%1$s" href="%2$s" data-origin="%3$s" data-replyid="%4$d" data-reply="%5$s" data-wysiwygid="%6$s" title="%7$s">%7$s</a>', 'wpas-edit', '#', "#wpas-reply-{$reply->ID}", $reply->ID, "wpas-editwrap-{$reply->ID}", "wpas-editreply-{$reply->ID}", esc_html_x('Edit', 'Link ot edit a ticket reply', 'awesome-support'));
    }
    if (get_current_user_id() !== $reply->post_author && 'unread' === $reply->post_status) {
        $controls['mark_read'] = sprintf('<a class="%1$s" href="%2$s" data-replyid="%3$d" title="%4$s">%4$s</a>', 'wpas-mark-read', '#', $reply->ID, esc_html_x('Mark as Read', 'Mark a user reply as read', 'awesome-support'));
    }
    return $controls;
}
/**
 * Add custom action and nonce to URL.
 *
 * The function adds a custom action trigger using the wpas-do
 * URL parameter and adds a security nonce for plugin custom actions.
 *
 * @param  string $url    URL to customize
 * @param  string $action Custom action to add
 *
 * @return string         Customized URL
 * @since      3.0.0
 * @deprecated 3.3
 */
function wpas_url_add_custom_action($url, $action)
{
    _deprecated_function('wpas_url_add_custom_action', '3.3', 'wpas_do_url');
    return wpas_do_url($url, sanitize_text_field($action));
}