| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) or exit; |
| 4 |
$date_format = get_option( 'date_format' ); |
| 5 |
$datetime_format = sprintf('%s %s', $date_format, get_option( 'time_format' ) ); |
| 6 |
|
| 7 |
add_action( 'hf_admin_form_submissions_table_output_column_header', function( $field, $column ) { |
| 8 |
echo $column; |
| 9 |
}, 10, 2 ); |
| 10 |
|
| 11 |
$bulk_actions = apply_filters( 'hf_admin_form_submissions_bulk_actions', array( |
| 12 |
'bulk_delete_submissions' => __( 'Move to Trash' ), |
| 13 |
)); |
| 14 |
|
| 15 |
/** |
| 16 |
* @var array $hidden_columns |
| 17 |
* @var array $submissions |
| 18 |
*/ |
| 19 |
?> |
| 20 |
|
| 21 |
<h2><?php _e( 'Form Submissions', 'html-forms' ); ?></h2> |
| 22 |
|
| 23 |
</form><?php // close main form. This means this always has to be the last tab or it will break stuff. ?> |
| 24 |
<form method="post"> |
| 25 |
<div class="tablenav top"> |
| 26 |
<div class="alignleft actions bulkactions"> |
| 27 |
<label for="bulk-action-selector-top" class="screen-reader-text"><?php _e( 'Select bulk action' ); ?></label> |
| 28 |
<select name="_hf_admin_action" id="bulk-action-selector-top"> |
| 29 |
<option value=""><?php _e( 'Bulk Actions' ); ?></option> |
| 30 |
<?php foreach( $bulk_actions as $key => $label ) { |
| 31 |
echo sprintf( '<option value="%s">%s</option>', esc_attr( $key ), $label ); |
| 32 |
} ?> |
| 33 |
</select> |
| 34 |
<input type="submit" class="button action" value="<?php _e( 'Apply' ); ?>"> |
| 35 |
</div> |
| 36 |
|
| 37 |
<div class="tablenav-pages one-page"> |
| 38 |
<span class="displaying-num"><?php echo sprintf( __( '%d items' ), count( $submissions ) ); ?></span> |
| 39 |
</div> |
| 40 |
|
| 41 |
<br class="clear"> |
| 42 |
</div> |
| 43 |
|
| 44 |
<table class="wp-list-table widefat fixed striped"> |
| 45 |
<thead> |
| 46 |
<tr> |
| 47 |
<td id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></td> |
| 48 |
<th scope="col" class="hf-column manage-column column-primary" style="width: 160px;"> |
| 49 |
<?php _e( 'Timestamp', 'html-forms' ); ?> |
| 50 |
</th> |
| 51 |
<?php foreach( $columns as $field => $column ) { |
| 52 |
$hidden_class = in_array( $field, $hidden_columns ) ? 'hidden' : ''; |
| 53 |
echo sprintf( '<th scope="col" class="hf-column hf-column-%s manage-column column-%s %s">', esc_attr( $field ), esc_attr( $field ), $hidden_class ); |
| 54 |
do_action( 'hf_admin_form_submissions_table_output_column_header', $field, $column ); |
| 55 |
echo '</th>'; |
| 56 |
} ?> |
| 57 |
</tr> |
| 58 |
</thead> |
| 59 |
<tbody> |
| 60 |
|
| 61 |
<?php foreach( $submissions as $s ) { ?> |
| 62 |
<tr id="hf-submissions-item-<?php echo $s->id; ?>"> |
| 63 |
<th scope="row" class="check-column"> |
| 64 |
<input type="checkbox" name="id[]" value="<?php echo esc_attr( $s->id ); ?>"/> |
| 65 |
</th> |
| 66 |
<td class="has-row-actions column-primary"> |
| 67 |
<strong><abbr title="<?php echo date( $datetime_format, strtotime( $s->submitted_at ) ); ?>"> |
| 68 |
<?php echo sprintf( '<a href="%s">%s</a>', esc_attr( add_query_arg( array( 'tab' => 'submissions', 'submission_id' => $s->id ) ) ), esc_html( $s->submitted_at ) ); ?> |
| 69 |
</abbr></strong> |
| 70 |
<div class="row-actions"> |
| 71 |
<?php do_action( 'hf_admin_form_submissions_table_output_row_actions', $s ); ?> |
| 72 |
</div> |
| 73 |
</td> |
| 74 |
|
| 75 |
<?php foreach( $columns as $field => $column ) { |
| 76 |
$hidden_class = in_array( $field, $hidden_columns ) ? 'hidden' : ''; |
| 77 |
echo sprintf( '<td class="column-%s %s">', esc_attr( $field ), $hidden_class ); |
| 78 |
|
| 79 |
// because some columns don't have a value, check if it's set here |
| 80 |
if( ! empty( $s->data[$field] ) ) { |
| 81 |
echo hf_field_value( $s->data[$field], 100 ); |
| 82 |
} |
| 83 |
|
| 84 |
echo '</td>'; |
| 85 |
} ?> |
| 86 |
</tr> |
| 87 |
<?php } ?> |
| 88 |
<?php if ( empty( $submissions ) ) { |
| 89 |
printf( '<tr><td colspan="2">%s</td></tr>', __( 'Nothing to see here, yet!', 'html-forms' ) ); |
| 90 |
} ?> |
| 91 |
</tbody> |
| 92 |
</table> |
| 93 |
</form> |
| 94 |
|
| 95 |
|
| 96 |
<form><?php // open new main form. This means this always has to be the last tab or it will break stuff. ?> |
| 97 |
|