本文整理汇总了PHP中wpas_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP wpas_get_option函数的具体用法?PHP wpas_get_option怎么用?PHP wpas_get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpas_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpas_is_ticket_old
/**
* Check if the ticket is old.
*
* A simple check based on the value of the "Ticket old" option.
* If the last reply (or the ticket itself if no reply) is older
* than the post date + the allowed delay, then it is considered old.
*
* @since 3.0.0
* @param integer $post_id The ID of the ticket to check
* @param object $latest The object containing the ticket replies. If the object was previously generated we pass it directly in order to avoid re-querying
* @return boolean True if the ticket is old, false otherwise
*/
function wpas_is_ticket_old($post_id, $latest = null)
{
if ('closed' === wpas_get_ticket_status($post_id)) {
return false;
}
/* Prepare the new object */
if (is_null($latest)) {
$latest = new WP_Query(array('posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'ticket_reply', 'post_parent' => $post_id, 'post_status' => array('unread', 'read'), 'no_found_rows' => true, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false));
}
/**
* We check when was the last reply (if there was a reply).
* Then, we compute the ticket age and if it is considered as
* old, we display an informational tag.
*/
if (empty($latest->posts)) {
$post = get_post($post_id);
/* We get the post date */
$date_created = $post->post_date;
} else {
/* We get the post date */
$date_created = $latest->post->post_date;
}
$old_after = wpas_get_option('old_ticket');
if (strtotime("{$date_created} +{$old_after} days") < strtotime('now')) {
return true;
}
return false;
}
示例2: display
/**
* Return the field markup for the front-end.
*
* @return string Field markup
*/
public function display()
{
$editor = '';
/**
* Check if the description field should use the WYSIWYG editor
*
* @var string
*/
$wysiwyg = boolval(wpas_get_option('frontend_wysiwyg_editor'));
if (true === $wysiwyg || is_admin()) {
$editor_defaults = array('media_buttons' => false, 'textarea_name' => $this->get_field_id(), 'textarea_rows' => 10, 'tabindex' => 2, 'editor_class' => $this->get_field_class(), 'quicktags' => false, 'tinymce' => array('toolbar1' => 'bold,italic,underline,strikethrough,hr,|,bullist,numlist,|,link,unlink', 'toolbar2' => ''));
/* Merge custom editor settings if any */
$args = isset($this->field_args['editor']) && is_array($this->field_args['editor']) ? wp_parse_args($this->field_args['editor'], $editor_defaults) : $editor_defaults;
$wysiwyg_id = str_replace('_', '-', $this->get_field_id());
// The codex says the opposite, but underscores causes issues while hyphens don't. Weird...
ob_start();
wp_editor($this->populate(), $wysiwyg_id, $args);
/* Get the buffered content into a var */
$editor = ob_get_contents();
/* Clean buffer */
ob_end_clean();
$editor = "<label {{label_atts}}>{{label}}</label><div class='wpas-submit-ticket-wysiwyg'>{$editor}</div>";
} else {
$path = WPAS_PATH . "includes/custom-fields/field-types/class-cf-textarea.php";
if (file_exists($path)) {
include_once $path;
$textarea = new WPAS_CF_Textarea($this->field_id, $this->field);
$editor = $textarea->display();
}
}
return $editor;
}
示例3: wpas_upgrade_320
/**
* Upgrade function for version 3.2.0
*
* @since 3.2.0
* @return void
*/
function wpas_upgrade_320()
{
$registrations = (bool) wpas_get_option('allow_registrations', true);
if (true === $registrations) {
wpas_update_option('allow_registrations', 'allow');
} else {
wpas_update_option('allow_registrations', 'disallow');
}
}
示例4: wpas_sc_client_account
/**
* Registration page shortcode.
*/
function wpas_sc_client_account()
{
global $wpas_tickets, $current_user, $post;
/**
* For some reason when the user ID is set to 0
* the query returns posts whose author has ID 1.
* In order to avoid that (for non logged users)
* we set the user ID to -1 if it is 0.
*
* @var integer
*/
$author = 0 !== $current_user->ID ? $current_user->ID : -1;
$args = apply_filters('wpas_tickets_shortcode_query_args', array('author' => $author, 'post_type' => 'ticket', 'post_status' => 'any', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => -1, 'no_found_rows' => false, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false));
$wpas_tickets = new WP_Query($args);
/* Get the ticket content */
ob_start();
/**
* wpas_frontend_plugin_page_top is executed at the top
* of every plugin page on the front end.
*/
do_action('wpas_frontend_plugin_page_top', $post->ID, $post);
/**
* wpas_before_tickets_list hook
*/
do_action('wpas_before_tickets_list');
/* If user is not logged in we display the register form */
if (!is_user_logged_in()) {
$registration = wpas_get_option('login_page', false);
if (false !== $registration && !empty($registration) && !is_null(get_post(intval($registration)))) {
/* As the headers are already sent we can't use wp_redirect. */
echo '<meta http-equiv="refresh" content="0; url=' . get_permalink($registration) . '" />';
wpas_get_notification_markup('info', __('You are being redirected...', 'awesome-support'));
exit;
}
wpas_get_template('registration');
} else {
/**
* Get the custom template.
*/
wpas_get_template('list');
}
/**
* wpas_after_tickets_list hook
*/
do_action('wpas_after_tickets_list');
/**
* Finally get the buffer content and return.
*
* @var string
*/
$content = ob_get_clean();
return $content;
}
示例5: display
/**
* Return the field markup for the front-end.
*
* @return string Field markup
*/
public function display()
{
$multiple = true === $this->field_args['multiple'] ? 'multiple' : '';
$filetypes = explode(',', apply_filters('wpas_attachments_filetypes', wpas_get_option('attachments_filetypes')));
$accept = array();
foreach ($filetypes as $key => $type) {
$filetypes[$key] = "<code>.{$type}</code>";
array_push($accept, ".{$type}");
}
$accept = implode(',', $accept);
return sprintf('<label {{label_atts}}>{{label}}</label><input type="file" value="%s" {{atts}} accept="%s" %s>', $this->populate(), $accept, $multiple);
}
示例6: wpas_tickets_count
/**
* Add ticket count in admin menu item.
*
* @return boolean True if the ticket count was added, false otherwise
* @since 1.0.0
*/
function wpas_tickets_count()
{
if (false === (bool) wpas_get_option('show_count')) {
return false;
}
global $menu, $current_user;
if (current_user_can('administrator') && false === boolval(wpas_get_option('admin_see_all')) || !current_user_can('administrator') && current_user_can('edit_ticket') && false === boolval(wpas_get_option('agent_see_all'))) {
$agent = new WPAS_Member_Agent($current_user->ID);
$count = $agent->open_tickets();
} else {
$count = count(wpas_get_tickets('open'));
}
if (0 === $count) {
return false;
}
foreach ($menu as $key => $value) {
if ($menu[$key][2] == 'edit.php?post_type=ticket') {
$menu[$key][0] .= ' <span class="awaiting-mod count-' . $count . '"><span class="pending-count">' . $count . '</span></span>';
}
}
return true;
}
示例7: wpas_toolbar_tickets_link
/**
* Add link to agent's tickets.
*
* @since 3.0.0
*
* @param object $wp_admin_bar The WordPress toolbar object
*
* @return void
*/
function wpas_toolbar_tickets_link($wp_admin_bar)
{
if (!current_user_can('edit_ticket')) {
return;
}
$hide = (bool) wpas_get_option('hide_closed');
$agent_see_all = (bool) wpas_get_option('agent_see_all');
$admin_see_all = (bool) wpas_get_option('admin_see_all');
$args = array('post_type' => 'ticket');
// In case the current user can only see his own tickets
if (current_user_can('administrator') && false === $admin_see_all || !current_user_can('administrator') && false === $agent_see_all) {
global $current_user;
$agent = new WPAS_Member_Agent($current_user->ID);
$tickets_count = $agent->open_tickets();
} else {
$tickets_count = count(wpas_get_tickets('open', $args));
}
if (true === $hide) {
$args['wpas_status'] = 'open';
}
$node = array('id' => 'wpas_tickets', 'parent' => null, 'group' => null, 'title' => '<span class="ab-icon"></span> ' . $tickets_count, 'href' => add_query_arg($args, admin_url('edit.php')), 'meta' => array('target' => '_self', 'title' => esc_html__('Open tickets assigned to you', 'awesome-support'), 'class' => 'wpas-my-tickets'));
$wp_admin_bar->add_node($node);
}
示例8: as_pastebin_send_paste
function as_pastebin_send_paste($data = array())
{
if (empty($data) && !empty($_POST)) {
$data = $_POST;
}
// Make sure we have data to paste
if (empty($data)) {
return new WP_Error('no_data', esc_html__('Not data to send to Pastebin', 'as-pastebin'));
}
$post_id = isset($data['post_id']) ? (int) $data['post_id'] : '';
// Make sure we have a post to attach the paste to
if (empty($post_id)) {
return new WP_Error('no_post_id', esc_html__('Impossible to identify the post to which this paste is related', 'as-pastebin'));
}
$post = get_post($post_id);
// Make sure the post is either a ticket or a ticket reply
if (!is_object($post) || !is_a($post, 'WP_Post') || !in_array($post->post_type, array('ticket', 'ticket_reply'))) {
return new WP_Error('no_ticket', esc_html__('A paste must be attached to a ticket or a reply only', 'as-pastebin'));
}
$dev_key = trim(wpas_get_option('pastebin_dev_key', ''));
// A developer key is required for using Pastebin API
if (empty($dev_key)) {
return new WP_Error('no_dev_key', esc_html__('A developer API key is required', 'as-pastebin'));
}
// Make sure we have some code to paste
if (empty($data['code'])) {
return new WP_Error('no_code', esc_html__('There is no code to paste', 'as-pastebin'));
}
// Get the code format and fallback on default if there is no format in $data
$format = isset($data['paste_format']) && !empty($data['paste_format']) ? filter_input('string', $data['paste_format']) : wpas_get_option('pastebin_paste_format', '');
// Get the paste name
$name = isset($data['paste_name']) && !empty($data['paste_name']) ? filter_input('string', $data['paste_name']) : "Paste for post ";
$args = array('body' => array('api_option' => 'paste', 'api_paste_private' => wpas_get_option('pastebin_paste_private', '1'), 'api_paste_name' => sanitize_text_field($name), 'api_paste_expire_date' => wpas_get_option('pastebin_paste_expire', '10M'), 'api_paste_format' => $format, 'api_dev_key' => $dev_key, 'api_paste_code' => $data['code']));
$response = wp_remote_post(esc_url('http://pastebin.com/api/api_post.php'), $args);
return $response;
}
示例9: get_api_key
protected function get_api_key()
{
return wpas_get_option('mailgun_api_key', '');
}
示例10: wpas_sc_client_account
/**
* Registration page shortcode.
*/
function wpas_sc_client_account()
{
global $wpas_tickets, $current_user, $post;
/**
* For some reason when the user ID is set to 0
* the query returns posts whose author has ID 1.
* In order to avoid that (for non logged users)
* we set the user ID to -1 if it is 0.
*
* @var integer
*/
$author = 0 !== $current_user->ID ? $current_user->ID : -1;
// Custom Code By spgandhi@live.com
if (isset($_GET['view'])) {
$view = $_GET['view'];
} else {
$view = 'mine';
}
// End - Custom Code by spgandhi@live.com
$args = array('post_type' => 'ticket', 'post_status' => 'any', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => -1, 'no_found_rows' => false, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false);
// Custom Code by spgandhi@live.com
if ($view == 'mine') {
$args['author'] = $author;
} else {
if ($view == 'hmc') {
if (current_user_can('supervisor_view')) {
echo '<h3>You will see all complains here.</h3>';
} else {
if (current_user_can('hmc_view')) {
$current_user_id = wp_get_current_user()->ID;
$wing = get_user_meta($current_user_id, 'pie_dropdown_4', true);
$room = get_user_meta($current_user_id, 'pie_number_5', true);
$room_start = substr($room, 0, 1);
$args['meta_query'] = array('relation' => 'AND', array('key' => '_wpas_wing', 'value' => $wing), array('key' => '_wpas_room_no', 'value' => array($room_start * 100, $room_start * 100 + 20), 'type' => 'numeric', 'compare' => 'BETWEEN'));
echo '<h3>You will see all the complains of your floor here.</h3>';
$args['meta_key'] = '_wpas_wing';
$args['meta_value'] = $wing;
} else {
$args['author'] = $author;
}
}
} else {
$args['author'] = $author;
}
}
// End - Custom code by spgandhi@live.com
$wpas_tickets = new WP_Query($args);
/* Get the ticket content */
ob_start();
/**
* wpas_frontend_plugin_page_top is executed at the top
* of every plugin page on the front end.
*/
do_action('wpas_frontend_plugin_page_top', $post->ID, $post);
/**
* wpas_before_tickets_list hook
*/
do_action('wpas_before_tickets_list');
/* If user is not logged in we display the register form */
if (!is_user_logged_in()) {
$registration = wpas_get_option('login_page', false);
if (false !== $registration && !empty($registration) && !is_null(get_post(intval($registration)))) {
/* As the headers are already sent we can't use wp_redirect. */
echo '<meta http-equiv="refresh" content="0; url=' . get_permalink($registration) . '" />';
wpas_get_notification_markup('info', __('You are being redirected...', 'awesome-support'));
exit;
}
wpas_get_template('registration');
} else {
/**
* Get the custom template.
*/
wpas_get_template('list');
}
/**
* wpas_after_tickets_list hook
*/
do_action('wpas_after_tickets_list');
/**
* Finally get the buffer content and return.
*
* @var string
*/
$content = ob_get_clean();
return $content;
}
示例11: status_filter
/**
* Add status dropdown in the filters bar.
*
* @since 2.0.0
* @return void
*/
public function status_filter()
{
global $typenow;
if ('ticket' != $typenow) {
echo '';
}
if (isset($_GET['post_status'])) {
echo '';
}
$this_sort = isset($_GET['wpas_status']) ? filter_input(INPUT_GET, 'wpas_status', FILTER_SANITIZE_STRING) : '';
$all_selected = '' === $this_sort ? 'selected="selected"' : '';
$open_selected = !isset($_GET['wpas_status']) && true === (bool) wpas_get_option('hide_closed') || 'open' === $this_sort ? 'selected="selected"' : '';
$closed_selected = 'closed' === $this_sort ? 'selected="selected"' : '';
$dropdown = '<select id="wpas_status" name="wpas_status">';
$dropdown .= "<option value='' {$all_selected}>" . __('Any Status', 'wpas') . "</option>";
$dropdown .= "<option value='open' {$open_selected}>" . __('Open', 'wpas') . "</option>";
$dropdown .= "<option value='closed' {$closed_selected}>" . __('Closed', 'wpas') . "</option>";
$dropdown .= '</select>';
echo $dropdown;
}
示例12: wpas_sc_submit_form
/**
* Submission for shortcode.
*/
function wpas_sc_submit_form()
{
global $post;
/* Start the buffer */
ob_start();
/* Open main container */
?>
<div class="wpas"><?php
/**
* wpas_before_ticket_submit hook
*/
do_action('wpas_before_ticket_submit');
/**
* wpas_frontend_plugin_page_top is executed at the top
* of every plugin page on the front end.
*/
do_action('wpas_frontend_plugin_page_top', $post->ID, $post);
/* If user is not logged in we display the register form */
if (!is_user_logged_in()) {
$registration = wpas_get_option('login_page', false);
if (false !== $registration && !empty($registration) && !is_null(get_post(intval($registration)))) {
/* As the headers are already sent we can't use wp_redirect. */
echo '<meta http-equiv="refresh" content="0; url=' . get_permalink($registration) . '" />';
echo wpas_get_notification_markup('info', __('You are being redirected...', 'wpas'));
exit;
}
wpas_get_template('registration');
/**
* If user is logged in we display the ticket submission form
*/
} else {
/**
* wpas_before_ticket_submission_form hook
*/
do_action('wpas_before_ticket_submission_form_before_wrapper');
/* Namespace our content */
echo '<div class="wpas">';
/**
* wpas_before_all_templates hook.
*
* This hook is called at the top of every template
* used for the plugin front-end. This allows for adding actions
* (like notifications for instance) on all plugin related pages.
*/
do_action('wpas_before_all_templates');
/**
* wpas_before_ticket_submission_form hook
*/
do_action('wpas_before_ticket_submission_form');
/**
* Check if the current user is logged in
*/
if (false === is_user_logged_in()) {
echo wpas_get_notification_markup('failure', sprintf(__('You need to <a href="%s">log-in</a> to submit a ticket.', 'wpas'), esc_url('')));
} else {
/**
* Make sure the current user can submit a ticket.
*/
if (false === wpas_can_submit_ticket()) {
echo wpas_get_notification_markup('failure', __('You are not allowed to submit a ticket.', 'wpas'));
} else {
/**
* We check if the user is authorized to submit a ticket.
* User must be logged-in and can't have the capability. If the
* user isn't authorized to submit, we return the error message hereafter.
*
* Basically, admins and agents aren't allowed to submit a ticket as they
* need to do it in the back-end.
*
* If you want to allow admins and agents to submit tickets through the
* front-end, please use the filter wpas_agent_submit_front_end and set the value to (bool) true.
*/
if (is_user_logged_in() && current_user_can('edit_ticket') && false === apply_filters('wpas_agent_submit_front_end', false)) {
/**
* Keep in mind that if you allow agents to open ticket through the front-end, actions
* will not be tracked.
*/
echo wpas_get_notification_markup('info', sprintf(__('Sorry, support team members cannot submit tickets from here. If you need to open a ticket, please go to your admin panel or <a href="%s">click here to open a new ticket</a>.', 'wpas'), add_query_arg(array('post_type' => 'ticket'), admin_url('post-new.php'))));
/**
* If the user is authorized to post a ticket, we display the submit form
*/
} else {
global $post;
/**
* wpas_submission_form_before hook
*
* @since 3.0.0
*/
do_action('wpas_submission_form_before');
wpas_get_template('submission');
/**
* wpas_submission_form_after hook
*
* @since 3.0.0
*/
do_action('wpas_submission_form_after');
}
//.........这里部分代码省略.........
示例13: limit_upload
/**
* Limit upload filetypes.
*
* Gets the list of allowed file extensions from the plugin settings
* and compare the processed file. If the extension is not in the list we
* simply return an error message to prevent uploading it.
*
* @since 3.0.0
* @param array $file Currently processed file details
* @return array File details with a possible error message
*/
public function limit_upload($file)
{
global $post;
if (empty($post)) {
$protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
$post_id = url_to_postid($protocol . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$post = get_post($post_id);
}
$submission = (int) wpas_get_option('ticket_submit');
$post_type = filter_input(INPUT_GET, 'post_type', FILTER_SANITIZE_STRING);
/**
* On the front-end we only want to limit upload size
* on the submission page or on a ticket details page.
*/
if (!is_admin()) {
if ('ticket' !== $post->post_type && $submission !== $post->ID) {
return $file;
}
}
/**
* In the admin we only want to limit upload size on the ticket creation screen
* or on the ticket edit screen.
*/
if (is_admin()) {
if (!isset($post) && empty($post_type)) {
return $file;
}
if (isset($post) && 'ticket' !== $post->post_type) {
return $file;
}
if (!empty($post_type) && 'ticket' !== $post_type) {
return $file;
}
}
$filetypes = explode(',', $this->get_allowed_filetypes());
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$max_size = wpas_get_option('filesize_max', 1);
$max_size_bytes = $max_size * 1024 * 1024;
if (!in_array($ext, $filetypes)) {
$file['error'] = sprintf(__('You are not allowed to upload files of this type (%s)', 'awesome-support'), $ext);
}
if ($file['size'] <= 0) {
$file['error'] = __('You cannot upload empty attachments. You attachments weights 0 bytes', 'awesome-support');
}
if ($file['size'] > $max_size_bytes) {
$file['error'] = sprintf(__('Your attachment is too big. You are allowed to attach files up to %s', 'awesome-support'), "{$max_size} Mo");
}
return $file;
}
示例14: wpas_register_account
/**
* Register user account.
*
* @param array|bool $data User data
*
* @since 1.0.0
* @return void
*/
function wpas_register_account($data = false)
{
global $post;
/* Make sure registrations are open */
$registration = boolval(wpas_get_option('allow_registrations', true));
if (true !== $registration) {
wp_redirect(add_query_arg(array('message' => wpas_create_notification(__('Registrations are currently not allowed.', 'wpas')), get_permalink($post->ID))));
exit;
}
if (false === $data) {
$data = $_POST;
}
$email = isset($data['email']) && !empty($data['email']) ? sanitize_email($data['email']) : false;
$first_name = isset($data['first_name']) && !empty($data['first_name']) ? sanitize_text_field($data['first_name']) : false;
$last_name = isset($data['last_name']) && !empty($data['last_name']) ? sanitize_text_field($data['last_name']) : false;
$pwd = isset($data['pwd']) && !empty($data['pwd']) ? $data['pwd'] : false;
/* Save the user information in session to pre populate the form in case of error. */
$_SESSION['wpas_registration_form'] = array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email);
/**
* wpas_pre_register_account hook
*
* This hook is triggered all the time
* even if the checks don't pass.
*
* @since 3.0.1
*/
do_action('wpas_pre_register_account', $data);
if (wpas_get_option('terms_conditions', false) && !isset($data['terms'])) {
wp_redirect(add_query_arg(array('message' => wpas_create_notification(__('You did not accept the terms and conditions.', 'wpas')), get_permalink($post->ID))));
exit;
}
/* Make sure we have all the necessary data. */
if (false === ($email || $first_name || $last_name || $pwd)) {
wp_redirect(add_query_arg(array('message' => wpas_create_notification(__('You didn\'t correctly fill all the fields.', 'wpas')), get_permalink($post->ID))));
exit;
}
$username = sanitize_user(strtolower($first_name) . strtolower($last_name));
$user = get_user_by('login', $username);
/* Check for existing username */
if (is_a($user, 'WP_User')) {
$suffix = 1;
do {
$alt_username = sanitize_user($username . $suffix);
$user = get_user_by('login', $alt_username);
$suffix++;
} while (is_a($user, 'WP_User'));
$username = $alt_username;
}
/**
* wpas_insert_user_data filter
*
* @since 3.1.5
* @var array User account arguments
*/
$args = apply_filters('wpas_insert_user_data', array('user_login' => $username, 'user_email' => $email, 'first_name' => $first_name, 'last_name' => $last_name, 'display_name' => "{$first_name} {$last_name}", 'user_pass' => $pwd, 'role' => 'wpas_user'));
/**
* wpas_register_account_before hook
*
* Fired right before the user is added to the database.
*/
do_action('wpas_register_account_before', $args);
$user_id = wp_insert_user(apply_filters('wpas_user_registration_data', $args));
if (is_wp_error($user_id)) {
/**
* wpas_register_account_before hook
*
* Fired right after a failed attempt to register a user.
*
* @since 3.0.1
*/
do_action('wpas_register_account_failed', $user_id, $args);
$error = $user_id->get_error_message();
wp_redirect(add_query_arg(array('message' => wpas_create_notification($error), get_permalink($post->ID))));
exit;
} else {
/**
* wpas_register_account_before hook
*
* Fired right after the user is successfully added to the database.
*
* @since 3.0.1
*/
do_action('wpas_register_account_after', $user_id, $args);
/* Delete the user information data from session. */
unset($_SESSION['wpas_registration_form']);
wp_new_user_notification($user_id, $pwd);
if (headers_sent()) {
wp_redirect(add_query_arg(array('message' => wpas_create_notification(__('Your account has been created. Please log-in.', 'wpas')), get_permalink($post->ID))));
exit;
}
if (!is_user_logged_in()) {
/* Automatically log the user in */
//.........这里部分代码省略.........
示例15: _e
<div class="updated below-h2" style="margin-top: 2em;">
<h2 style="margin: 0.5em 0; padding: 0; line-height: 100%;"><?php
_e('Create Ticket', 'awesome-support');
?>
</h2>
<p><?php
_e('Please save this ticket to reveal all options.', 'awesome-support');
?>
</p>
</div>
<?php
/* Now let's display the real content */
} else {
/* We're going to get all the posts part of the ticket history */
$replies_args = array('posts_per_page' => -1, 'orderby' => 'post_date', 'order' => wpas_get_option('replies_order', 'ASC'), 'post_type' => apply_filters('wpas_replies_post_type', array('ticket_history', 'ticket_reply')), 'post_parent' => $post->ID, 'post_status' => apply_filters('wpas_replies_post_status', array('publish', 'inherit', 'private', 'trash', 'read', 'unread')));
$history = new WP_Query($replies_args);
if (!empty($history->posts)) {
foreach ($history->posts as $row) {
// Set the author data (if author is known)
if ($row->post_author != 0) {
$user_data = get_userdata($row->post_author);
$user_id = $user_data->data->ID;
$user_name = $user_data->data->display_name;
} else {
$user_name = __('Anonymous', 'awesome-support');
$user_id = 0;
}
$user_avatar = get_avatar($user_id, '64', get_option('avatar_default'));
$date = human_time_diff(get_the_time('U', $row->ID), current_time('timestamp'));
$post_type = $row->post_type;