| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) : |
| 5 |
exit; |
| 6 |
endif; |
| 7 |
|
| 8 |
class RSVP_Events_List_Table extends RSVP_List_Table { |
| 9 |
|
| 10 |
public function __construct( $args = array() ) { |
| 11 |
parent::__construct( array( |
| 12 |
'plural' => 'events', |
| 13 |
'singular' => 'event', |
| 14 |
'ajax' => false, |
| 15 |
'screen' => null, |
| 16 |
) ); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Message to be displayed when there are no items |
| 21 |
* |
| 22 |
* @since 2.7.2 |
| 23 |
* @access public |
| 24 |
*/ |
| 25 |
public function no_items() { |
| 26 |
_e( 'No events found.', 'rsvp-plugin' ); |
| 27 |
} |
| 28 |
|
| 29 |
public function prepare_items( $data = array() ) { |
| 30 |
|
| 31 |
$columns = $this->get_columns(); |
| 32 |
$hidden = $this->get_hidden_columns(); |
| 33 |
$sortable = $this->get_sortable_columns(); |
| 34 |
|
| 35 |
$this->_column_headers = array( $columns, $hidden, $sortable ); |
| 36 |
|
| 37 |
$this->items = array( |
| 38 |
'event_name' => esc_html( 'General event', 'rsvp-plugin' ), |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
public function get_columns() { |
| 43 |
|
| 44 |
$columns = array( |
| 45 |
'event_name' => __( 'Event Name', 'rsvp-plugin' ), |
| 46 |
'attendees' => __( 'Attendees', 'rsvp-plugin' ), |
| 47 |
); |
| 48 |
|
| 49 |
return $columns; |
| 50 |
} |
| 51 |
|
| 52 |
public function get_hidden_columns() { |
| 53 |
return array(); |
| 54 |
} |
| 55 |
|
| 56 |
public function get_sortable_columns() { |
| 57 |
return array(); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* @param $item |
| 63 |
* @param $column_name |
| 64 |
* |
| 65 |
* @return mixed|void |
| 66 |
* @since 4.4.8 |
| 67 |
*/ |
| 68 |
public function column_default( $item, $column_name ) { |
| 69 |
switch ( $column_name ) { |
| 70 |
case 'event_name': |
| 71 |
$text = esc_html( $item[ $column_name ] ); |
| 72 |
break; |
| 73 |
default: |
| 74 |
$text = esc_html( $item[ $column_name ] ); |
| 75 |
} |
| 76 |
|
| 77 |
return apply_filters( "rsvp_attendee_list_column_$column_name", $text, $item ); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @param int $level |
| 82 |
* |
| 83 |
* @param $item |
| 84 |
* |
| 85 |
* @since 4.4.8 |
| 86 |
*/ |
| 87 |
public function single_row( $item, $level = 0 ) { |
| 88 |
?> |
| 89 |
<tr> |
| 90 |
<?php $this->single_row_columns( $item ); ?> |
| 91 |
</tr> |
| 92 |
<?php |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
/** |
| 97 |
* Display the table |
| 98 |
* |
| 99 |
* @since 4.4.8 |
| 100 |
* @access public |
| 101 |
*/ |
| 102 |
public function display() { |
| 103 |
|
| 104 |
$this->prepare_items(); |
| 105 |
$singular = $this->_args['singular']; |
| 106 |
?> |
| 107 |
<form id="posts-filter" method="get"> |
| 108 |
<p class="search-box"> |
| 109 |
<label class="screen-reader-text" |
| 110 |
for="post-search-input"><?php esc_html_e( 'Search', 'rsvp-plugin' ); ?></label> |
| 111 |
<input type="hidden" name="page" value="rsvp-pro-top-level"> |
| 112 |
<input type="search" id="post-search-input" name="s" |
| 113 |
value="<?php echo( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ? $_GET['s'] : '' ) ?>"> |
| 114 |
<input type="submit" id="search-submit" class="button" |
| 115 |
value="<?php esc_html_e( 'Search event', 'rsvp-plugin' ); ?>"> |
| 116 |
|
| 117 |
</p> |
| 118 |
<?php |
| 119 |
$this->display_tablenav( 'top' ); |
| 120 |
?> |
| 121 |
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
| 122 |
<thead> |
| 123 |
<tr> |
| 124 |
<?php $this->print_column_headers(); ?> |
| 125 |
</tr> |
| 126 |
</thead> |
| 127 |
|
| 128 |
<tbody id="the-list"<?php |
| 129 |
if ( $singular ) { |
| 130 |
echo " data-wp-lists='list:$singular'"; |
| 131 |
} ?>> |
| 132 |
<?php $this->display_rows_or_placeholder(); ?> |
| 133 |
</tbody> |
| 134 |
|
| 135 |
<tfoot> |
| 136 |
<tr> |
| 137 |
<?php $this->print_column_headers( false ); ?> |
| 138 |
</tr> |
| 139 |
</tfoot> |
| 140 |
|
| 141 |
</table> |
| 142 |
<?php |
| 143 |
$this->display_tablenav( 'bottom' ); |
| 144 |
?> |
| 145 |
</form> |
| 146 |
<?php |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
/** |
| 151 |
* The Attendees column output |
| 152 |
* |
| 153 |
* @param $item |
| 154 |
* |
| 155 |
* @since 4.4.8 |
| 156 |
*/ |
| 157 |
public function column_attendees( $item ) { |
| 158 |
$url = add_query_arg( array( |
| 159 |
'page' => 'rsvp-top-level', |
| 160 |
), admin_url( 'admin.php' ) ); |
| 161 |
?> |
| 162 |
<a href="<?php echo esc_url( $url ); ?>" |
| 163 |
title="Manage Attendees"><?php esc_html_e( 'Manage Attendees', 'rsvp-plugin' ) ?></a> |
| 164 |
<?php |
| 165 |
$actions = array(); |
| 166 |
$actions = apply_filters( 'rsvp_pro_attendees_actions', $actions, $item ); |
| 167 |
echo $this->row_actions( $actions ); |
| 168 |
} |
| 169 |
|
| 170 |
/** |
| 171 |
* The Attendees column output |
| 172 |
* |
| 173 |
* @param $item |
| 174 |
* |
| 175 |
* @since 4.4.8 |
| 176 |
*/ |
| 177 |
public function column_event_name( $item ) { |
| 178 |
|
| 179 |
$links = array( |
| 180 |
'custom_questions' => array( |
| 181 |
'placeholder' => esc_html__( 'Custom Questions', 'rsvp-plugin' ), |
| 182 |
'url_vals' => array( |
| 183 |
'page' => 'rsvp-admin-questions', |
| 184 |
), |
| 185 |
), |
| 186 |
); |
| 187 |
|
| 188 |
$actions = array(); |
| 189 |
|
| 190 |
foreach ( $links as $key => $link ) { |
| 191 |
$url = add_query_arg( $link['url_vals'], admin_url( 'admin.php' ) ); |
| 192 |
$actions[ $key ] = "<a href='" . esc_url( $url ) . "' >" . esc_html( $link['placeholder'] ) . '</a>'; |
| 193 |
} |
| 194 |
|
| 195 |
$actions = apply_filters( 'rsvp_event_name_actions', $actions, $item ); |
| 196 |
echo $item; |
| 197 |
echo $this->row_actions( $actions ); |
| 198 |
} |
| 199 |
|
| 200 |
} |