PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.9.9
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.9.9
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 3 years ago plugin-updates 8 years ago settings 3 years ago views 3 years ago class-evf-admin-addons.php 4 years ago class-evf-admin-assets.php 3 years ago class-evf-admin-builder.php 8 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 5 years ago class-evf-admin-notices.php 3 years ago class-evf-admin-settings.php 3 years ago class-evf-admin-tools.php 4 years ago class-evf-admin-welcome.php 5 years ago class-evf-admin.php 3 years ago evf-admin-functions.php 3 years ago
class-evf-admin-forms-table-list.php
582 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
213 $row_actions = array();
214
215 foreach ( $actions as $action => $link ) {
216 $row_actions[] = '<span class="' . esc_attr( $action ) . '">' . $link . '</span>';
217 }
218
219 $output .= '<div class="row-actions">' . implode( ' | ', $row_actions ) . '</div>';
220
221 return $output;
222 }
223
224 /**
225 * Return shortcode column.
226 *
227 * @param object $posts Form object.
228 */
229 public function column_shortcode( $posts ) {
230 ?>
231 <span class="shortcode evf-shortcode-field">
232 <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo esc_attr( '[everest_form id="' . absint( $posts->ID ) . '"]' ); ?> " class="large-text code">
233 <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' ); ?>">
234 <span class="dashicons dashicons-admin-page"></span>
235 </button>
236 </span>
237 <?php
238 }
239
240 /**
241 * Return author column.
242 *
243 * @param object $posts Form object.
244 * @return string
245 */
246 public function column_author( $posts ) {
247 $user = get_user_by( 'id', $posts->post_author );
248
249 if ( ! $user ) {
250 return '<span class="na">&ndash;</span>';
251 }
252
253 $user_name = ! empty( $user->data->display_name ) ? $user->data->display_name : $user->data->user_login;
254
255 if ( current_user_can( 'edit_user' ) ) {
256 return '<a href="' . esc_url(
257 add_query_arg(
258 array(
259 'user_id' => $user->ID,
260 ),
261 admin_url( 'user-edit.php' )
262 )
263 ) . '">' . esc_html( $user_name ) . '</a>';
264 }
265
266 return esc_html( $user_name );
267 }
268
269 /**
270 * Return date column.
271 *
272 * @param object $posts Form object.
273 * @return string
274 */
275 public function column_date( $posts ) {
276 $post = get_post( $posts->ID );
277
278 if ( ! $post ) {
279 return;
280 }
281
282 $t_time = mysql2date(
283 __( 'Y/m/d g:i:s A', 'everest-forms' ),
284 $post->post_date,
285 true
286 );
287 $m_time = $post->post_date;
288 $time = mysql2date( 'G', $post->post_date ) - get_option( 'gmt_offset' ) * 3600;
289
290 $time_diff = time() - $time;
291
292 if ( $time_diff > 0 && $time_diff < 24 * 60 * 60 ) {
293 $h_time = sprintf(
294 /* translators: %s: Time */
295 __( '%s ago', 'everest-forms' ),
296 human_time_diff( $time )
297 );
298 } else {
299 $h_time = mysql2date( __( 'Y/m/d', 'everest-forms' ), $m_time );
300 }
301
302 return '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
303 }
304
305 /**
306 * Return entries count.
307 *
308 * @param object $posts Form object.
309 * @return string
310 */
311 public function column_entries( $posts ) {
312 global $wpdb;
313
314 if ( ! current_user_can( 'everest_forms_view_form_entries', $posts->ID ) ) {
315 return '-';
316 }
317
318 $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.
319
320 if ( isset( $_GET['status'] ) && 'trash' === $_GET['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
321 return '<strong>' . absint( $entries ) . '</strong>';
322 } else {
323 return '<a href="' . esc_url( admin_url( 'admin.php?page=evf-entries&amp;form_id=' . $posts->ID ) ) . '">' . absint( $entries ) . '</a>';
324 }
325 }
326
327 /**
328 * Table list views.
329 *
330 * @return array
331 */
332 protected function get_views() {
333 $class = '';
334 $status_links = array();
335 $num_posts = array();
336 $total_posts = count( $this->items );
337 $all_args = array( 'page' => 'evf-builder' );
338
339 if ( empty( $class ) && empty( $_REQUEST['status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
340 $class = 'current';
341 }
342
343 $all_inner_html = sprintf(
344 /* translators: %s: count */
345 _nx(
346 'All <span class="count">(%s)</span>',
347 'All <span class="count">(%s)</span>',
348 $total_posts,
349 'posts',
350 'everest-forms'
351 ),
352 number_format_i18n( $total_posts )
353 );
354
355 $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
356
357 foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
358 $class = '';
359 $status_name = $status->name;
360 $num_posts[ $status_name ] = count( evf()->form->get_multiple( array( 'post_status' => $status_name ) ) );
361
362 if ( ! in_array( $status_name, array( 'publish', 'draft', 'pending', 'trash', 'future', 'private', 'auto-draft' ), true ) || empty( $num_posts[ $status_name ] ) ) {
363 continue;
364 }
365
366 if ( isset( $_REQUEST['status'] ) && $status_name === $_REQUEST['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
367 $class = 'current';
368 }
369
370 $status_args = array(
371 'page' => 'evf-builder',
372 'status' => $status_name,
373 );
374
375 $status_label = sprintf(
376 translate_nooped_plural( $status->label_count, $num_posts[ $status_name ] ),
377 number_format_i18n( $num_posts[ $status_name ] )
378 );
379
380 $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class );
381 }
382
383 return $status_links;
384 }
385
386 /**
387 * Helper to create links to admin.php with params.
388 *
389 * @since 1.5.3
390 *
391 * @param string[] $args Associative array of URL parameters for the link.
392 * @param string $label Link text.
393 * @param string $class Optional. Class attribute. Default empty string.
394 * @return string The formatted link string.
395 */
396 protected function get_edit_link( $args, $label, $class = '' ) {
397 $url = add_query_arg( $args, 'admin.php' );
398
399 $class_html = '';
400 $aria_current = '';
401
402 if ( ! empty( $class ) ) {
403 $class_html = sprintf(
404 ' class="%s"',
405 esc_attr( $class )
406 );
407
408 if ( 'current' === $class ) {
409 $aria_current = ' aria-current="page"';
410 }
411 }
412
413 return sprintf(
414 '<a href="%s"%s%s>%s</a>',
415 esc_url( $url ),
416 $class_html,
417 $aria_current,
418 $label
419 );
420 }
421
422 /**
423 * Get bulk actions.
424 *
425 * @return array
426 */
427 protected function get_bulk_actions() {
428 $actions = array();
429
430 if ( isset( $_GET['status'] ) && 'trash' === $_GET['status'] ) { // phpcs:ignore WordPress.Security.NonceVerification
431 if ( current_user_can( 'everest_forms_edit_forms' ) ) {
432 $actions['untrash'] = esc_html__( 'Restore', 'everest-forms' );
433 }
434
435 if ( current_user_can( 'everest_forms_delete_forms' ) ) {
436 $actions['delete'] = esc_html__( 'Delete permanently', 'everest-forms' );
437 }
438 } elseif ( current_user_can( 'everest_forms_delete_forms' ) ) {
439 $actions = array(
440 'trash' => esc_html__( 'Move to trash', 'everest-forms' ),
441 );
442 }
443
444 return $actions;
445 }
446
447 /**
448 * Process bulk actions.
449 *
450 * @since 1.2.0
451 */
452 public function process_bulk_action() {
453 $action = $this->current_action();
454 $form_ids = isset( $_REQUEST['form_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['form_id'] ) ) : array(); // phpcs:ignore WordPress.Security.NonceVerification
455 $count = 0;
456
457 if ( $form_ids ) {
458 check_admin_referer( 'bulk-forms' );
459 }
460
461 switch ( $action ) {
462 case 'trash':
463 foreach ( $form_ids as $form_id ) {
464 if ( wp_trash_post( $form_id ) ) {
465 $count ++;
466 }
467 }
468
469 add_settings_error(
470 'bulk_action',
471 'bulk_action',
472 /* translators: %d: number of forms */
473 sprintf( _n( '%d form moved to the Trash.', '%d forms moved to the Trash.', $count, 'everest-forms' ), $count ),
474 'updated'
475 );
476 break;
477 case 'untrash':
478 foreach ( $form_ids as $form_id ) {
479 if ( wp_untrash_post( $form_id ) ) {
480 $count ++;
481 }
482 }
483
484 add_settings_error(
485 'bulk_action',
486 'bulk_action',
487 /* translators: %d: number of forms */
488 sprintf( _n( '%d form restored from the Trash.', '%d forms restored from the Trash.', $count, 'everest-forms' ), $count ),
489 'updated'
490 );
491 break;
492 case 'delete':
493 foreach ( $form_ids as $form_id ) {
494 if ( wp_delete_post( $form_id, true ) ) {
495 $count ++;
496 }
497 }
498
499 add_settings_error(
500 'bulk_action',
501 'bulk_action',
502 /* translators: %d: number of forms */
503 sprintf( _n( '%d form permanently deleted.', '%d forms permanently deleted.', $count, 'everest-forms' ), $count ),
504 'updated'
505 );
506 break;
507 }
508 }
509
510 /**
511 * Extra controls to be displayed between bulk actions and pagination.
512 *
513 * @param string $which The location of the extra table nav markup.
514 */
515 protected function extra_tablenav( $which ) {
516 $num_posts = wp_count_posts( 'everest_form', 'readable' );
517
518 if ( $num_posts->trash && isset( $_GET['status'] ) && 'trash' === $_GET['status'] && current_user_can( 'everest_forms_delete_forms' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
519 echo '<div class="alignleft actions">';
520 submit_button( __( 'Empty Trash', 'everest-forms' ), 'apply', 'delete_all', false );
521 echo '</div>';
522 }
523 }
524
525 /**
526 * Prepare table list items.
527 */
528 public function prepare_items() {
529 $user_id = get_current_user_id();
530 $per_page = $this->get_items_per_page( 'evf_forms_per_page' );
531 $current_page = $this->get_pagenum();
532
533 // Query args.
534 $args = array(
535 'post_type' => 'everest_form',
536 'posts_per_page' => $per_page,
537 'paged' => $current_page,
538 'no_found_rows' => false,
539 'ignore_sticky_posts' => true,
540 );
541
542 // Handle the status query.
543 if ( ! empty( $_REQUEST['status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
544 $args['post_status'] = sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
545 }
546
547 // Handle the search query.
548 if ( ! empty( $_REQUEST['s'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
549 $args['s'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
550 }
551
552 $args['orderby'] = isset( $_REQUEST['orderby'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ) : 'date_created'; // phpcs:ignore WordPress.Security.NonceVerification
553 $args['order'] = isset( $_REQUEST['order'] ) && 'ASC' === strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ) ? 'ASC' : 'DESC'; // phpcs:ignore WordPress.Security.NonceVerification
554
555 // Can user interact, lets check the view capabilities?
556 if ( current_user_can( 'everest_forms_view_forms' ) && ! current_user_can( 'everest_forms_view_others_forms' ) ) {
557 $args['author'] = $user_id;
558 }
559
560 if ( ! current_user_can( 'everest_forms_view_forms' ) && current_user_can( 'everest_forms_view_others_forms' ) ) {
561 $args['author__not_in'] = $user_id;
562 }
563
564 if ( ! current_user_can( 'everest_forms_view_forms' ) && ! current_user_can( 'everest_forms_view_others_forms' ) ) {
565 $args['post__in'] = array( 0 );
566 }
567
568 // Get the forms.
569 $posts = new WP_Query( $args );
570 $this->items = $posts->posts;
571
572 // Set the pagination.
573 $this->set_pagination_args(
574 array(
575 'total_items' => $posts->found_posts,
576 'per_page' => $per_page,
577 'total_pages' => $posts->max_num_pages,
578 )
579 );
580 }
581 }
582