Exemplo n.º 1
0
/**
 * Admin Messages
 *
 * @since	0.1
 * @global	$kbs_options Array of all the KBS Options
 * @return	void
 */
function kbs_admin_messages()
{
    global $kbs_options;
    if (isset($_GET['kbs-message']) && 'nonce_fail' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-nonce-fail', __('Security verification failed.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message']) && 'ticket_reopened' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-ticket-reopened', sprintf(__('%s reopened.', 'kb-support'), kbs_get_ticket_label_singular()), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'ticket_not_closed' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-ticket-not-closed', sprintf(__('The %s cannot be re-opened. It is not closed.', 'kb-support'), kbs_get_ticket_label_singular()), 'error');
    }
    if (isset($_GET['kbs-message']) && 'ticket_reply_added' == $_GET['kbs-message']) {
        $closed = '';
        if (isset($_GET['post']) && 'kbs_ticket' == get_post_type($_GET['post']) && 'closed' == get_post_status($_GET['post'])) {
            $closed = sprintf(__(' and the %1$s was closed', 'kb-support'), kbs_get_ticket_label_singular());
        }
        add_settings_error('kbs-notices', 'kbs-ticket-reply-added', sprintf(__('The reply was successfully added%s.', 'kb-support'), $closed), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'ticket_reply_failed' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-ticket-reply-failed', __('The reply could not be added.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message']) && 'note_deleted' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-ticket-note-deleted', __('The note was deleted.', 'kb-support'), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'note_not_deleted' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-ticket-note-not-deleted', __('The note could not be deleted.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message']) && 'field_added' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-added', __('Field was added.', 'kb-support'), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'field_add_fail' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-notadded', __('Field added.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message']) && 'field_saved' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-saved', __('Field updated.', 'kb-support'), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'field_save_fail' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-notsaved', __('Field not saved.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message']) && 'field_deleted' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-delete', __('Field deleted.', 'kb-support'), 'updated');
    }
    if (isset($_GET['kbs-message']) && 'field_delete_fail' == $_GET['kbs-message']) {
        add_settings_error('kbs-notices', 'kbs-field-notdeleted', __('Field not deleted.', 'kb-support'), 'error');
    }
    if (isset($_GET['kbs-message'], $_GET['field_id']) && 'editing_field' == $_GET['kbs-message']) {
        echo '<div class="notice notice-info">';
        echo '<p><strong>' . sprintf(__('Editing: %s.', 'kb-support'), get_the_title($_GET['field_id'])) . '</strong></p>';
        echo '</div>';
    }
    settings_errors('kbs-notices');
}
Exemplo n.º 2
0
/**
 * Get the settings sections for each tab
 * Uses a static to avoid running the filters on every request to this function
 *
 * @since	1.0
 * @return	arr		Array of tabs and sections
 */
function kbs_get_registered_settings_sections()
{
    static $sections = false;
    if (false !== $sections) {
        return $sections;
    }
    $sections = array('general' => apply_filters('kbs_settings_sections_general', array('main' => __('General Settings', 'kb-support'), 'pages' => __('Pages', 'kb-support'))), 'tickets' => apply_filters('kbs_settings_sections_tickets', array('main' => sprintf(__('General %s Settings', 'kb-support'), kbs_get_ticket_label_singular()), 'submit' => __('Submission Settings', 'kb-support'), 'sla' => __('Service Levels', 'kb-support'))), 'kb_articles' => apply_filters('kbs_settings_sections_kb_articles', array('main' => sprintf(__('General %s Settings', 'kb-support'), kbs_get_kb_label_singular()))), 'emails' => apply_filters('kbs_settings_sections_emails', array('main' => __('Emails', 'kb-support'), 'ticket_received' => sprintf(__('%s Received', 'kb-support'), kbs_get_ticket_label_singular()), 'ticket_notifications' => sprintf(__('%s Notifications', 'kb-support'), kbs_get_ticket_label_singular()))), 'styles' => apply_filters('kbs_settings_sections_styles', array('main' => __('Styles', 'kb-support'))), 'extensions' => apply_filters('kbs_settings_sections_extensions', array('main' => __('Main', 'kb-support'))), 'licenses' => apply_filters('kbs_settings_sections_licenses', array()), 'misc' => apply_filters('kbs_settings_sections_misc', array('main' => __('Misc Settings', 'kb-support'), 'recaptcha' => __('Google reCaptcha', 'kb-support'), 'site_terms' => __('Terms and Conditions', 'kb-support'))));
    $sections = apply_filters('kbs_settings_sections', $sections);
    return $sections;
}
Exemplo n.º 3
0
/**
 * Display the ticket reply row.
 *
 * @since	1.0
 * @global	obj		$kbs_ticket			KBS_Ticket class object
 * @global	bool	$kbs_ticket_update	True if this ticket is being updated, false if new.
 * @param	int		$ticket_id			The ticket post ID.
 * @return	str
 */
function kbs_ticket_metabox_reply_row($ticket_id)
{
    global $kbs_ticket, $kbs_ticket_update;
    if ('closed' == $kbs_ticket->post_status) {
        printf(__('This %1$s is currently closed. <a href="%2$s">Re-open %1$s.</a>', 'kb-support'), kbs_get_ticket_label_singular(), wp_nonce_url(add_query_arg('kbs-action', 're-open-ticket', get_edit_post_link($ticket_id)), 'kbs-reopen-ticket', 'kbs-ticket-nonce'));
    } else {
        $settings = apply_filters('kbs_ticket_reply_mce_settings', array('textarea_rows' => 5, 'drag_drop_upload' => true, 'quicktags' => false));
        ?>

		<div id="kbs-ticket-reply-wrap">
        	<p><label for="kbs_ticket_reply"><strong><?php 
        _e('Add a New Reply', 'kb-support');
        ?>
</strong></label><br />
				<?php 
        wp_editor('', 'kbs_ticket_reply', $settings);
        ?>
            </p>
        </div>

		<?php 
        /*
         * Fires immediately before the reply buttons are output
         * @since	1.0
         * @param	int	$post_id	The Ticket post ID
         */
        do_action('kbs_ticket_before_reply_buttons', $ticket_id);
        ?>
        <div id="kbs-ticket-reply-container">
            <div class="kbs-reply"><a id="kbs-reply-update" class="button button-primary"><?php 
        _e('Reply', 'kb-support');
        ?>
</a></div>
            <div class="kbs-reply"><a id="kbs-reply-close" class="button button-secondary"><?php 
        _e('Reply and Close', 'kb-support');
        ?>
</a></div>
        </div>
        <div id="kbs-new-reply-loader"></div>
        <?php 
    }
}
Exemplo n.º 4
0
/**
 * Front end notices.
 *
 * @since	1.0
 * @param	str		$notice		The message key to display.
 * @return	str		Notice.
 */
function kbs_get_notices($notice = false)
{
    $notices = array('need_login' => array('class' => 'info', 'notice' => sprintf(__('You must be logged in to create a support %s', 'kb-support'), kbs_get_ticket_label_singular())), 'ticket_submitted' => array('class' => 'success', 'notice' => __("Your support request has been successfully received. We'll be in touch as soon as possible.", 'kb-support')), 'ticket_failed' => array('class' => 'error', 'notice' => __('There was an error submitting your support request. Please try again', 'kb-support')));
    $notices = apply_filters('kbs_get_notices', $notices);
    if ($notice) {
        if (!array_key_exists($notice, $notices)) {
            return false;
        }
        return $notices[$notice];
    }
    return $notices;
}
Exemplo n.º 5
0
/**
 * Get ticket notification email text
 *
 * Returns the stored email text if available, the standard email text if not
 *
 * @since	1.0
 * @param
 * @return	str		$message
 */
function kbs_get_default_sale_notification_email()
{
    $default_email_body = __('Hello', 'kb-support') . "\n\n" . sprintf(__('A %s has been logged', 'kb-support'), kbs_get_ticket_label_singular()) . ".\n\n";
    $default_email_body .= '{ticket_details}' . "\n\n";
    $default_email_body .= __('Thank you', 'kb-support');
    $message = kbs_get_option('ticket_notification', false);
    $message = !empty($message) ? $message : $default_email_body;
    return $message;
}
Exemplo n.º 6
0
/**
 * Updated bulk messages
 *
 * @since	0.1
 * @param	arr		$bulk_messages	Post updated messages
 * @param	arr		$bulk_counts	Post counts
 * @return	arr		$bulk_messages	New post updated messages
 */
function kbs_bulk_updated_messages($bulk_messages, $bulk_counts)
{
    $ticket_singular = kbs_get_ticket_label_singular();
    $ticket_plural = kbs_get_ticket_label_plural();
    $article_singular = kbs_get_kb_label_singular();
    $article_plural = kbs_get_kb_label_plural();
    $bulk_messages['kbs_ticket'] = array('updated' => sprintf(_n('%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'kb-support'), $bulk_counts['updated'], $ticket_singular, $ticket_plural), 'locked' => sprintf(_n('%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'kb-support'), $bulk_counts['locked'], $ticket_singular, $ticket_plural), 'deleted' => sprintf(_n('%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'kb-support'), $bulk_counts['deleted'], $ticket_singular, $ticket_plural), 'trashed' => sprintf(_n('%1$s %2$s moved to the Trash.', '%1$s %3$s moved to the Trash.', $bulk_counts['trashed'], 'kb-support'), $bulk_counts['trashed'], $ticket_singular, $ticket_plural), 'untrashed' => sprintf(_n('%1$s %2$s restored from the Trash.', '%1$s %3$s restored from the Trash.', $bulk_counts['untrashed'], 'kb-support'), $bulk_counts['untrashed'], $ticket_singular, $ticket_plural));
    $bulk_messages['kbs_kb'] = array('updated' => sprintf(_n('%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'kb-support'), $bulk_counts['updated'], $article_singular, $article_plural), 'locked' => sprintf(_n('%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'kb-support'), $bulk_counts['locked'], $article_singular, $article_plural), 'deleted' => sprintf(_n('%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'kb-support'), $bulk_counts['deleted'], $article_singular, $article_plural), 'trashed' => sprintf(_n('%1$s %2$s moved to the Trash.', '%1$s %3$s moved to the Trash.', $bulk_counts['trashed'], 'kb-support'), $bulk_counts['trashed'], $article_singular, $article_plural), 'untrashed' => sprintf(_n('%1$s %2$s restored from the Trash.', '%1$s %3$s restored from the Trash.', $bulk_counts['untrashed'], 'kb-support'), $bulk_counts['untrashed'], $article_singular, $article_plural));
    return $bulk_messages;
}
Exemplo n.º 7
0
/**
 * Email Template Body
 *
 * @since	0.1
 * @param	int 	$ticket_id		Payment ID
 * @param	arr		$ticket_data	Payment Data
 * @return	str		$email_body		Body of the email
 */
function kbs_get_email_body_content($ticket_id = 0, $ticket_data = array())
{
    $default_email_body = __("Dear", "kb-support") . " {name},\n\n";
    $default_email_body .= sprintf(__("Thank you for logging your %s.", "kb-support"), kbs_get_ticket_label_singular(true)) . "\n\n";
    $default_email_body .= "{ticket_detailst}\n\n";
    $default_email_body .= "{sitename}";
    $email = kbs_get_option('ticket_received', false);
    $email = $email ? stripslashes($email) : $default_email_body;
    $email_body = apply_filters('kbs_email_template_wpautop', true) ? wpautop($email) : $email;
    $email_body = apply_filters('kbs_ticket_received_' . KBS()->emails->get_template(), $email_body, $ticket_id, $ticket_data);
    return apply_filters('kbs_ticket_received', $email_body, $ticket_id, $ticket_data);
}
Exemplo n.º 8
0
/**
 * The form submit button label.
 *
 * @since	1.0
 * @return	str		The label for the form submit button.
 */
function kbs_get_form_submit_label()
{
    return kbs_get_option('form_submit_label', sprintf(__('Submit %s', 'kb-support'), kbs_get_ticket_label_singular()));
}
Exemplo n.º 9
0
 /**
  * Creates a ticket
  *
  * @since 	1.0
  * @param 	arr		$data Array of attributes for a ticket. See $defaults aswell as wp_insert_post.
  * @param 	arr		$meta Array of attributes for a ticket's meta data. See $default_meta.
  * @return	mixed	false if data isn't passed and class not instantiated for creation, or New Ticket ID
  */
 public function create($data = array(), $meta = array())
 {
     if ($this->id != 0) {
         return false;
     }
     add_action('save_post_kbs_ticket', 'kbs_ticket_post_save', 10, 3);
     $defaults = array('post_type' => 'kbs_ticket', 'post_author' => is_user_logged_in() ? get_current_user_id() : 1, 'post_content' => '', 'post_status' => 'new', 'post_title' => sprintf(__('New %s', 'kb-support'), kbs_get_ticket_label_singular()));
     $default_meta = array('__agent' => 0, '__target_sla_respond' => kbs_calculate_sla_target_response(), '__target_sla_resolve' => kbs_calculate_sla_target_resolution(), '__source' => 1);
     $data = wp_parse_args($data, $defaults);
     $meta = wp_parse_args($meta, $default_meta);
     $data['meta_input'] = array('_ticket_data' => $meta);
     do_action('kbs_pre_create_ticket', $data, $meta);
     $id = wp_insert_post($data, true);
     $ticket = WP_Post::get_instance($id);
     do_action('kbs_post_create_ticket', $id, $data);
     add_action('save_post_kbs_ticket', 'kbs_ticket_post_save', 10, 3);
     return $this->setup_ticket($ticket);
 }
Exemplo n.º 10
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since	1.0
 * @global	$post
 * @param	str		$hook	Page hook
 * @return	void
 */
function kbs_load_admin_scripts($hook)
{
    if (!apply_filters('kbs_load_admin_scripts', kbs_is_admin_page(), $hook)) {
        return;
    }
    global $wp_version, $post;
    $js_dir = KBS_PLUGIN_URL . 'assets/js/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '';
    //'.min';
    $admin_deps = array();
    if (!kbs_is_admin_page($hook, 'edit') && !kbs_is_admin_page($hook, 'new')) {
        $admin_deps = array('jquery', 'inline-edit-post');
    } else {
        $admin_deps = array('jquery');
    }
    wp_register_script('kbs-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', $admin_deps, KBS_VERSION, false);
    wp_enqueue_script('kbs-admin-scripts');
    $editing_field_type = false;
    if (isset($_GET['kbs-action']) && 'edit_form_field' == $_GET['kbs-action']) {
        $field_settings = kbs_get_field_settings($_GET['field_id']);
        if ($field_settings) {
            $editing_field_type = $field_settings['type'];
        }
    }
    wp_localize_script('kbs-admin-scripts', 'kbs_vars', array('ajax_loader' => KBS_PLUGIN_URL . 'assets/images/loading.gif', 'post_id' => isset($post->ID) ? $post->ID : null, 'post_type' => isset($_GET['post']) ? get_post_type($_GET['post']) : false, 'editing_ticket' => isset($_GET['action']) && 'edit' == $_GET['action'] && 'kbs_ticket' == get_post_type($_GET['post']) ? true : false, 'admin_url' => admin_url(), 'kbs_version' => KBS_VERSION, 'add_new_ticket' => sprintf(__('Add New %s', 'kb-support'), kbs_get_ticket_label_singular()), 'new_media_ui' => apply_filters('kbs_use_35_media_ui', 1), 'no_ticket_reply_content' => __('There is no content in your reply', 'kb-support'), 'ticket_confirm_close' => __('Are you sure you wish to close this ticket? Click OK to close, or Cancel to return.', 'kb-support'), 'ticket_reply_failed' => sprintf(__('Could not add %s Reply', 'kb-support'), kbs_get_ticket_label_singular()), 'no_note_content' => __('There is no content in your note', 'kb-support'), 'note_not_added' => __('Your note could not be added', 'kb-support'), 'type_to_search' => sprintf(__('Type to search %s', 'kb-support'), kbs_get_kb_label_plural()), 'search_placeholder' => sprintf(__('Type to search all %s', 'kb-support'), kbs_get_kb_label_plural()), 'editing_field_type' => $editing_field_type, 'field_label_missing' => __('Enter a Label for your field.', 'kb-support'), 'field_type_missing' => __('Select the field Type', 'kb-support')));
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        // Call for new media manager
        wp_enqueue_media();
    }
    wp_register_style('kbs-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), KBS_VERSION, 'all');
    wp_enqueue_style('kbs-font-awesome');
    wp_register_script('jquery-chosen', $js_dir . 'chosen.jquery.js', array('jquery'), KBS_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('jquery-ui-dialog');
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_enqueue_style('thickbox');
    if ('post.php' == $hook || 'post-new.php' == $hook) {
        if (isset($_GET['post']) && 'kbs_ticket' == get_post_type($_GET['post'])) {
            wp_enqueue_script('jquery-ui-accordion');
        }
    }
}