/**
  * JavaScript object.
  *
  * The plugin uses a couple of JS variables that we pass
  * to the main script through a "wpas" object.
  *
  * @since  3.0.2
  * @return array The JavaScript object
  */
 protected function get_javascript_object()
 {
     global $post;
     if (!isset($post) || !is_object($post) || !is_a($post, 'WP_Post')) {
         return;
     }
     $upload_max_files = (int) wpas_get_option('attachments_max');
     $upload_max_size = (int) wpas_get_option('filesize_max');
     // Editors translations
     if (in_array($post->ID, wpas_get_submission_pages())) {
         $empty_editor = _x("You can't submit an empty ticket", 'JavaScript validation error message', 'awesome-support');
     } else {
         $empty_editor = _x("You can't submit an empty reply", 'JavaScript validation error message', 'awesome-support');
     }
     $object = array('ajaxurl' => admin_url('admin-ajax.php'), 'emailCheck' => true === boolval(wpas_get_option('enable_mail_check', false)) ? 'true' : 'false', 'fileUploadMax' => $upload_max_files, 'fileUploadSize' => $upload_max_size * 1048576, 'fileUploadMaxError' => __(sprintf('You can only upload a maximum of %d files', $upload_max_files), 'awesome-support'), 'fileUploadMaxSizeError' => array(__('The following file(s) are too big to be uploaded:', 'awesome-support'), sprintf(__('The maximum file size allowed for one file is %d MB', 'awesome-support'), $upload_max_size)), 'translations' => array('emptyEditor' => $empty_editor, 'onSubmit' => _x('Submitting...', 'ticket submission button text while submitting', 'awesome-support')));
     return $object;
 }
/**
 * Get URL of a submission page
 *
 * As the plugin can handle multiple submission pages, we need to
 * make sure that a give post ID is indeed a submission page, and if no
 * post ID is provided we return the URL of the first submission page.
 *
 * @since 3.2
 *
 * @param bool|false $post_id ID of the submission page
 *
 * @return string
 */
function wpas_get_submission_page_url($post_id = false)
{
    $submission = wpas_get_submission_pages();
    if (empty($submission)) {
        return '';
    }
    if (is_int($post_id) && in_array($post_id, $submission)) {
        $url = get_permalink((int) $post_id);
    } else {
        $url = get_permalink((int) $submission[0]);
    }
    return wp_sanitize_redirect($url);
}