/**
 * Get the ticket header.
 *
 * @since  3.0.0
 * @param  array  $args Additional parameters
 * @return void
 */
function wpas_ticket_header($args = array())
{
    global $wpas_cf, $post;
    $default = array('container' => '', 'container_id' => '', 'container_class' => '', 'table_id' => "header-ticket-{$post->ID}", 'table_class' => 'wpas-table wpas-ticket-details-header');
    $args = wp_parse_args($args, $default);
    $custom_fields = $wpas_cf->get_custom_fields();
    $columns = array('id' => __('ID', 'awesome-support'), 'status' => __('Status', 'awesome-support'), 'date' => __('Date', 'awesome-support'));
    $columns_callbacks = array('id' => 'id', 'status' => 'wpas_cf_display_status', 'date' => 'date');
    foreach ($custom_fields as $field) {
        /* Don't display core fields */
        if (true === $field['args']['core']) {
            continue;
        }
        /* Don't display fields that aren't specifically designed to */
        if (true === $field['args']['show_column']) {
            $columns[$field['name']] = !empty($field['args']['title']) ? sanitize_text_field($field['args']['title']) : wpas_get_title_from_id($field['name']);
            $columns_callbacks[$field['name']] = 'taxonomy' === $field['args']['field_type'] && true === $field['args']['taxo_std'] ? 'taxonomy' : $field['args']['column_callback'];
        }
    }
    $columns = apply_filters('wpas_tickets_details_columns', $columns);
    $columns_callbacks = apply_filters('wpas_tickets_details_columns_callbacks', $columns_callbacks);
    ?>

	<?php 
    if (!empty($args['container'])) {
        ?>
<<?php 
        echo $args['container'];
        ?>
><?php 
    }
    ?>

		<table id="<?php 
    echo $args['table_id'];
    ?>
" class="<?php 
    echo $args['table_class'];
    ?>
">
			<thead>
				<tr>
					<?php 
    foreach ($columns as $column => $label) {
        ?>
						<th><?php 
        echo $label;
        ?>
</th>
					<?php 
    }
    ?>
				</tr>
			</thead>
			<tbody>
				<tr>
					<?php 
    foreach ($columns_callbacks as $column => $callback) {
        ?>
						<td>
							<?php 
        wpas_get_tickets_list_column_content($column, array('callback' => $callback));
        ?>
						</td>
					<?php 
    }
    ?>
				</tr>
			</tbody>
		</table>

	<?php 
    if (!empty($args['container'])) {
        ?>
</<?php 
        echo $args['container'];
        ?>
><?php 
    }
}
Exemplo n.º 2
0
			</thead>
			<tbody>
				<?php 
    while ($wpas_tickets->have_posts()) {
        $wpas_tickets->the_post();
        echo '<tr>';
        foreach ($columns as $column_id => $column) {
            echo '<td';
            /* If current column is the date we add the date attribute for sorting purpose */
            if ('date' === $column_id) {
                echo ' data-order="' . strtotime(get_the_time()) . '"';
            }
            /* We don't forget to close the <td> tag */
            echo '>';
            /* Display the content for this column */
            wpas_get_tickets_list_column_content($column_id, $column);
            echo '</td>';
        }
        echo '</tr>';
    }
    wp_reset_query();
    ?>
			</tbody>
		</table>
		<?php 
    wpas_make_button(__('Open a ticket', 'awesome-support'), array('type' => 'link', 'link' => wpas_get_submission_page_url(), 'class' => 'wpas-btn wpas-btn-default'));
    ?>
	</div>
<?php 
} else {
    echo wpas_get_notification_markup('info', sprintf(__('You haven\'t submitted a ticket yet. <a href="%s">Click here to submit your first ticket</a>.', 'awesome-support'), wpas_get_submission_page_url()));