/**
 * Echo a custom field value.
 *
 * This function is just a wrapper function for wpas_get_cf_value()
 * that echoes the result instead of returning it.
 *
 * @param  string  $name    Option name
 * @param  integer $post_id Post ID
 * @param  mixed   $default Default value
 *
 * @return mixed            Meta value
 * @since  3.0.0
 */
function wpas_cf_value($name, $post_id, $default = false)
{
    echo wpas_get_cf_value($name, $post_id, $default);
}
Ejemplo n.º 2
0
/* Issuer name */
if ($issuer !== false) {
    $issuer_id = $issuer->data->ID;
    $issuer_name = $issuer->data->display_name;
} else {
    $issuer_id = 0;
    $issuer_name = __('User was deleted', 'awesome-support');
}
/* Issuer tickets link */
$issuer_tickets = admin_url(add_query_arg(array('post_type' => 'ticket', 'author' => $issuer_id), 'edit.php'));
/* Prepare the empty users list */
$users = array();
/* Get fields values */
$ccs = wpas_get_cf_value('ccs', get_the_ID());
/* Get ticket assignee */
$assignee = wpas_get_cf_value('assignee', get_the_ID());
/* List available agents */
foreach ($wp_roles->roles as $role => $data) {
    /* Check if current role can edit tickets */
    if (array_key_exists('edit_ticket', $data['capabilities'])) {
        /* Get users with current role */
        $usrs = new WP_User_Query(array('role' => $role));
        /* Save users in global array */
        $users = array_merge($users, $usrs->get_results());
    }
}
?>
<div id="wpas-stakeholders">
	<label for="wpas-issuer"><strong><?php 
_e('Ticket Creator', 'awesome-support');
?>
Ejemplo n.º 3
0
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}
// Add nonce
wp_nonce_field('wpas_update_cf', 'wpas_cf', false, true);
// Set post-dependant values
if (isset($post) && is_a($post, 'WP_Post') && 'auto-draft' !== $post->post_status) {
    // Client
    $client = get_userdata($post->post_author);
    $client_id = $client->ID;
    $client_name = $client->data->display_name;
    $client_option = "<option value='{$client_id}' selected='selected'>{$client_name}</option>";
    $client_link = esc_url(admin_url(add_query_arg(array('post_type' => 'ticket', 'author' => $client_id), 'edit.php')));
    // Staff
    $staff_id = wpas_get_cf_value('assignee', get_the_ID());
} else {
    // Staff
    $staff_id = get_current_user_id();
    // Client
    $client_id = 0;
    $client_name = '';
    $client_link = '';
    $client_option = '';
}
// Set post-independent vars
$staff = get_user_by('ID', $staff_id);
$staff_name = $staff->data->display_name;
?>
<div id="wpas-stakeholders">
	<label for="wpas-issuer"><strong data-hint="<?php 
 public function test_get_field_value()
 {
     update_post_meta($this->ticket_id, '_wpas_my_test_field', 'hello');
     $this->assertEquals('hello', $this->text_field->get_field_value('', $this->ticket_id));
     $this->assertEquals('hello', wpas_get_cf_value('my_test_field', $this->ticket_id, ''));
 }
Ejemplo n.º 5
0
    /**
     * Textarea field.
     */
    public static function textarea($field)
    {
        if (isset($post)) {
            $post_id = $post->ID;
        } elseif (isset($_GET['post'])) {
            $post_id = intval($_GET['post']);
        } else {
            $post_id = false;
        }
        $field_id = 'wpas_' . $field['name'];
        $value = wpas_get_cf_value($field_id, $post_id);
        $label = wpas_get_field_title($field);
        $field_class = isset($field['args']['field_class']) ? $field['args']['field_class'] : '';
        ?>

		<div <?php 
        wpas_get_field_container_class($field_id);
        ?>
 id="<?php 
        echo $field_id;
        ?>
_container">
			
			<label for="<?php 
        echo $field_id;
        ?>
"><strong><?php 
        echo $label;
        ?>
</strong></label>

			<?php 
        if (!is_admin() || current_user_can($field['args']['capability'])) {
            ?>
				<textarea id="<?php 
            echo $field_id;
            ?>
" <?php 
            wpas_get_field_class($field_id, $field_class);
            ?>
 name="<?php 
            echo $field_id;
            ?>
" <?php 
            if ($field['args']['placeholder'] !== '') {
                ?>
placeholder="<?php 
                echo $field['args']['placeholder'];
                ?>
"<?php 
            }
            ?>
 <?php 
            if (true === $field['args']['required']) {
                ?>
required<?php 
            }
            ?>
><?php 
            echo $value;
            ?>
</textarea>
			<?php 
        } else {
            ?>
				<p id="<?php 
            echo $field_id;
            ?>
"><?php 
            echo $value;
            ?>
</p>
			<?php 
        }
        if (isset($field['args']['desc']) && '' != $field['args']['desc'] && WPAS_FIELDS_DESC) {
            ?>
<p class="<?php 
            echo is_admin() ? 'description' : 'wpas-help-block';
            ?>
"><?php 
            echo wp_kses_post($field['args']['desc']);
            ?>
</p><?php 
        }
        ?>
		</div>

	<?php 
    }