PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 2.0.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v2.0.3
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / admin / class-evf-admin-forms-table-list.php
everest-forms / includes / admin Last commit date
builder 2 years ago plugin-updates 8 years ago settings 2 years ago views 2 years ago class-evf-admin-addons.php 4 years ago class-evf-admin-assets.php 2 years ago class-evf-admin-builder.php 7 years ago class-evf-admin-deactivation-feedback.php 3 years ago class-evf-admin-editor.php 4 years ago class-evf-admin-entries-table-list.php 3 years ago class-evf-admin-entries.php 4 years ago class-evf-admin-form-templates.php 3 years ago class-evf-admin-forms-table-list.php 3 years ago class-evf-admin-forms.php 3 years ago class-evf-admin-import-export.php 4 years ago class-evf-admin-menus.php 2 years ago class-evf-admin-notices.php 3 years ago class-evf-admin-settings.php 2 years ago class-evf-admin-tools.php 4 years ago class-evf-admin-welcome.php 2 years ago class-evf-admin.php 2 years ago evf-admin-functions.php 3 years ago
class-evf-admin-forms-table-list.php
586 lines
1 <?php
2 /**
3 * EverestForms Forms Table List
4 *
5 * @package EverestForms\Admin
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 if ( ! class_exists( 'WP_List_Table' ) ) {
12 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 }
14
15 /**
16 * Forms table list class.
17 */
18 class EVF_Admin_Forms_Table_List extends WP_List_Table {
19
20 /**
21 * Initialize the form table list.
22 */
23 public function __construct() {
24 parent::__construct(
25 array(
26 'singular' => 'form',
27 'plural' => 'forms',
28 'ajax' => false,
29 )
30 );
31 }
32
33 /**
34 * No items found text.
35 */
36 public function no_items() {
37 esc_html_e( 'No Forms found.', 'everest-forms' );
38 }
39
40 /**
41 * Get list columns.
42 *
43 * @return array
44 */
45 public function get_columns() {
46 $forms_columns = array(
47 'cb' => '<input type="checkbox" />',
48 'enabled' => '',
49 'title' => esc_html__( 'Title', 'everest-forms' ),
50 'shortcode' => esc_html__( 'Shortcode', 'everest-forms' ),
51 'author' => esc_html__( 'Author', 'everest-forms' ),
52 'date' => esc_html__( 'Date', 'everest-forms' ),
53 );
54
55 // Hide form enabled toggle if in trash page.
56 if ( isset( $_GET['status'] ) && 'trash' === $_GET['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
57 unset( $forms_columns['enabled'] );
58 }
59
60 // Only show entries column if the user can view entries.
61 if ( current_user_can( 'everest_forms_view_entries' ) || current_user_can( 'everest_forms_view_others_entries' ) ) {
62 $forms_columns['entries'] = esc_html__( 'Entries', 'everest-forms' );
63 }
64
65 // Only "Move to trash" bulk action exist, lets hide cb if the user cannot delete forms.
66 if ( isset( $_GET['status'] ) && 'trash' !== $_GET['status'] && ! current_user_can( 'everest_forms_delete_forms' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
67 unset( $forms_columns['cb'] );
68 }
69
70 return $forms_columns;
71 }
72
73 /**
74 * Get a list of sortable columns.
75 *
76 * @return array
77 */
78 protected function get_sortable_columns() {
79 return array(
80 'title' => array( 'title', false ),
81 'author' => array( 'author', false ),
82 'date' => array( 'date', false ),
83 );
84 }
85
86 /**
87 * Column cb.
88 *
89 * @param object $form Form object.
90 * @return string
91 */
92 public function column_cb( $form ) {
93 $show = current_user_can( 'everest_forms_edit_form', $form->ID );
94 $delete = current_user_can( 'everest_forms_delete_form', $form->ID );
95
96 /**
97 * Filters whether to show the bulk edit checkbox for a form in its list table.
98 *
99 * By default the checkbox is only shown if the current user can edit the form.
100 *
101 * @since 1.7.5
102 *
103 * @param bool $show Whether to show the checkbox.
104 * @param WP_Post $post The current WP_Post object.
105 */
106 if ( apply_filters( 'everest_forms_list_table_show_form_checkbox', $show, $form ) || apply_filters( 'everest_forms_list_table_delete_form_checkbox', $delete, $form ) ) {
107 return sprintf( '<input type="checkbox" name="form_id[]" value="%1$s" />', esc_attr( $form->ID ) );
108 }
109 }
110
111 /**
112 * Column enabled.
113 *
114 * @param object $posts Form object.
115 * @return string
116 */
117 public function column_enabled( $posts ) {
118 $form_data = evf()->form->get( absint( $posts->ID ), array( 'content_only' => true ) );
119 $form_enabled = isset( $form_data['form_enabled'] ) ? $form_data['form_enabled'] : 1;
120
121 if ( current_user_can( 'everest_forms_edit_form', $posts->ID ) ) {
122 return '<label class="everest-forms-toggle-form form-enabled"><input type="checkbox" data-form_id="' . absint( $posts->ID ) . '" value="1" ' . checked( 1, $form_enabled, false ) . '/><span class="slider round"></span></label>';
123 }
124 }
125
126 /**
127 * Return title column.
128 *
129 * @param object $posts Form object.
130 * @return string
131 */
132 public function column_title( $posts ) {
133 $edit_link = admin_url( 'admin.php?page=evf-builder&tab=fields&form_id=' . $posts->ID );
134 $preview_link = add_query_arg(
135 array(
136 'form_id' => absint( $posts->ID ),
137 'evf_preview' => 'true',
138 ),
139 home_url()
140 );
141 $title = _draft_or_post_title( $posts->ID );
142 $post_type_object = get_post_type_object( 'everest_form' );
143 $post_status = $posts->post_status;
144 $form_data = ! empty( $posts->post_content ) ? evf_decode( $posts->post_content ) : array();
145 // Title.
146 $output = '<strong>';
147 if ( 'trash' === $post_status ) {
148 $output .= esc_html( $title );
149 } else {
150 $name = esc_html( $title );
151
152 if ( current_user_can( 'everest_forms_view_form', $posts->ID ) ) {
153 $name = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_html__( 'View Preview', 'everest-forms' ) . '" class="row-title" target="_blank" rel="noopener noreferrer">' . esc_html( $title ) . '</a>';
154 }
155
156 if ( current_user_can( 'everest_forms_view_form_entries', $posts->ID ) ) {
157 $name = '<a href="' . esc_url( esc_url( admin_url( 'admin.php?page=evf-entries&amp;form_id=' . $posts->ID ) ) ) . '" title="' . esc_html__( 'View Entries', 'everest-forms' ) . '" class="row-title">' . esc_html( $title ) . '</a>';
158 }
159
160 if ( current_user_can( 'everest_forms_edit_form', $posts->ID ) ) {
161 $name = '<a href="' . esc_url( $edit_link ) . '" title="' . esc_html__( 'Edit this Form', 'everest-forms' ) . '" class="row-title">' . esc_html( $title ) . '</a>';
162 }
163
164 $output .= $name;
165 }
166 $output .= '</strong>';
167
168 // Get actions.
169 $actions = array();
170
171 if ( current_user_can( 'everest_forms_edit_form', $posts->ID ) && 'trash' !== $post_status ) {
172 $actions['edit'] = '<a href="' . esc_url( $edit_link ) . '" title="' . esc_html__( 'Edit this Form', 'everest-forms' ) . '">' . __( 'Edit', 'everest-forms' ) . '</a>';
173 }
174
175 if ( current_user_can( 'everest_forms_view_form_entries', $posts->ID ) && 'trash' !== $post_status ) {
176 $actions['entries'] = '<a href="' . esc_url( admin_url( 'admin.php?page=evf-entries&amp;form_id=' . $posts->ID ) ) . '" title="' . esc_html__( 'View Entries', 'everest-forms' ) . '">' . __( 'Entries', 'everest-forms' ) . '</a>';
177 }
178
179 if ( current_user_can( 'everest_forms_delete_form', $posts->ID ) ) {
180 if ( 'trash' === $post_status ) {
181 $actions['untrash'] = '<a aria-label="' . esc_attr__( 'Restore this item from the Trash', 'everest-forms' ) . '" href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $posts->ID ) ), 'untrash-post_' . $posts->ID ) . '">' . esc_html__( 'Restore', 'everest-forms' ) . '</a>';
182 } elseif ( EMPTY_TRASH_DAYS ) {
183 $actions['trash'] = '<a class="submitdelete" aria-label="' . esc_attr__( 'Move this item to the Trash', 'everest-forms' ) . '" href="' . get_delete_post_link( $posts->ID ) . '">' . esc_html__( 'Trash', 'everest-forms' ) . '</a>';
184 }
185 if ( 'trash' === $post_status || ! EMPTY_TRASH_DAYS ) {
186 $actions['delete'] = '<a class="submitdelete" aria-label="' . esc_attr__( 'Delete this item permanently', 'everest-forms' ) . '" href="' . get_delete_post_link( $posts->ID, '', true ) . '">' . esc_html__( 'Delete permanently', 'everest-forms' ) . '</a>';
187 }
188 }
189
190 if ( current_user_can( 'everest_forms_view_form', $posts->ID ) ) {
191 $preview_link = add_query_arg(
192 array(
193 'form_id' => absint( $posts->ID ),
194 'evf_preview' => 'true',
195 ),
196 home_url()
197 );
198 $duplicate_link = wp_nonce_url( admin_url( 'admin.php?page=evf-builder&action=duplicate_form&form_id=' . absint( $posts->ID ) ), 'everest-forms-duplicate-form_' . $posts->ID );
199
200 if ( 'trash' !== $post_status ) {
201 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" rel="bookmark" target="_blank">' . __( 'Preview', 'everest-forms' ) . '</a>';
202 }
203
204 if ( isset( $form_data['settings']['enable_conversational_forms'] ) && $form_data['settings']['enable_conversational_forms'] ) {
205 $actions['view_conversational_forms'] = '<a href="' . esc_url( home_url( $posts->post_name ) ) . '" title="View ConversationalForm" target="_blank">' . __( 'Conversational Form Preview', 'everest-forms' ) . '</a>';
206 }
207
208 if ( 'publish' === $post_status && current_user_can( 'everest_forms_create_forms' ) ) {
209 $actions['duplicate'] = '<a href="' . esc_url( $duplicate_link ) . '">' . __( 'Duplicate', 'everest-forms' ) . '</a>';
210 }
211
212 if ( 'publish' === $post_status && current_user_can( 'everest_forms_create_forms' ) ) {
213 $actions['locate'] = '<a href="#" class="evf-form-locate" data-id= "' . esc_attr( $posts->ID ) . '">' . __( 'Locate', 'everest-forms' ) . '</a>';
214 }
215 }
216
217 $row_actions = array();
218
219 foreach ( $actions as $action => $link ) {
220 $row_actions[] = '<span class="' . esc_attr( $action ) . '">' . $link . '</span>';
221 }
222
223 $output .= '<div class="row-actions">' . implode( ' | ', $row_actions ) . '</div>';
224
225 return $output;
226 }
227
228 /**
229 * Return shortcode column.
230 *
231 * @param object $posts Form object.
232 */
233 public function column_shortcode( $posts ) {
234 ?>
235 <span class="shortcode evf-shortcode-field">
236 <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo esc_attr( '[everest_form id="' . absint( $posts->ID ) . '"]' ); ?> " class="large-text code">
237 <button class="button evf-copy-shortcode help_tip" type="button" href="#" data-tip="<?php esc_attr_e( 'Copy Shortcode!', 'everest-forms' ); ?>" data-copied="<?php esc_attr_e( 'Copied!', 'everest-forms' ); ?>">
238 <span class="dashicons dashicons-admin-page"></span>
239 </button>
240 </span>
241 <?php
242 }
243
244 /**
245 * Return author column.
246 *
247 * @param object $posts Form object.
248 * @return string
249 */
250 public function column_author( $posts ) {
251 $user = get_user_by( 'id', $posts->post_author );
252
253 if ( ! $user ) {
254 return '<span class="na">&ndash;</span>';
255 }
256
257 $user_name = ! empty( $user->data->display_name ) ? $user->data->display_name : $user->data->user_login;
258
259 if ( current_user_can( 'edit_user' ) ) {
260 return '<a href="' . esc_url(
261 add_query_arg(
262 array(
263 'user_id' => $user->ID,
264 ),
265 admin_url( 'user-edit.php' )
266 )
267 ) . '">' . esc_html( $user_name ) . '</a>';
268 }
269
270 return esc_html( $user_name );
271 }
272
273 /**
274 * Return date column.
275 *
276 * @param object $posts Form object.
277 * @return string
278 */
279 public function column_date( $posts ) {
280 $post = get_post( $posts->ID );
281
282 if ( ! $post ) {
283 return;
284 }
285
286 $t_time = mysql2date(
287 __( 'Y/m/d g:i:s A', 'everest-forms' ),
288 $post->post_date,
289 true
290 );
291 $m_time = $post->post_date;
292 $time = mysql2date( 'G', $post->post_date ) - get_option( 'gmt_offset' ) * 3600;
293
294 $time_diff = time() - $time;
295
296 if ( $time_diff > 0 && $time_diff < 24 * 60 * 60 ) {
297 $h_time = sprintf(
298 /* translators: %s: Time */
299 __( '%s ago', 'everest-forms' ),
300 human_time_diff( $time )
301 );
302 } else {
303 $h_time = mysql2date( __( 'Y/m/d', 'everest-forms' ), $m_time );
304 }
305
306 return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
307 }
308
309 /**
310 * Return entries count.
311 *
312 * @param object $posts Form object.
313 * @return string
314 */
315 public function column_entries( $posts ) {
316 global $wpdb;
317
318 if ( ! current_user_can( 'everest_forms_view_form_entries', $posts->ID ) ) {
319 return '-';
320 }
321
322 $entries = count( $wpdb->get_results( $wpdb->prepare( "SELECT form_id FROM {$wpdb->prefix}evf_entries WHERE `status` != 'trash' AND form_id = %d", $posts->ID ) ) ); // WPCS: cache ok, DB call ok.
323
324 if ( isset( $_GET['status'] ) && 'trash' === $_GET['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
325 return '<strong>' . absint( $entries ) . '</strong>';
326 } else {
327 return '<a href="' . esc_url( admin_url( 'admin.php?page=evf-entries&amp;form_id=' . $posts->ID ) ) . '">' . absint( $entries ) . '</a>';
328 }
329 }
330
331 /**
332 * Table list views.
333 *
334 * @return array
335 */
336 protected function get_views() {
337 $class = '';
338 $status_links = array();
339 $num_posts = array();
340 $total_posts = count( $this->items );
341 $all_args = array( 'page' => 'evf-builder' );
342
343 if ( empty( $class ) && empty( $_REQUEST['status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
344 $class = 'current';
345 }
346
347 $all_inner_html = sprintf(
348 /* translators: %s: count */
349 _nx(
350 'All <span class="count">(%s)</span>',
351 'All <span class="count">(%s)</span>',
352 $total_posts,
353 'posts',
354 'everest-forms'
355 ),
356 number_format_i18n( $total_posts )
357 );
358
359 $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
360
361 foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
362 $class = '';
363 $status_name = $status->name;
364 $num_posts[ $status_name ] = count( evf()->form->get_multiple( array( 'post_status' => $status_name ) ) );
365
366 if ( ! in_array( $status_name, array( 'publish', 'draft', 'pending', 'trash', 'future', 'private', 'auto-draft' ), true ) || empty( $num_posts[ $status_name ] ) ) {
367 continue;
368 }
369
370 if ( isset( $_REQUEST['status'] ) && $status_name === $_REQUEST['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
371 $class = 'current';
372 }
373
374 $status_args = array(
375 'page' => 'evf-builder',
376 'status' => $status_name,
377 );
378
379 $status_label = sprintf(
380 translate_nooped_plural( $status->label_count, $num_posts[ $status_name ] ),
381 number_format_i18n( $num_posts[ $status_name ] )
382 );
383
384 $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class );
385 }
386
387 return $status_links;
388 }
389
390 /**
391 * Helper to create links to admin.php with params.
392 *
393 * @since 1.5.3
394 *
395 * @param string[] $args Associative array of URL parameters for the link.
396 * @param string $label Link text.
397 * @param string $class Optional. Class attribute. Default empty string.
398 * @return string The formatted link string.
399 */
400 protected function get_edit_link( $args, $label, $class = '' ) {
401 $url = add_query_arg( $args, 'admin.php' );
402
403 $class_html = '';
404 $aria_current = '';
405
406 if ( ! empty( $class ) ) {
407 $class_html = sprintf(
408 ' class="%s"',
409 esc_attr( $class )
410 );
411
412 if ( 'current' === $class ) {
413 $aria_current = ' aria-current="page"';
414 }
415 }
416
417 return sprintf(
418 '<a href="%s"%s%s>%s</a>',
419 esc_url( $url ),
420 $class_html,
421 $aria_current,
422 $label
423 );
424 }
425
426 /**
427 * Get bulk actions.
428 *
429 * @return array
430 */
431 protected function get_bulk_actions() {
432 $actions = array();
433
434 if ( isset( $_GET['status'] ) && 'trash' === $_GET['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
435 if ( current_user_can( 'everest_forms_edit_forms' ) ) {
436 $actions['untrash'] = esc_html__( 'Restore', 'everest-forms' );
437 }
438
439 if ( current_user_can( 'everest_forms_delete_forms' ) ) {
440 $actions['delete'] = esc_html__( 'Delete permanently', 'everest-forms' );
441 }
442 } elseif ( current_user_can( 'everest_forms_delete_forms' ) ) {
443 $actions = array(
444 'trash' => esc_html__( 'Move to trash', 'everest-forms' ),
445 );
446 }
447
448 return $actions;
449 }
450
451 /**
452 * Process bulk actions.
453 *
454 * @since 1.2.0
455 */
456 public function process_bulk_action() {
457 $action = $this->current_action();
458 $form_ids = isset( $_REQUEST['form_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['form_id'] ) ) : array(); // phpcs:ignore WordPress.Security.NonceVerification
459 $count = 0;
460
461 if ( $form_ids ) {
462 check_admin_referer( 'bulk-forms' );
463 }
464
465 switch ( $action ) {
466 case 'trash':
467 foreach ( $form_ids as $form_id ) {
468 if ( wp_trash_post( $form_id ) ) {
469 $count ++;
470 }
471 }
472
473 add_settings_error(
474 'bulk_action',
475 'bulk_action',
476 /* translators: %d: number of forms */
477 sprintf( _n( '%d form moved to the Trash.', '%d forms moved to the Trash.', $count, 'everest-forms' ), $count ),
478 'updated'
479 );
480 break;
481 case 'untrash':
482 foreach ( $form_ids as $form_id ) {
483 if ( wp_untrash_post( $form_id ) ) {
484 $count ++;
485 }
486 }
487
488 add_settings_error(
489 'bulk_action',
490 'bulk_action',
491 /* translators: %d: number of forms */
492 sprintf( _n( '%d form restored from the Trash.', '%d forms restored from the Trash.', $count, 'everest-forms' ), $count ),
493 'updated'
494 );
495 break;
496 case 'delete':
497 foreach ( $form_ids as $form_id ) {
498 if ( wp_delete_post( $form_id, true ) ) {
499 $count ++;
500 }
501 }
502
503 add_settings_error(
504 'bulk_action',
505 'bulk_action',
506 /* translators: %d: number of forms */
507 sprintf( _n( '%d form permanently deleted.', '%d forms permanently deleted.', $count, 'everest-forms' ), $count ),
508 'updated'
509 );
510 break;
511 }
512 }
513
514 /**
515 * Extra controls to be displayed between bulk actions and pagination.
516 *
517 * @param string $which The location of the extra table nav markup.
518 */
519 protected function extra_tablenav( $which ) {
520 $num_posts = wp_count_posts( 'everest_form', 'readable' );
521
522 if ( $num_posts->trash && isset( $_GET['status'] ) && 'trash' === $_GET['status'] && current_user_can( 'everest_forms_delete_forms' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
523 echo '<div class="alignleft actions">';
524 submit_button( __( 'Empty Trash', 'everest-forms' ), 'apply', 'delete_all', false );
525 echo '</div>';
526 }
527 }
528
529 /**
530 * Prepare table list items.
531 */
532 public function prepare_items() {
533 $user_id = get_current_user_id();
534 $per_page = $this->get_items_per_page( 'evf_forms_per_page' );
535 $current_page = $this->get_pagenum();
536
537 // Query args.
538 $args = array(
539 'post_type' => 'everest_form',
540 'posts_per_page' => $per_page,
541 'paged' => $current_page,
542 'no_found_rows' => false,
543 'ignore_sticky_posts' => true,
544 );
545
546 // Handle the status query.
547 if ( ! empty( $_REQUEST['status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
548 $args['post_status'] = sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
549 }
550
551 // Handle the search query.
552 if ( ! empty( $_REQUEST['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
553 $args['s'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
554 }
555
556 $args['orderby'] = isset( $_REQUEST['orderby'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ) : 'date_created'; // phpcs:ignore WordPress.Security.NonceVerification
557 $args['order'] = isset( $_REQUEST['order'] ) && 'ASC' === strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ) ? 'ASC' : 'DESC'; // phpcs:ignore WordPress.Security.NonceVerification
558
559 // Can user interact, lets check the view capabilities?
560 if ( current_user_can( 'everest_forms_view_forms' ) && ! current_user_can( 'everest_forms_view_others_forms' ) ) {
561 $args['author'] = $user_id;
562 }
563
564 if ( ! current_user_can( 'everest_forms_view_forms' ) && current_user_can( 'everest_forms_view_others_forms' ) ) {
565 $args['author__not_in'] = $user_id;
566 }
567
568 if ( ! current_user_can( 'everest_forms_view_forms' ) && ! current_user_can( 'everest_forms_view_others_forms' ) ) {
569 $args['post__in'] = array( 0 );
570 }
571
572 // Get the forms.
573 $posts = new WP_Query( $args );
574 $this->items = $posts->posts;
575
576 // Set the pagination.
577 $this->set_pagination_args(
578 array(
579 'total_items' => $posts->found_posts,
580 'per_page' => $per_page,
581 'total_pages' => $posts->max_num_pages,
582 )
583 );
584 }
585 }
586