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/FrmFormsListHelper.php +123 -233 6.5.33.06.06 View file →
@@ -5,10 +5,8 @@
5 5
6 6 class FrmFormsListHelper extends FrmListHelper {
7 7 public $status = '';
8 8
9 - public $total_items = 0;
10 -
11 9 public function __construct( $args ) {
12 10 $this->status = self::get_param( array( 'param' => 'form_type' ) );
13 11
14 12 parent::__construct( $args );
@@ -13,15 +11,12 @@
13 11
14 12 parent::__construct( $args );
15 13 }
16 14
17 - /**
18 - * @return void
19 - */
20 15 public function prepare_items() {
21 16 global $wpdb, $per_page, $mode;
22 17
23 - $page = $this->get_pagenum();
18 + $page = $this->get_pagenum();
24 19 $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
25 20
26 21 $mode = self::get_param(
27 22 array(
@@ -49,25 +44,25 @@
49 44 );
50 45
51 46 $s_query = array(
52 47 array(
53 - 'or' => 1,
54 - 'parent_form_id' => null,
48 + 'or' => 1,
49 + 'parent_form_id' => null,
55 50 'parent_form_id <' => 1,
56 51 ),
57 52 );
58 53 switch ( $this->status ) {
59 - case 'draft':
60 - $s_query['is_template'] = 0;
61 - $s_query['status'] = 'draft';
62 - break;
63 - case 'trash':
64 - $s_query['status'] = 'trash';
65 - break;
66 - default:
67 - $s_query['is_template'] = 0;
68 - $s_query['status !'] = 'trash';
69 - break;
54 + case 'draft':
55 + $s_query['is_template'] = 0;
56 + $s_query['status'] = 'draft';
57 + break;
58 + case 'trash':
59 + $s_query['status'] = 'trash';
60 + break;
61 + default:
62 + $s_query['is_template'] = 0;
63 + $s_query['status !'] = 'trash';
64 + break;
70 65 }
71 66
72 67 $s = self::get_param(
73 68 array(
@@ -74,9 +69,9 @@
74 69 'param' => 's',
75 70 'sanitize' => 'sanitize_text_field',
76 71 )
77 72 );
78 - if ( $s != '' ) {
73 + if ( $s != '' ) {
79 74 preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
80 75 $search_terms = array_map( 'trim', $matches[0] );
81 76 foreach ( (array) $search_terms as $term ) {
82 77 $s_query[] = array(
@@ -83,18 +78,15 @@
83 78 'or' => true,
84 79 'name LIKE' => $term,
85 80 'description LIKE' => $term,
86 81 'created_at LIKE' => $term,
87 - 'form_key LIKE' => $term,
88 - 'id' => $term,
89 82 );
90 83 unset( $term );
91 84 }
92 - }
85 + }
93 86
94 87 $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
95 - $total_items = FrmDb::get_count( 'frm_forms', $s_query );
96 - $this->total_items = $total_items;
88 + $total_items = FrmDb::get_count( 'frm_forms', $s_query );
97 89
98 90 $this->set_pagination_args(
99 91 array(
100 92 'total_items' => $total_items,
@@ -102,134 +94,106 @@
102 94 )
103 95 );
104 96 }
105 97
106 - /**
107 - * @return void
108 - */
109 98 public function no_items() {
110 - if ( $this->status === 'trash' ) {
111 - echo '<p>';
112 - esc_html_e( 'No forms found in the trash.', 'formidable' );
113 - ?>
114 - <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable' ) ); ?>">
115 - <?php esc_html_e( 'See all forms.', 'formidable' ); ?>
116 - </a>
117 - <?php
118 - echo '</p>';
119 - } else {
120 - $title = __( 'No Forms Found', 'formidable' );
121 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_no_forms.php';
122 - }
99 + esc_html_e( 'No Forms Found.', 'formidable' );
100 + ?>
101 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>">
102 + <?php esc_html_e( 'Add New', 'formidable' ); ?>
103 + </a>
104 +<?php
123 105 }
124 106
125 107 public function get_bulk_actions() {
126 - $actions = array();
108 + $actions = array();
127 109
128 - if ( 'trash' == $this->status ) {
110 + if ( 'trash' == $this->status ) {
129 111 if ( current_user_can( 'frm_edit_forms' ) ) {
130 - $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
131 - }
112 + $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
113 + }
132 114
133 115 if ( current_user_can( 'frm_delete_forms' ) ) {
134 - $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
135 - }
116 + $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
117 + }
136 118 } elseif ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
137 - $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
119 + $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
138 120 } elseif ( current_user_can( 'frm_delete_forms' ) ) {
139 121 $actions['bulk_delete'] = __( 'Delete', 'formidable' );
140 - }
122 + }
141 123
142 - return $actions;
143 - }
124 + return $actions;
125 + }
144 126
145 - /**
146 - * @return void
147 - */
148 127 public function extra_tablenav( $which ) {
149 - if ( 'top' != $which ) {
150 - return;
151 - }
128 + if ( 'top' != $which ) {
129 + return;
130 + }
152 131
153 132 if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
154 - ?>
155 - <div class="alignleft actions frm_visible_overflow">
156 - <?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?>
157 - </div>
158 - <?php
159 - }
133 +?>
134 + <div class="alignleft actions frm_visible_overflow">
135 + <?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?>
136 + </div>
137 +<?php
138 + }
160 139 }
161 140
162 141 public function get_views() {
163 142
164 143 $statuses = array(
165 - 'published' => __( 'My Forms', 'formidable' ),
166 - 'draft' => __( 'Drafts', 'formidable' ),
167 - 'trash' => __( 'Trash', 'formidable' ),
144 + 'published' => __( 'My Forms', 'formidable' ),
145 + 'draft' => __( 'Drafts', 'formidable' ),
146 + 'trash' => __( 'Trash', 'formidable' ),
168 147 );
169 148
170 - $links = array();
171 - $counts = FrmForm::get_count();
172 - $form_type = FrmAppHelper::simple_get( 'form_type', 'sanitize_title', 'published' );
173 -
174 - if ( isset( $statuses[ $form_type ] ) ) {
175 - $counts->$form_type = $this->total_items;
176 - }
177 -
149 + $links = array();
150 + $counts = FrmForm::get_count();
178 151 $form_type = self::get_param(
179 152 array(
180 - 'param' => 'form_type',
153 + 'param' => 'form_type',
181 154 'default' => 'published',
182 155 )
183 156 );
184 157
185 - foreach ( $statuses as $status => $name ) {
158 + foreach ( $statuses as $status => $name ) {
186 159
187 - if ( $status == $form_type ) {
188 - $class = ' class="current"';
189 - } else {
190 - $class = '';
191 - }
160 + if ( $status == $form_type ) {
161 + $class = ' class="current"';
162 + } else {
163 + $class = '';
164 + }
192 165
193 - if ( $counts->{$status} || 'draft' !== $status ) {
194 - /* translators: %1$s: Status, %2$s: Number of items */
166 + if ( $counts->{$status} || 'published' == $status ) {
195 167 $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
196 - }
168 + }
197 169
198 170 unset( $status, $name );
199 - }
171 + }
200 172
201 173 return $links;
202 174 }
203 175
204 - /**
205 - * @return void
206 - */
207 176 public function pagination( $which ) {
208 177 global $mode;
209 178
210 179 parent::pagination( $which );
211 180
212 - if ( 'top' === $which ) {
181 + if ( 'top' == $which ) {
213 182 $this->view_switcher( $mode );
214 183 }
215 184 }
216 185
217 - /**
218 - * @param stdClass $item
219 - * @param string $style
220 - * @return string
221 - */
222 186 public function single_row( $item, $style = '' ) {
223 - global $frm_vars, $mode;
187 + global $frm_vars, $mode;
224 188
225 189 // Set up the hover actions for this user
226 - $actions = array();
227 - $edit_link = FrmForm::get_edit_link( $item->id );
190 + $actions = array();
191 + $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
228 192
229 193 $this->get_actions( $actions, $item, $edit_link );
230 194
231 - $action_links = $this->row_actions( $actions );
195 + $action_links = $this->row_actions( $actions );
232 196
233 197 // Set up the checkbox ( because the user is editable, otherwise its empty )
234 198 $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
235 199
@@ -236,11 +200,11 @@
236 200 $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>';
237 201
238 202 list( $columns, $hidden ) = $this->get_column_info();
239 203
240 - $format = 'Y/m/d';
241 - if ( 'list' != $mode ) {
242 - $format .= ' \<\b\r \/\> g:i:s a';
204 + $format = 'Y/m/d';
205 + if ( 'list' != $mode ) {
206 + $format .= ' \<\b\r \/\> g:i:s a';
243 207 }
244 208
245 209 foreach ( $columns as $column_name => $column_display_name ) {
246 210 $class = $column_name . ' column-' . $column_name . ( 'name' == $column_name ? ' post-title page-title column-title' : '' );
@@ -246,18 +210,14 @@
246 210 $class = $column_name . ' column-' . $column_name . ( 'name' == $column_name ? ' post-title page-title column-title' : '' );
247 211
248 212 $style = '';
249 213 if ( in_array( $column_name, $hidden ) ) {
250 - $class .= ' frm_hidden';
214 + $class .= ' frm_hidden';
251 215 }
252 216
253 - if ( $column_name === 'name' ) {
254 - $class .= ' column-primary';
255 - }
256 -
257 - $class = 'class="' . esc_attr( $class ) . '"';
217 + $class = 'class="' . esc_attr( $class ) . '"';
258 218 $data_colname = ' data-colname="' . esc_attr( $column_display_name ) . '"';
259 - $attributes = $class . $style . $data_colname;
219 + $attributes = $class . $style . $data_colname;
260 220
261 221 switch ( $column_name ) {
262 222 case 'cb':
263 223 $r .= '<th scope="row" class="check-column">' . $checkbox . '</th>';
@@ -263,44 +223,39 @@
263 223 $r .= '<th scope="row" class="check-column">' . $checkbox . '</th>';
264 224 break;
265 225 case 'id':
266 226 case 'form_key':
267 - $val = $item->{$column_name};
268 - break;
227 + $val = $item->{$column_name};
228 + break;
269 229 case 'name':
270 - $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
271 - $val .= $action_links;
272 - break;
230 + $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
231 + $val .= $action_links;
232 +
233 + break;
273 234 case 'created_at':
274 - $date = gmdate( $format, strtotime( $item->created_at ) );
275 - $val = '<abbr title="' . esc_attr( gmdate( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
235 + $date = date( $format, strtotime( $item->created_at ) );
236 + $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
276 237 break;
277 - case 'entries':
238 + case 'shortcode':
239 + $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
240 + if ( 'excerpt' == $mode ) {
241 + $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
242 + }
243 + break;
244 + case 'entries':
278 245 if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
279 - $val = FrmAppHelper::icon_by_class(
280 - 'frmfont frm_forbid_icon frm_bstooltip',
281 - array(
282 - 'title' => __( 'Saving entries is disabled for this form', 'formidable' ),
283 - 'echo' => false,
284 - )
285 - );
246 + $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>';
286 247 } else {
287 248 $text = FrmEntry::getRecordCount( $item->id );
288 - $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
249 + $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
289 250 unset( $text );
290 251 }
291 - break;
292 - default:
293 - if ( method_exists( $this, 'column_' . $column_name ) ) {
294 - $val = call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
295 - }
296 - break;
297 252 }
298 253
299 254 if ( isset( $val ) ) {
300 - $r .= "<td $attributes>";
301 - $r .= $val;
302 - $r .= '</td>';
255 + $r .= "<td $attributes>";
256 + $r .= $val;
257 + $r .= '</td>';
303 258 }
304 259 unset( $val );
305 260 }
306 261 $r .= '</tr>';
@@ -307,61 +262,11 @@
307 262
308 263 return $r;
309 264 }
310 265
311 - /**
312 - * Get the HTML for the Actions column in the form list.
313 - * This includes multiple icons for triggering the embed modal, the visual styler, and an active landing page.
314 - *
315 - * @since 6.0
316 - *
317 - * @param stdClass $form
318 - * @return string
319 - */
320 - protected function column_shortcode( $form ) {
321 - $val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_html__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>';
322 - $val .= $this->column_style( $form );
323 - $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) );
324 - $val = str_replace( '&nbsp;', '', $val ); // Remove the space hard coded in Landing pages.
325 - $val = '<div>' . $val . '</div>';
326 - return $val;
327 - }
328 -
329 - /**
330 - * Get the HTML for the Style column in the form list.
331 - *
332 - * @since 6.0
333 - *
334 - * @param stdClass $form
335 - * @return string
336 - */
337 - protected function column_style( $form ) {
338 - $style_setting = isset( $form->options['custom_style'] ) ? $form->options['custom_style'] : '';
339 - $frm_settings = FrmAppHelper::get_settings();
340 -
341 - if ( $style_setting === '0' || 'none' === $frm_settings->load_style ) {
342 - // Don't show a link if styling is off.
343 - return '';
344 - }
345 -
346 - $style = FrmStylesController::get_form_style( $form );
347 - if ( ! $style ) {
348 - // Do a second pass to avoid null values.
349 - $frm_style = new FrmStyle( 'default' );
350 - $style = $frm_style->get_one();
351 - }
352 -
353 - $href = FrmStylesHelper::get_edit_url( $style, $form->id );
354 - return '<a href="' . esc_url( $href ) . '" title="' . esc_attr( $style->post_title ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_pallet_icon', array( 'echo' => false ) ) . '</a>';
355 - }
356 -
357 - /**
358 - * @param string $edit_link
359 - * @param array $actions
360 - * @param stdClass $item
361 - *
362 - * @return void
363 - */
266 + /**
267 + * @param string $edit_link
268 + */
364 269 private function get_actions( &$actions, $item, $edit_link ) {
365 270 $new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
366 271 foreach ( $new_actions as $link => $action ) {
367 272 $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' );
@@ -368,29 +273,25 @@
368 273 }
369 274
370 275 if ( 'trash' == $this->status ) {
371 276 $actions = $new_actions;
372 -
373 277 return;
374 278 }
375 279
376 280 if ( current_user_can( 'frm_edit_forms' ) ) {
377 - $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'formidable' ) . '</a>';
281 + $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'formidable' ) . '</a>';
378 282 $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
379 283 }
380 284
381 - $actions = array_merge( $actions, $new_actions );
285 + $actions = array_merge( $actions, $new_actions );
382 286 $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>';
383 - }
287 + }
384 288
385 - /**
386 - * @param string $edit_link
387 - * @param stdClass $item
388 - *
389 - * @return string
390 - */
289 + /**
290 + * @param string $edit_link
291 + */
391 292 private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
392 - $form_name = $item->name;
293 + $form_name = $item->name;
393 294 if ( trim( $form_name ) == '' ) {
394 295 $form_name = __( '(no title)', 'formidable' );
395 296 }
396 297 $form_name = FrmAppHelper::kses( $form_name );
@@ -397,49 +298,38 @@
397 298 if ( 'excerpt' != $mode ) {
398 299 $form_name = FrmAppHelper::truncate( $form_name, 50 );
399 300 }
400 301
401 - $val = '<strong>';
402 - if ( 'trash' == $this->status ) {
403 - $val .= $form_name;
404 - } else {
302 + $val = '<strong>';
303 + if ( 'trash' == $this->status ) {
304 + $val .= $form_name;
305 + } else {
405 306 $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
406 - }
307 + }
407 308
408 - $this->add_draft_label( $item, $val );
409 - $val .= '</strong>';
309 + $this->add_draft_label( $item, $val );
310 + $val .= '</strong>';
410 311
411 - $this->add_form_description( $item, $val );
312 + $this->add_form_description( $item, $val );
412 313
413 - return $val;
414 - }
314 + return $val;
315 + }
415 316
416 - /**
417 - * @param string $val
418 - *
419 - * @return void
420 - */
421 - private function add_draft_label( $item, &$val ) {
422 - if ( 'draft' == $item->status && 'draft' != $this->status ) {
317 + /**
318 + * @param string $val
319 + */
320 + private function add_draft_label( $item, &$val ) {
321 + if ( 'draft' == $item->status && 'draft' != $this->status ) {
423 322 $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
424 - }
425 - }
323 + }
324 + }
426 325
427 - /**
428 - * @param string $val
429 - *
430 - * @return void
431 - */
432 - private function add_form_description( $item, &$val ) {
433 - global $mode;
434 - if ( 'excerpt' == $mode ) {
326 + /**
327 + * @param string $val
328 + */
329 + private function add_form_description( $item, &$val ) {
330 + global $mode;
331 + if ( 'excerpt' == $mode ) {
435 332 $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
436 - }
437 - }
438 -
439 - /**
440 - * @return string
441 - */
442 - protected function confirm_bulk_delete() {
443 - return __( 'ALL selected forms and their entries will be permanently deleted. Want to proceed?', 'formidable' );
444 - }
333 + }
334 + }
445 335 }