PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmEntriesListHelper.php +65 -176 6.5.33.06.06 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmEntriesListHelper extends FrmListHelper {
7 4 protected $column_name;
8 5 protected $item;
@@ -7,31 +4,23 @@
7 4 protected $column_name;
8 5 protected $item;
9 6 protected $field;
10 7
11 - /**
12 - * @since 4.07
13 - */
14 - public $total_items = 0;
15 -
16 - /**
17 - * @return void
18 - */
19 8 public function prepare_items() {
20 - global $per_page;
9 + global $per_page;
21 10
22 11 $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
23 - $form_id = $this->params['form'];
12 + $form_id = $this->params['form'];
24 13
25 14 $s_query = array();
26 15
27 16 if ( $form_id ) {
28 17 $s_query['it.form_id'] = $form_id;
29 - $join_form_in_query = false;
18 + $join_form_in_query = false;
30 19 } else {
31 - $s_query[] = array(
32 - 'or' => 1,
33 - 'parent_form_id' => null,
20 + $s_query[] = array(
21 + 'or' => 1,
22 + 'parent_form_id' => null,
34 23 'parent_form_id <' => 1,
35 24 );
36 25 $join_form_in_query = true;
37 26 }
@@ -43,9 +32,9 @@
43 32 )
44 33 );
45 34
46 35 if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
47 - $fid = self::get_param( array( 'param' => 'fid' ) );
36 + $fid = self::get_param( array( 'param' => 'fid' ) );
48 37 $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
49 38 }
50 39
51 40 $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) );
@@ -51,9 +40,9 @@
51 40 $s_query = apply_filters( 'frm_entries_list_query', $s_query, compact( 'form_id' ) );
52 41
53 42 $orderby = self::get_param(
54 43 array(
55 - 'param' => 'orderby',
44 + 'param' => 'orderby',
56 45 'default' => 'id',
57 46 )
58 47 );
59 48
@@ -58,9 +47,9 @@
58 47 );
59 48
60 49 if ( strpos( $orderby, 'meta' ) !== false ) {
61 50 $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
62 - $orderby .= in_array( $order_field_type, array( 'number', 'scale', 'star' ) ) ? '+0' : '';
51 + $orderby .= in_array( $order_field_type, array( 'number', 'scale', 'star' ) ) ? '+0' : '';
63 52 }
64 53
65 54 $order = self::get_param(
66 55 array(
@@ -69,9 +58,9 @@
69 58 )
70 59 );
71 60 $order = FrmDb::esc_order( $orderby . ' ' . $order );
72 61
73 - $page = $this->get_pagenum();
62 + $page = $this->get_pagenum();
74 63 $start = (int) self::get_param(
75 64 array(
76 65 'param' => 'start',
77 66 'default' => ( $page - 1 ) * $per_page,
@@ -77,107 +66,71 @@
77 66 'default' => ( $page - 1 ) * $per_page,
78 67 )
79 68 );
80 69
81 - $limit = FrmDb::esc_limit( $start . ',' . $per_page );
70 + $limit = FrmDb::esc_limit( $start . ',' . $per_page );
82 71 $this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
83 72 $total_items = FrmEntry::getRecordCount( $s_query );
84 - $this->total_items = $total_items;
85 73
86 74 $this->set_pagination_args(
87 75 array(
88 76 'total_items' => $total_items,
89 - 'per_page' => $per_page,
77 + 'per_page' => $per_page,
90 78 )
91 79 );
92 80 }
93 81
94 - /**
95 - * @return void
96 - */
97 82 public function no_items() {
98 83 $s = self::get_param(
99 84 array(
100 - 'param' => 's',
85 + 'param' => 's',
101 86 'sanitize' => 'sanitize_text_field',
102 87 )
103 88 );
104 89 if ( ! empty( $s ) ) {
105 90 esc_html_e( 'No Entries Found', 'formidable' );
91 + return;
92 + }
106 93
107 - return;
108 - }
109 -
110 94 $form_id = $this->params['form'];
111 - $form = $this->params['form'];
95 + $form = $this->params['form'];
112 96
113 - if ( $form_id ) {
97 + if ( $form_id ) {
114 98 $form = FrmForm::getOne( $form_id );
115 - }
116 - $has_form = ! empty( $form );
99 + }
100 + $colspan = $this->get_column_count();
117 101
118 - if ( ! $has_form ) {
119 - $has_form = FrmForm::getAll( array(), '', 1 );
120 - $has_form = ! empty( $has_form );
121 - }
122 -
123 - $colspan = $this->get_column_count();
124 -
125 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php';
102 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
126 103 }
127 104
128 - /**
129 - * @return void
130 - */
131 105 public function search_box( $text, $input_id ) {
132 106 // Searching is a pro feature
133 107 }
134 108
135 - /**
136 - * @return void
137 - */
138 - protected function display_tablenav( $which ) {
139 - $is_footer = ( $which !== 'top' );
140 - if ( $is_footer && ! empty( $this->items ) ) {
141 - ?>
142 - <p>
143 - <?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?>
144 - <a href="https://formidableforms.com/knowledgebase/add-spam-protection/" target="_blank">
145 - <?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?>
146 - </a>
147 - </p>
148 - <?php
149 - }
150 - parent::display_tablenav( $which );
151 - }
152 -
153 - /**
154 - * @return void
155 - */
156 109 protected function extra_tablenav( $which ) {
157 110 $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
158 - if ( $which === 'top' && ! $form_id ) {
111 + if ( $which == 'top' && empty( $form_id ) ) {
159 112 echo '<div class="alignleft actions">';
160 113
161 114 // Override the referrer to prevent it from being used for the screen options.
162 115 echo '<input type="hidden" name="_wp_http_referer" value="" />';
163 116
164 - FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
165 - submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
117 + echo FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) ); // WPCS: XSS ok.
118 + submit_button( __( 'Filter', 'formidable' ), 'filter_action', '', false, array( 'id' => 'post-query-submit' ) );
166 119 echo '</div>';
167 120 }
168 121 }
169 122
170 123 /**
171 - * Gets the name of the primary column in the Entries screen
172 - *
173 - * @since 2.0.14
174 - *
175 - * @return string $primary_column
176 - */
124 + * Gets the name of the primary column in the Entries screen
125 + *
126 + * @since 2.0.14
127 + *
128 + * @return string $primary_column
129 + */
177 130 protected function get_primary_column_name() {
178 131 $columns = get_column_headers( $this->screen );
179 - $hidden = get_hidden_columns( $this->screen );
132 + $hidden = get_hidden_columns( $this->screen );
180 133
181 134 $primary_column = '';
182 135
183 136 foreach ( $columns as $column_key => $column_display_name ) {
@@ -189,19 +142,16 @@
189 142
190 143 return $primary_column;
191 144 }
192 145
193 - /**
194 - * @return string
195 - */
196 146 public function single_row( $item, $style = '' ) {
197 147 // Set up the hover actions for this user
198 - $actions = array();
148 + $actions = array();
199 149 $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
200 150
201 151 $this->get_actions( $actions, $item, $view_link );
202 152
203 - $action_links = $this->row_actions( $actions );
153 + $action_links = $this->row_actions( $actions );
204 154
205 155 // Set up the checkbox ( because the user is editable, otherwise its empty )
206 156 $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
207 157
@@ -207,10 +157,9 @@
207 157
208 158 $r = "<tr id='item-action-{$item->id}'$style>";
209 159
210 160 list( $columns, $hidden, , $primary ) = $this->get_column_info();
211 - $action_col = false;
212 - $action_columns = $this->get_action_columns();
161 + $action_col = false;
213 162
214 163 foreach ( $columns as $column_name => $column_display_name ) {
215 164 $class = $column_name . ' column-' . $column_name;
216 165
@@ -217,39 +166,39 @@
217 166 if ( $column_name === $primary ) {
218 167 $class .= ' column-primary';
219 168 }
220 169
221 - if ( in_array( $column_name, $hidden, true ) ) {
170 + if ( in_array( $column_name, $hidden ) ) {
222 171 $class .= ' frm_hidden';
223 - } elseif ( ! $action_col && ! in_array( $column_name, $action_columns, true ) ) {
224 - $action_col = $column_name;
225 - }
172 + } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
173 + $action_col = $column_name;
174 + }
226 175
227 176 $attributes = 'class="' . esc_attr( $class ) . '"';
228 177 unset( $class );
229 178 $attributes .= ' data-colname="' . $column_display_name . '"';
230 179
231 - $form_id = $this->params['form'] ? $this->params['form'] : 0;
180 + $form_id = $this->params['form'] ? $this->params['form'] : 0;
232 181 $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name );
233 182
234 - if ( $this->column_name === 'cb' ) {
183 + if ( $this->column_name == 'cb' ) {
235 184 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
236 185 } else {
237 - if ( in_array( $column_name, $hidden, true ) ) {
186 + if ( in_array( $column_name, $hidden ) ) {
238 187 $val = '';
239 188 } else {
240 189 $val = $this->column_value( $item );
241 190 }
242 191
243 - $r .= "<td $attributes>";
192 + $r .= "<td $attributes>";
244 193 if ( $column_name == $action_col ) {
245 - $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
246 - $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
247 - $r .= $action_links;
194 + $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
195 + $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
196 + $r .= $action_links;
248 197 } else {
249 - $r .= $val;
250 - }
251 - $r .= '</td>';
198 + $r .= $val;
199 + }
200 + $r .= '</td>';
252 201 }
253 202 unset( $val );
254 203 }
255 204 $r .= '</tr>';
@@ -256,20 +205,8 @@
256 205
257 206 return $r;
258 207 }
259 208
260 - /**
261 - * Get the column names that the logged in user can action on
262 - *
263 - * @return string[]
264 - */
265 - private function get_action_columns() {
266 - return array( 'cb', 'form_id', 'id', 'post_id' );
267 - }
268 -
269 - /**
270 - * @param object $item
271 - */
272 209 private function column_value( $item ) {
273 210 $col_name = $this->column_name;
274 211
275 212 switch ( $col_name ) {
@@ -278,31 +215,21 @@
278 215 case 'item_key':
279 216 $val = $item->{$col_name};
280 217 break;
281 218 case 'name':
219 + case 'description':
282 220 $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name} ), 100 );
283 221 break;
284 222 case 'created_at':
285 223 case 'updated_at':
286 224 $date = FrmAppHelper::get_formatted_time( $item->{$col_name} );
287 - $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
225 + $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
288 226 break;
289 227 case 'is_draft':
290 - $entry_status = FrmEntriesHelper::get_entry_status_label( $item->is_draft );
291 - $val = sprintf(
292 - '<span class="frm-entry-status frm-entry-status-%s">%s</span>',
293 - sanitize_html_class( $item->is_draft ),
294 - esc_html( $entry_status )
295 - );
228 + $val = empty( $item->is_draft ) ? esc_html__( 'No', 'formidable' ) : esc_html__( 'Yes', 'formidable' );
296 229 break;
297 230 case 'form_id':
298 - $form_id = $item->form_id;
299 - $user_can_edit_forms = false === FrmAppHelper::permission_nonce_error( 'frm_edit_forms' );
300 - if ( $user_can_edit_forms ) {
301 - $val = FrmFormsHelper::edit_form_link( $form_id );
302 - } else {
303 - $val = FrmFormsHelper::edit_form_link_label( $form_id );
304 - }
231 + $val = FrmFormsHelper::edit_form_link( $item->form_id );
305 232 break;
306 233 case 'post_id':
307 234 $val = FrmAppHelper::post_edit_link( $item->post_id );
308 235 break;
@@ -307,9 +234,9 @@
307 234 $val = FrmAppHelper::post_edit_link( $item->post_id );
308 235 break;
309 236 case 'user_id':
310 237 $user = get_userdata( $item->user_id );
311 - $val = $user ? $user->user_login : '';
238 + $val = $user ? $user->user_login : '';
312 239 break;
313 240 case 'parent_item_id':
314 241 $val = $item->parent_item_id;
315 242 break;
@@ -317,51 +244,32 @@
317 244 $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
318 245 if ( $val === false ) {
319 246 $this->get_column_value( $item, $val );
320 247 }
321 -
322 - /**
323 - * Allows changing entries list column value.
324 - *
325 - * @since 5.1
326 - *
327 - * @param mixed $val Column value.
328 - * @param array $args Contains `item` and `col_name`.
329 - */
330 - $val = apply_filters( 'frm_entries_column_value', $val, compact( 'item', 'col_name' ) );
331 248 }
332 249
333 250 return $val;
334 251 }
335 252
336 - /**
337 - * @param string $view_link
338 - * @param array $actions
339 - * @param object $item
340 - *
341 - * @return void
342 - */
343 - private function get_actions( &$actions, $item, $view_link ) {
253 + /**
254 + * @param string $view_link
255 + */
256 + private function get_actions( &$actions, $item, $view_link ) {
344 257 $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
345 258
346 259 if ( current_user_can( 'frm_delete_entries' ) ) {
347 - $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
348 - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . __( 'Delete', 'formidable' ) . '</a>';
349 - }
260 + $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
261 + $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete', 'formidable' ) . '</a>';
262 + }
350 263
351 264 $actions = apply_filters( 'frm_row_actions', $actions, $item );
352 - }
265 + }
353 266
354 - /**
355 - * @param false $val
356 - *
357 - * @return void
358 - */
359 267 private function get_column_value( $item, &$val ) {
360 268 $col_name = $this->column_name;
361 269
362 270 if ( strpos( $col_name, 'frmsep_' ) === 0 ) {
363 - $sep_val = true;
271 + $sep_val = true;
364 272 $col_name = str_replace( 'frmsep_', '', $col_name );
365 273 } else {
366 274 $sep_val = false;
367 275 }
@@ -375,12 +283,12 @@
375 283 return;
376 284 }
377 285
378 286 $atts = array(
379 - 'type' => $field->type,
380 - 'truncate' => true,
381 - 'post_id' => $item->post_id,
382 - 'entry_id' => $item->id,
287 + 'type' => $field->type,
288 + 'truncate' => true,
289 + 'post_id' => $item->post_id,
290 + 'entry_id' => $item->id,
383 291 'embedded_field_id' => 0,
384 292 );
385 293
386 294 if ( $sep_val ) {
@@ -392,25 +300,6 @@
392 300 unset( $embedded_field_id );
393 301 }
394 302
395 303 $val = FrmEntriesHelper::prepare_display_value( $item, $field, $atts );
396 - }
397 -
398 - /**
399 - * @return string
400 - */
401 - protected function confirm_bulk_delete() {
402 - return sprintf(
403 - /* translators: %1$s: HTML break line, %2$s: HTML bold text */
404 - esc_html__( 'ALL entries in this form will be permanently deleted.%1$sWant to proceed? Type %2$s below.', 'formidable' ),
405 - '<br/>',
406 - '<b>DELETE ALL</b>'
407 - );
408 - }
409 -
410 - /**
411 - * @return string
412 - */
413 - protected function loaded_from() {
414 - return 'entries-list';
415 304 }
416 305 }