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/models/FrmFormAction.php +362 -641 6.293.06.06 View file →
@@ -1,74 +1,19 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmFormAction {
7 4
8 - /**
9 - * Root id for all actions of this type.
10 - *
11 - * @var string
12 - */
13 - public $id_base;
14 -
15 - /**
16 - * Name for this action type.
17 - *
18 - * @var string
19 - */
20 - public $name;
21 -
22 - /**
23 - * Name of the option used to store the settings for this action type.
24 - *
25 - * @var string
26 - */
5 + public $id_base; // Root id for all actions of this type.
6 + public $name; // Name for this action type.
27 7 public $option_name;
8 + public $action_options; // Option array passed to wp_register_sidebar_widget()
9 + public $control_options; // Option array passed to wp_register_widget_control()
28 10
29 - /**
30 - * Option array passed to wp_register_sidebar_widget().
31 - *
32 - * @var array
33 - */
34 - public $action_options;
11 + public $form_id; // The ID of the form to evaluate
12 + public $number = false; // Unique ID number of the current instance.
13 + public $id = ''; // Unique ID string of the current instance (id_base-number)
14 + public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
35 15
36 - /**
37 - * Option array passed to wp_register_widget_control().
38 - *
39 - * @var array
40 - */
41 - public $control_options;
42 -
43 - /**
44 - * The ID of the form to evaluate.
45 - *
46 - * @var int
47 - */
48 - public $form_id;
49 -
50 - /**
51 - * Unique ID number of the current instance.
52 - *
53 - * @var int
54 - */
55 - public $number = false;
56 -
57 - /**
58 - * Unique ID string of the current instance (id_base-number).
59 - *
60 - * @var string
61 - */
62 - public $id = '';
63 -
64 - /**
65 - * Set true when we update the data after a POST submit - makes sure we don't do it twice.
66 - *
67 - * @var bool
68 - */
69 - public $updated = false;
70 -
71 16 // Member functions that you must over-ride.
72 17
73 18 /**
74 19 * This function should check that $new_instance is set correctly.
@@ -74,11 +19,10 @@
74 19 * This function should check that $new_instance is set correctly.
75 20 * The newly calculated value of $instance should be returned.
76 21 * If "false" is returned, the instance won't be saved/updated.
77 22 *
78 - * @param array $new_instance New settings for this instance as input by the user via form().
79 - * @param array $old_instance Old settings for this instance.
80 - *
23 + * @param array $new_instance New settings for this instance as input by the user via form()
24 + * @param array $old_instance Old settings for this instance
81 25 * @return array Settings to save or bool false to cancel saving
82 26 */
83 27 public function update( $new_instance, $old_instance ) {
84 28 return $new_instance;
@@ -84,14 +28,11 @@
84 28 return $new_instance;
85 29 }
86 30
87 31 /**
88 - * Echo the settings update form
32 + * Echo the settings update form
89 33 *
90 - * @param WP_Post $instance Current settings.
91 - * @param array $args
92 - *
93 - * @return string
34 + * @param array $instance Current settings
94 35 */
95 36 public function form( $instance, $args = array() ) {
96 37 echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
97 38 return 'noform';
@@ -100,26 +41,17 @@
100 41 /**
101 42 * @return array of the default options
102 43 */
103 44 public function get_defaults() {
104 - return array();
45 + return array();
105 46 }
106 47
107 - /**
108 - * @return array
109 - */
110 48 public function get_switch_fields() {
111 - return array();
49 + return array();
112 50 }
113 51
114 - /**
115 - * @param object $action
116 - * @param object $form
117 - *
118 - * @return object
119 - */
120 52 public function migrate_values( $action, $form ) {
121 - return $action;
53 + return $action;
122 54 }
123 55
124 56 // Functions you'll need to call.
125 57
@@ -128,14 +60,14 @@
128 60 *
129 61 * @param string $id_base Optional Base ID for the widget, lower case,
130 62 * if left empty a portion of the widget's class name will be used. Has to be unique.
131 63 * @param string $name Name for the widget displayed on the configuration page.
132 - * @param array $action_options Optional Passed to wp_register_sidebar_widget().
133 - * - description: shown on the configuration page.
134 - * - classname.
135 - * @param array $control_options Optional Passed to wp_register_widget_control().
136 - * - width: required if more than 250px.
137 - * - height: currently not used but may be needed in the future.
64 + * @param array $action_options Optional Passed to wp_register_sidebar_widget()
65 + * - description: shown on the configuration page
66 + * - classname
67 + * @param array $control_options Optional Passed to wp_register_widget_control()
68 + * - width: required if more than 250px
69 + * - height: currently not used but may be needed in the future
138 70 */
139 71 public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
140 72 if ( ! defined( 'ABSPATH' ) ) {
141 73 die( 'You are not allowed to call this page directly.' );
@@ -140,61 +72,31 @@
140 72 if ( ! defined( 'ABSPATH' ) ) {
141 73 die( 'You are not allowed to call this page directly.' );
142 74 }
143 75
144 - $this->id_base = strtolower( $id_base );
145 - $this->name = $name;
76 + $this->id_base = strtolower( $id_base );
77 + $this->name = $name;
146 78 $this->option_name = 'frm_' . $this->id_base . '_action';
147 79
148 - $default_options = array(
149 - 'classes' => '',
150 - 'active' => true,
151 - 'event' => array( 'create' ),
152 - 'limit' => 1,
153 - 'force_event' => false,
154 - 'priority' => 20,
155 - 'ajax_load' => true,
156 - 'plugin' => $this->id_base,
157 - 'tooltip' => $name,
158 - 'group' => $id_base,
159 - 'color' => '',
160 - 'keywords' => '',
161 - );
80 + $default_options = array(
81 + 'classes' => '',
82 + 'active' => true,
83 + 'event' => array( 'create' ),
84 + 'limit' => 1,
85 + 'force_event' => false,
86 + 'priority' => 20,
87 + 'ajax_load' => true,
88 + 'plugin' => $this->id_base,
89 + 'tooltip' => $name,
90 + );
162 91
163 - $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
164 - $group = $this->get_group( $action_options );
165 - $action_options['group'] = $group['id'];
166 -
167 - if ( ! isset( $action_options['color'] ) ) {
168 - $colors = array( 'green', 'orange', 'purple' );
169 - shuffle( $colors );
170 - $action_options['color'] = 'var(--' . reset( $colors ) . ')';
171 - }
172 -
173 - $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
174 -
175 - if ( $action_options['group'] === $id_base ) {
176 - $upgrade_class = str_contains( $action_options['classes'], 'frm_show_upgrade' );
177 - $action_options['classes'] = $group['icon'];
178 - } elseif ( empty( $action_options['classes'] ) || $upgrade_class ) {
179 - $action_options['classes'] = $group['icon'];
180 - }
181 -
182 - if ( $upgrade_class ) {
183 - $action_options['classes'] .= ' frm_show_upgrade';
184 - }
185 -
186 - $this->action_options = wp_parse_args( $action_options, $default_options );
92 + $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
93 + $this->action_options = wp_parse_args( $action_options, $default_options );
187 94 $this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
188 95 }
189 96
190 97 /**
191 98 * @param string $id_base
192 - * @param string $name
193 - * @param array $action_options
194 - * @param array $control_options
195 - *
196 - * @return void
197 99 */
198 100 public function FrmFormAction( $id_base, $name, $action_options = array(), $control_options = array() ) {
199 101 self::__construct( $id_base, $name, $action_options, $control_options );
200 102 }
@@ -199,67 +101,20 @@
199 101 self::__construct( $id_base, $name, $action_options, $control_options );
200 102 }
201 103
202 104 /**
203 - * Help to switch old field id by new field id for duplicate form
204 - *
205 - * @param string $action id of the field that needs to be switched.
206 - *
207 - * @return string
208 - */
209 - public function maybe_switch_field_ids( $action ) {
210 - $updated_action = apply_filters( 'frm_maybe_switch_field_ids', $action );
211 -
212 - if ( $updated_action === $action ) {
213 - return FrmFieldsHelper::switch_field_ids( $action );
214 - }
215 -
216 - return $updated_action;
217 - }
218 -
219 - /**
220 - * @since 4.0
221 - *
222 - * @param array $action_options
223 - *
224 - * @return array
225 - */
226 - protected function get_group( $action_options ) {
227 - $groups = FrmFormActionsController::form_action_groups();
228 - $group = 'misc';
229 -
230 - if ( isset( $action_options['group'] ) && isset( $groups[ $action_options['group'] ] ) ) {
231 - $group = $action_options['group'];
232 - } elseif ( isset( $groups[ $this->id_base ] ) ) {
233 - $group = $this->id_base;
234 - } else {
235 - foreach ( $groups as $name => $check_group ) {
236 - if ( isset( $check_group['actions'] ) && in_array( $this->id_base, $check_group['actions'], true ) ) {
237 - $group = $name;
238 - break;
239 - }
240 - }
241 - }
242 -
243 - $groups[ $group ]['id'] = $group;
244 - return $groups[ $group ];
245 - }
246 -
247 - /**
248 105 * Constructs name attributes for use in form() fields
249 106 *
250 107 * This function should be used in form() methods to create name attributes for fields to be saved by update()
251 108 *
252 - * @param string $field_name Field name.
253 - * @param string $post_field
254 - *
109 + * @param string $field_name Field name
255 110 * @return string Name attribute for $field_name
256 111 */
257 112 public function get_field_name( $field_name, $post_field = 'post_content' ) {
258 - $name = $this->option_name . '[' . $this->number . ']';
259 - $name .= $post_field ? '[' . $post_field . ']' : '';
260 -
261 - return $name . ( '[' . $field_name . ']' );
113 + $name = $this->option_name . '[' . $this->number . ']';
114 + $name .= ( empty( $post_field ) ? '' : '[' . $post_field . ']' );
115 + $name .= '[' . $field_name . ']';
116 + return $name;
262 117 }
263 118
264 119 /**
265 120 * Constructs id attributes for use in form() fields
@@ -265,10 +120,9 @@
265 120 * Constructs id attributes for use in form() fields
266 121 *
267 122 * This function should be used in form() methods to create id attributes for fields to be saved by update()
268 123 *
269 - * @param string $field_name Field name.
270 - *
124 + * @param string $field_name Field name
271 125 * @return string ID attribute for $field_name
272 126 */
273 127 public function get_field_id( $field_name ) {
274 128 return $field_name . '_' . $this->number;
@@ -273,32 +127,24 @@
273 127 public function get_field_id( $field_name ) {
274 128 return $field_name . '_' . $this->number;
275 129 }
276 130
277 - /**
278 - * @param int|string $number
279 - *
280 - * @return void
281 - */
131 + // Private Function. Don't worry about this.
132 +
282 133 public function _set( $number ) {
283 134 $this->number = $number;
284 - $this->id = $this->id_base . '-' . $number;
135 + $this->id = $this->id_base . '-' . $number;
285 136 }
286 137
287 - /**
288 - * @param false|int|string $form_id
289 - *
290 - * @return object
291 - */
292 138 public function prepare_new( $form_id = false ) {
293 - if ( $form_id ) {
294 - $this->form_id = $form_id;
295 - }
139 + if ( $form_id ) {
140 + $this->form_id = $form_id;
141 + }
296 142
297 - $post_content = array();
298 - $default_values = $this->get_global_defaults();
143 + $post_content = array();
144 + $default_values = $this->get_global_defaults();
299 145
300 - // Fill default values
146 + // fill default values
301 147 $post_content = wp_parse_args( $post_content, $default_values );
302 148
303 149 if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) {
304 150 $post_content['event'] = array( reset( $this->action_options['event'] ) );
@@ -303,99 +149,79 @@
303 149 if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) {
304 150 $post_content['event'] = array( reset( $this->action_options['event'] ) );
305 151 }
306 152
307 - $form_action = array(
308 - 'post_title' => $this->name,
309 - 'post_content' => $post_content,
310 - 'post_excerpt' => $this->id_base,
311 - 'ID' => '',
312 - 'post_status' => 'publish',
313 - 'post_type' => FrmFormActionsController::$action_post_type,
314 - 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number,
315 - 'menu_order' => $this->form_id,
316 - );
153 + $form_action = array(
154 + 'post_title' => $this->name,
155 + 'post_content' => $post_content,
156 + 'post_excerpt' => $this->id_base,
157 + 'ID' => '',
158 + 'post_status' => 'publish',
159 + 'post_type' => FrmFormActionsController::$action_post_type,
160 + 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number,
161 + 'menu_order' => $this->form_id,
162 + );
163 + unset( $post_content );
317 164
318 - return (object) $form_action;
319 - }
165 + return (object) $form_action;
166 + }
320 167
321 - /**
322 - * @param int|string $form_id
323 - *
324 - * @return int|WP_Error
325 - */
326 168 public function create( $form_id ) {
327 - $this->form_id = $form_id;
169 + $this->form_id = $form_id;
328 170
329 - $action = $this->prepare_new();
171 + $action = $this->prepare_new();
330 172
331 173 return $this->save_settings( $action );
332 - }
174 + }
333 175
334 - /**
335 - * @param int|string $form_id
336 - * @param int|string $old_id
337 - *
338 - * @return void
339 - */
340 176 public function duplicate_form_actions( $form_id, $old_id ) {
341 - // phpcs:ignore Universal.Operators.StrictComparisons
342 - if ( $form_id == $old_id ) {
343 - // Don't duplicate the actions if this is a template getting updated
344 - return;
345 - }
177 + if ( $form_id == $old_id ) {
178 + // don't duplicate the actions if this is a template getting updated
179 + return;
180 + }
346 181
347 - $this->form_id = $old_id;
348 - $actions = $this->get_all( $old_id );
182 + $this->form_id = $old_id;
183 + $actions = $this->get_all( $old_id );
349 184
350 - $this->form_id = $form_id;
351 -
352 - foreach ( $actions as $action ) {
185 + $this->form_id = $form_id;
186 + foreach ( $actions as $action ) {
353 187 $this->duplicate_one( $action, $form_id );
354 188 unset( $action );
355 - }
356 - }
189 + }
190 + }
357 191
358 - /**
359 - * Check if imported action should be created or updated.
360 - *
361 - * @since 2.0
362 - *
363 - * @param array $action
364 - * @param array $forms
365 - *
366 - * @return int Post ID.
367 - */
368 - public function maybe_create_action( $action, $forms ) {
369 - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) {
370 - // Update action only
192 + /* Check if imported action should be created or updated
193 + *
194 + * Since 2.0
195 + *
196 + * @param array $action
197 + * @return integer $post_id
198 + */
199 + public function maybe_create_action( $action, $forms ) {
200 + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
201 + // Update action only
202 + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
203 + $post_id = $this->save_settings( $action );
204 + } else {
205 + // Create action
371 206 $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
372 - return $this->save_settings( $action );
373 - }
374 - // Create action
375 - $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
376 - return $this->duplicate_one( (object) $action, $action['menu_order'] );
377 - }
207 + $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] );
208 + }
209 + return $post_id;
210 + }
378 211
379 - /**
380 - * @param object $action
381 - * @param int|string $form_id
382 - *
383 - * @return int|WP_Error
384 - */
385 212 public function duplicate_one( $action, $form_id ) {
386 - global $frm_duplicate_ids;
213 + global $frm_duplicate_ids;
387 214
388 - $action->menu_order = $form_id;
389 - $switch = $this->get_global_switch_fields();
390 -
391 - foreach ( (array) $action->post_content as $key => $val ) {
215 + $action->menu_order = $form_id;
216 + $switch = $this->get_global_switch_fields();
217 + foreach ( (array) $action->post_content as $key => $val ) {
392 218 if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
393 219 $action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
394 - } elseif ( ! is_array( $val ) ) {
220 + } else if ( ! is_array( $val ) ) {
395 221 $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
396 - } elseif ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
397 - // Loop through each value if empty
222 + } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
223 + // loop through each value if empty
398 224 if ( empty( $switch[ $key ] ) ) {
399 225 $switch[ $key ] = array_keys( $val );
400 226 }
401 227
@@ -400,10 +226,10 @@
400 226 }
401 227
402 228 foreach ( $switch[ $key ] as $subkey ) {
403 229 $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
404 - }
405 - }
230 + }
231 + }
406 232
407 233 unset( $key, $val );
408 234 }
409 235 unset( $action->ID );
@@ -408,98 +234,83 @@
408 234 }
409 235 unset( $action->ID );
410 236
411 237 return $this->save_settings( $action );
412 - }
238 + }
413 239
414 - /**
415 - * @param array $action
416 - * @param array|string $subkey
417 - * @param mixed $val
418 - *
419 - * @return array
420 - */
421 240 private function duplicate_array_walk( $action, $subkey, $val ) {
422 - global $frm_duplicate_ids;
241 + global $frm_duplicate_ids;
423 242
424 243 if ( is_array( $subkey ) ) {
425 - foreach ( $subkey as $subkey2 ) {
426 - foreach ( (array) $val as $ck => $cv ) {
244 + foreach ( $subkey as $subkey2 ) {
245 + foreach ( (array) $val as $ck => $cv ) {
427 246 if ( is_array( $cv ) ) {
428 247 $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
429 - } elseif ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248 + } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
430 249 $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
431 - }
432 - }
433 - }
434 - } else {
435 - foreach ( (array) $val as $ck => $cv ) {
250 + }
251 + }
252 + }
253 + } else {
254 + foreach ( (array) $val as $ck => $cv ) {
436 255 if ( is_array( $cv ) ) {
437 256 $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
438 - } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { // phpcs:ignore Universal.Operators.StrictComparisons
257 + } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
439 258 $action[ $ck ] = $frm_duplicate_ids[ $cv ];
440 - } elseif ( $ck == $subkey ) { // phpcs:ignore Universal.Operators.StrictComparisons
441 - $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] );
442 - }
443 - }
444 - }//end if
259 + }
260 + }
261 + }
445 262
446 - return $action;
447 - }
263 + return $action;
264 + }
448 265
449 266 /**
450 267 * Deal with changed settings.
451 268 *
452 269 * Do NOT over-ride this function
453 - *
454 - * @param int|string $form_id
455 - *
456 - * @return array|null
457 270 */
458 - public function update_callback( $form_id ) {
459 - $this->form_id = $form_id;
271 + public function update_callback( $form_id ) {
272 + $this->form_id = $form_id;
460 273
461 - $all_instances = $this->get_settings();
274 + $all_instances = $this->get_settings();
462 275
463 - // We need to update the data
464 - if ( $this->updated ) {
465 - return null;
466 - }
276 + // We need to update the data
277 + if ( $this->updated ) {
278 + return;
279 + }
467 280
468 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
469 - if ( ! isset( $_POST[ $this->option_name ] ) || ! is_array( $_POST[ $this->option_name ] ) ) {
470 - return null;
471 - }
281 + if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
282 + $settings = $_POST[ $this->option_name ];
283 + } else {
284 + return;
285 + }
472 286
473 - // Sanitizing removes scripts and <email> type of values.
474 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
475 - $settings = wp_unslash( $_POST[ $this->option_name ] );
287 + $action_ids = array();
476 288
477 - $action_ids = array();
289 + foreach ( $settings as $number => $new_instance ) {
290 + $this->_set( $number );
478 291
479 - foreach ( $settings as $number => $new_instance ) {
480 - $this->_set( $number );
292 + $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
481 293
482 - $old_instance = $all_instances[ $number ] ?? array();
483 -
484 294 if ( ! isset( $new_instance['post_status'] ) ) {
485 295 $new_instance['post_status'] = 'draft';
486 296 }
487 297
488 - // Settings were never opened, so don't update
489 - if ( ! isset( $new_instance['post_title'] ) ) {
298 + // settings were never opened, so don't update
299 + if ( ! isset( $new_instance['post_title'] ) ) {
490 300 $this->maybe_update_status( $new_instance, $old_instance );
491 - $action_ids[] = $new_instance['ID'];
492 - $this->updated = true;
493 - continue;
494 - }
301 + $action_ids[] = $new_instance['ID'];
302 + $this->updated = true;
303 + continue;
304 + }
495 305
496 306 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
497 307 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
498 308 $new_instance['menu_order'] = $this->form_id;
499 - $new_instance['post_date'] = $old_instance->post_date ?? '';
500 - $instance = $this->update( $new_instance, $old_instance );
309 + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
501 310
311 + $instance = $this->update( $new_instance, $old_instance );
312 +
502 313 /**
503 314 * Filter an action's settings before saving.
504 315 *
505 316 * Returning false will effectively short-circuit the widget's ability
@@ -506,17 +317,17 @@
506 317 * to update settings.
507 318 *
508 319 * @since 2.0
509 320 *
510 - * @param array $instance The current widget instance's settings.
511 - * @param array $new_instance Array of new widget settings.
512 - * @param array $old_instance Array of old widget settings.
513 - * @param FrmFormAction $form_action FrmFormAction instance.
321 + * @param array $instance The current widget instance's settings.
322 + * @param array $new_instance Array of new widget settings.
323 + * @param array $old_instance Array of old widget settings.
324 + * @param WP_Widget $this The current widget instance.
514 325 */
515 326 $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
516 327
517 328 $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
518 - $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
329 + $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
519 330
520 331 if ( false !== $instance ) {
521 332 $all_instances[ $number ] = $instance;
522 333 }
@@ -522,255 +333,180 @@
522 333 }
523 334
524 335 $action_ids[] = $this->save_settings( $instance );
525 336
526 - $this->updated = true;
527 - }//end foreach
337 + $this->updated = true;
338 + }
528 339
529 - return $action_ids;
530 - }
340 + return $action_ids;
341 + }
531 342
532 343 /**
533 344 * If the status of the action has changed, update it
534 345 *
535 346 * @since 3.04
536 - *
537 - * @param array $new_instance
538 - * @param array|stdClass $old_instance
539 - *
540 - * @return void
541 347 */
542 348 protected function maybe_update_status( $new_instance, $old_instance ) {
543 - if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) {
544 - return;
349 + if ( $new_instance['post_status'] !== $old_instance->post_status ) {
350 + self::clear_cache();
351 + wp_update_post(
352 + array(
353 + 'ID' => $new_instance['ID'],
354 + 'post_status' => $new_instance['post_status'],
355 + )
356 + );
545 357 }
546 -
547 - self::clear_cache();
548 - wp_update_post(
549 - array(
550 - 'ID' => $new_instance['ID'],
551 - 'post_status' => $new_instance['post_status'],
552 - )
553 - );
554 358 }
555 359
556 - /**
557 - * @param array $settings
558 - *
559 - * @return int|WP_Error
560 - */
561 360 public function save_settings( $settings ) {
562 361 self::clear_cache();
563 362 return FrmDb::save_settings( $settings, 'frm_actions' );
564 363 }
565 364
566 - /**
567 - * @param int $id
568 - *
569 - * @return object|null
570 - */
571 365 public function get_single_action( $id ) {
572 366 $action = get_post( $id );
573 -
574 367 if ( $action ) {
575 368 $action = $this->prepare_action( $action );
576 369 $this->_set( $id );
577 370 }
578 -
579 - return $action;
371 + return $action;
580 372 }
581 373
582 - /**
583 - * @param int|string $form_id
584 - *
585 - * @return array
586 - */
587 374 public function get_one( $form_id ) {
588 375 return $this->get_all( $form_id, 1 );
589 376 }
590 377
591 - /**
592 - * @param int|string $form_id
593 - * @param string $type
594 - * @param array $atts
595 - *
596 - * @return array
597 - */
598 - public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
599 - $action_controls = FrmFormActionsController::get_form_actions( $type );
378 + public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
379 + $action_controls = FrmFormActionsController::get_form_actions( $type );
380 + if ( empty( $action_controls ) ) {
381 + // don't continue if there are no available actions
382 + return array();
383 + }
600 384
601 - if ( ! $action_controls ) {
602 - // Don't continue if there are no available actions
603 - return array();
604 - }
605 -
606 - if ( 'all' !== $type ) {
607 - if ( is_array( $action_controls ) ) {
608 - return array();
609 - }
610 -
385 + if ( 'all' != $type ) {
611 386 return $action_controls->get_all( $form_id, $atts );
612 387 }
613 388
614 389 self::prepare_get_action( $atts );
615 390
616 - $limit = self::get_action_limit( $form_id, $atts['limit'] );
617 - $args = self::action_args( $form_id, $limit );
391 + $limit = apply_filters( 'frm_form_action_limit', $atts['limit'], compact( 'type', 'form_id' ) );
392 +
393 + $args = self::action_args( $form_id, $limit );
618 394 $args['post_status'] = $atts['post_status'];
619 - $actions = FrmDb::check_cache( json_encode( $args ), 'frm_actions', $args, 'get_posts' );
395 + $actions = FrmDb::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
620 396
621 - if ( ! $actions ) {
622 - return array();
623 - }
397 + if ( ! $actions ) {
398 + return array();
399 + }
624 400
625 - $settings = array();
626 -
627 - foreach ( $actions as $action ) {
628 - // Some plugins/themes are formatting the post_excerpt
401 + $settings = array();
402 + foreach ( $actions as $action ) {
403 + // some plugins/themes are formatting the post_excerpt
629 404 $action->post_excerpt = sanitize_title( $action->post_excerpt );
630 405
631 406 if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
632 - continue;
633 - }
407 + continue;
408 + }
634 409
635 - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
410 + $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
636 411 $settings[ $action->ID ] = $action;
637 412
638 413 if ( count( $settings ) >= $limit ) {
639 414 break;
640 415 }
641 - }
416 + }
642 417
643 - return 1 === $limit ? reset( $settings ) : $settings;
644 - }
418 + if ( 1 === $limit ) {
419 + $settings = reset( $settings );
420 + }
645 421
646 - /**
647 - * Get the limit for the number of actions for a single form. By default, this is 99, but
648 - * it can be modified with a code snippet.
649 - *
650 - * @since 6.17 This logic from moved from FrmFormAction::get_action_for_form.
651 - *
652 - * @param int|string $form_id
653 - * @param int|string $limit The unfiltered limit value.
654 - *
655 - * @return int The filtered limit value.
656 - */
657 - public static function get_action_limit( $form_id, $limit = 99 ) {
658 - $type = 'all';
659 - return (int) apply_filters( 'frm_form_action_limit', (int) $limit, compact( 'type', 'form_id' ) );
660 - }
422 + return $settings;
423 + }
661 424
662 425 /**
663 426 * @since 3.04
664 - *
665 - * @param array|string $args
666 - * @param string $default_status
667 - *
668 - * @return void
427 + * @param array $args
428 + * @param string $default_status
669 429 */
670 430 protected static function prepare_get_action( &$args, $default_status = 'publish' ) {
671 431 if ( is_numeric( $args ) ) {
672 - // For reverse compatibility. $limit was changed to $args
432 + // for reverse compatibility. $limit was changed to $args
673 433 $args = array(
674 434 'limit' => $args,
675 435 );
676 436 }
677 -
678 437 $defaults = array(
679 438 'limit' => 99,
680 439 'post_status' => $default_status,
681 440 );
682 - $args = wp_parse_args( $args, $defaults );
441 + $args = wp_parse_args( $args, $defaults );
683 442 }
684 443
685 444 /**
686 - * @param int $action_id
687 - * @param string $type
688 - *
689 - * @return bool|object
445 + * @param int $action_id
690 446 */
691 447 public static function get_single_action_type( $action_id, $type ) {
692 448 if ( ! $type ) {
693 449 return false;
694 450 }
695 -
696 - /**
697 - * @var FrmFormAction
698 - */
699 451 $action_control = FrmFormActionsController::get_form_actions( $type );
700 -
701 452 return $action_control->get_single_action( $action_id );
702 453 }
703 454
704 455 /**
705 - * @param int $form_id
706 - * @param string $type
707 - *
456 + * @param int $form_id
708 457 * @return bool
709 458 */
710 459 public static function form_has_action_type( $form_id, $type ) {
711 - $actions = self::get_action_for_form( $form_id, $type );
712 - return ! empty( $actions );
460 + $payment_actions = self::get_action_for_form( $form_id, $type );
461 + return ! empty( $payment_actions );
713 462 }
714 463
715 - /**
716 - * @param false|int|string $form_id
717 - * @param array $atts
718 - *
719 - * @return array
720 - */
721 464 public function get_all( $form_id = false, $atts = array() ) {
722 - if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) {
723 - $atts['limit'] = $this->action_options['limit'];
724 - }
725 -
726 465 self::prepare_get_action( $atts, 'any' );
727 -
728 466 $limit = $atts['limit'];
729 467
730 - if ( $form_id ) {
731 - $this->form_id = $form_id;
732 - }
468 + if ( $form_id ) {
469 + $this->form_id = $form_id;
470 + }
733 471
734 - $type = $this->id_base;
472 + $type = $this->id_base;
735 473
736 - global $frm_vars;
737 - $frm_vars['action_type'] = $type;
474 + global $frm_vars;
475 + $frm_vars['action_type'] = $type;
738 476
739 477 add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
740 - $query = self::action_args( $form_id, $limit );
741 - $query['post_status'] = $atts['post_status'];
742 - $query['suppress_filters'] = false;
478 + $query = self::action_args( $form_id, $limit );
479 + $query['post_status'] = $atts['post_status'];
480 + $query['suppress_filters'] = false;
743 481
744 - $actions = FrmDb::check_cache( json_encode( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
482 + $actions = FrmDb::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
745 483 unset( $query );
746 484
747 485 remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
748 486
749 - if ( ! $actions ) {
750 - return array();
751 - }
487 + if ( empty( $actions ) ) {
488 + return array();
489 + }
752 490
753 - $settings = array();
491 + $settings = array();
492 + foreach ( $actions as $action ) {
493 + if ( count( $settings ) >= $limit ) {
494 + continue;
495 + }
754 496
755 - foreach ( $actions as $action ) {
756 - if ( count( $settings ) >= $limit ) {
757 - continue;
758 - }
497 + $action = $this->prepare_action( $action );
759 498
760 - $action = $this->prepare_action( $action );
761 499 $settings[ $action->ID ] = $action;
762 - }
500 + }
763 501
764 - return 1 === $limit ? reset( $settings ) : $settings;
502 + if ( 1 === $limit ) {
503 + $settings = reset( $settings );
504 + }
505 +
506 + return $settings;
765 507 }
766 508
767 - /**
768 - * @param int|string $form_id
769 - * @param int $limit
770 - *
771 - * @return array
772 - */
773 509 public static function action_args( $form_id = 0, $limit = 99 ) {
774 510 $args = array(
775 511 'post_type' => FrmFormActionsController::$action_post_type,
776 512 'post_status' => 'publish',
@@ -778,9 +514,9 @@
778 514 'orderby' => 'title',
779 515 'order' => 'ASC',
780 516 );
781 517
782 - if ( $form_id && $form_id !== 'all' ) {
518 + if ( $form_id && $form_id != 'all' ) {
783 519 $args['menu_order'] = $form_id;
784 520 }
785 521
786 522 return $args;
@@ -785,66 +521,51 @@
785 521
786 522 return $args;
787 523 }
788 524
789 - /**
790 - * @param WP_Post $action
791 - *
792 - * @return WP_Post
793 - */
794 525 public function prepare_action( $action ) {
795 526 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
796 527 $action->post_excerpt = sanitize_title( $action->post_excerpt );
797 528
798 - $default_values = $this->get_global_defaults();
529 + $default_values = $this->get_global_defaults();
799 530
800 - // Fill default values
801 - $action->post_content += $default_values;
531 + // fill default values
532 + $action->post_content += $default_values;
802 533
803 - foreach ( $default_values as $k => $vals ) {
804 - if ( ! is_array( $vals ) || ! $vals ) {
805 - continue;
806 - }
534 + foreach ( $default_values as $k => $vals ) {
535 + if ( is_array( $vals ) && ! empty( $vals ) ) {
536 + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
537 + continue;
538 + }
539 + $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
540 + }
541 + }
807 542
808 - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
809 - continue;
810 - }
811 - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
812 - }
813 -
814 543 if ( ! is_array( $action->post_content['event'] ) ) {
815 544 $action->post_content['event'] = explode( ',', $action->post_content['event'] );
816 545 }
817 546
818 - return $action;
547 + return $action;
819 548 }
820 549
821 - /**
822 - * @param false|int|string $form_id
823 - * @param string $type
824 - *
825 - * @return void
826 - */
827 550 public function destroy( $form_id = false, $type = 'default' ) {
828 - global $wpdb;
551 + global $wpdb;
829 552
830 - $this->form_id = $form_id;
553 + $this->form_id = $form_id;
831 554
832 - $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
555 + $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
556 + if ( $form_id ) {
557 + $query['menu_order'] = $form_id;
558 + }
559 + if ( 'all' != $type ) {
560 + $query['post_excerpt'] = $this->id_base;
561 + }
833 562
834 - if ( $form_id ) {
835 - $query['menu_order'] = $form_id;
836 - }
563 + $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
837 564
838 - if ( 'all' !== $type ) {
839 - $query['post_excerpt'] = $this->id_base;
840 - }
841 -
842 - $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
843 -
844 - foreach ( $post_ids as $id ) {
565 + foreach ( $post_ids as $id ) {
845 566 wp_delete_post( $id );
846 - }
567 + }
847 568 self::clear_cache();
848 569 }
849 570
850 571 /**
@@ -850,184 +571,184 @@
850 571 /**
851 572 * Delete the action cache when a form action is created, deleted, or updated
852 573 *
853 574 * @since 2.0.5
854 - *
855 - * @return void
856 575 */
857 576 public static function clear_cache() {
858 577 FrmDb::cache_delete_group( 'frm_actions' );
859 578 }
860 579
861 - /**
862 - * @return array
863 - */
864 580 public function get_settings() {
865 581 return self::get_action_for_form( $this->form_id, $this->id_base );
866 582 }
867 583
868 - /**
869 - * @return array
870 - */
871 584 public function get_global_defaults() {
872 - $defaults = $this->get_defaults();
585 + $defaults = $this->get_defaults();
873 586
874 587 if ( ! isset( $defaults['event'] ) ) {
875 588 $defaults['event'] = array( 'create' );
876 - }
589 + }
877 590
878 591 if ( ! isset( $defaults['conditions'] ) ) {
879 - $defaults['conditions'] = array(
880 - 'send_stop' => '',
881 - 'any_all' => '',
882 - );
883 - }
592 + $defaults['conditions'] = array(
593 + 'send_stop' => '',
594 + 'any_all' => '',
595 + );
596 + }
884 597
885 - return $defaults;
598 + return $defaults;
886 599 }
887 600
888 - /**
889 - * @return array
890 - */
891 601 public function get_global_switch_fields() {
892 - $switch = $this->get_switch_fields();
602 + $switch = $this->get_switch_fields();
893 603 $switch['conditions'] = array( 'hide_field' );
894 -
895 - return apply_filters( 'frm_global_switch_fields', $switch );
604 + return $switch;
896 605 }
897 606
898 607 /**
899 608 * Migrate settings from form->options into new action.
900 - *
901 - * @param object $form
902 - * @param string $update
903 - *
904 - * @return int|WP_Error
905 609 */
906 610 public function migrate_to_2( $form, $update = 'update' ) {
907 611 $action = $this->prepare_new( $form->id );
908 - FrmAppHelper::unserialize_or_decode( $form->options );
612 + $form->options = maybe_unserialize( $form->options );
909 613
910 - // Fill with existing options
911 - foreach ( $action->post_content as $name => $val ) {
912 - if ( ! isset( $form->options[ $name ] ) ) {
913 - continue;
914 - }
614 + // fill with existing options
615 + foreach ( $action->post_content as $name => $val ) {
616 + if ( isset( $form->options[ $name ] ) ) {
617 + $action->post_content[ $name ] = $form->options[ $name ];
618 + unset( $form->options[ $name ] );
619 + }
620 + }
915 621
916 - $action->post_content[ $name ] = $form->options[ $name ];
917 - unset( $form->options[ $name ] );
918 - }
919 -
920 622 $action = $this->migrate_values( $action, $form );
921 623
922 - // Check if action already exists
624 + // check if action already exists
923 625 $post_id = get_posts(
924 626 array(
925 - 'name' => $action->post_name,
926 - 'post_type' => FrmFormActionsController::$action_post_type,
927 - 'post_status' => $action->post_status,
928 - 'numberposts' => 1,
627 + 'name' => $action->post_name,
628 + 'post_type' => FrmFormActionsController::$action_post_type,
629 + 'post_status' => $action->post_status,
630 + 'numberposts' => 1,
929 631 )
930 632 );
931 633
932 - if ( ! $post_id ) {
933 - // Create action now
634 + if ( empty( $post_id ) ) {
635 + // create action now
934 636 $post_id = $this->save_settings( $action );
935 637 }
936 638
937 - if ( ! $post_id || 'update' !== $update ) {
938 - return $post_id;
639 + if ( $post_id && 'update' == $update ) {
640 + global $wpdb;
641 + $form->options = maybe_serialize( $form->options );
642 +
643 + // update form options
644 + $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
645 + FrmForm::clear_form_cache();
646 + }
647 +
648 + return $post_id;
649 + }
650 +
651 + public static function action_conditions_met( $action, $entry ) {
652 + $notification = $action->post_content;
653 + $stop = false;
654 + $met = array();
655 +
656 + if ( ! isset( $notification['conditions'] ) || empty( $notification['conditions'] ) ) {
657 + return $stop;
939 658 }
940 659
941 - global $wpdb;
942 - $form->options = maybe_serialize( $form->options );
660 + foreach ( $notification['conditions'] as $k => $condition ) {
661 + if ( ! is_numeric( $k ) ) {
662 + continue;
663 + }
943 664
944 - // Update form options
945 - $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
946 - FrmForm::clear_form_cache();
665 + if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) {
666 + continue;
667 + }
947 668
948 - return $post_id;
669 + self::prepare_logic_value( $condition['hide_opt'] );
670 +
671 + $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
672 +
673 + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
674 +
675 + if ( $notification['conditions']['send_stop'] == 'send' ) {
676 + $stop = $stop ? false : true;
677 + }
678 +
679 + $met[ $stop ] = $stop;
680 + }
681 +
682 + if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
683 + $stop = ( $notification['conditions']['send_stop'] == 'send' );
684 + } elseif ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) {
685 + $stop = false;
686 + }
687 +
688 + return $stop;
949 689 }
950 690
951 691 /**
952 - * @param WP_Post $action
953 - * @param stdClass $entry
692 + * Prepare the logic value for comparison against the entered value
954 693 *
955 - * @return bool
694 + * @since 2.01.02
695 + * @param array|string $logic_value
956 696 */
957 - public static function action_conditions_met( $action, $entry ) {
958 - if ( is_callable( 'FrmProFormActionsController::action_conditions_met' ) ) {
959 - return FrmProFormActionsController::action_conditions_met( $action, $entry );
697 + private static function prepare_logic_value( &$logic_value ) {
698 + if ( is_array( $logic_value ) ) {
699 + $logic_value = reset( $logic_value );
960 700 }
961 - return false;
701 +
702 + if ( $logic_value == 'current_user' ) {
703 + $logic_value = get_current_user_id();
704 + }
962 705 }
963 706
707 +
964 708 /**
965 - * @param string $class
709 + * Get the value from a specific field and entry
966 710 *
967 - * @return array
711 + * @since 2.01.02
712 + * @param object $entry
713 + * @param int $field_id
714 + * @return array|bool|mixed|string
968 715 */
716 + private static function get_value_from_entry( $entry, $field_id ) {
717 + $observed_value = '';
718 +
719 + if ( isset( $entry->metas[ $field_id ] ) ) {
720 + $observed_value = $entry->metas[ $field_id ];
721 + } else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
722 + $field = FrmField::getOne( $field_id );
723 + $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value(
724 + $entry,
725 + $field,
726 + array(
727 + 'links' => false,
728 + 'truncate' => false,
729 + )
730 + );
731 + }
732 +
733 + return $observed_value;
734 + }
735 +
969 736 public static function default_action_opts( $class = '' ) {
970 737 return array(
971 - 'classes' => 'frmfont ' . $class,
972 - 'active' => false,
973 - 'limit' => 0,
738 + 'classes' => 'frm_icon_font ' . $class,
739 + 'active' => false,
740 + 'limit' => 0,
974 741 );
975 742 }
976 743
977 - /**
978 - * @return array
979 - */
980 744 public static function trigger_labels() {
981 745 $triggers = array(
982 - 'draft' => __( 'Draft is saved', 'formidable' ),
983 - 'create' => __( 'Entry is created', 'formidable' ),
984 - 'update' => __( 'Entry is updated', 'formidable' ),
985 - 'delete' => __( 'Entry is deleted', 'formidable' ),
986 - 'import' => __( 'Entry is imported', 'formidable' ),
746 + 'draft' => __( 'Save Draft', 'formidable' ),
747 + 'create' => __( 'Create', 'formidable' ),
748 + 'update' => __( 'Update', 'formidable' ),
749 + 'delete' => __( 'Delete', 'formidable' ),
750 + 'import' => __( 'Import', 'formidable' ),
987 751 );
988 -
989 752 return apply_filters( 'frm_action_triggers', $triggers );
990 - }
991 -
992 - /**
993 - * @return void
994 - */
995 - public function render_conditional_logic_call_to_action() {
996 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
997 - ?>
998 - <h3>
999 - <a href="javascript:void(0)" class="frm_show_upgrade frm_noallow" data-upgrade="<?php echo esc_attr( $this->get_upgrade_text() ); ?>" data-medium="conditional-<?php echo esc_attr( $this->id_base ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
1000 - <?php esc_html_e( 'Use Conditional Logic', 'formidable' ); ?>
1001 - </a>
1002 - </h3>
1003 - <?php
1004 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1005 - }
1006 -
1007 - /**
1008 - * @return string
1009 - */
1010 - protected function get_upgrade_text() {
1011 - return __( 'Conditional form actions', 'formidable' );
1012 - }
1013 -
1014 - /**
1015 - * Gets form fields for form action settings.
1016 - *
1017 - * @since 6.10
1018 - *
1019 - * @param int $form_id Form ID.
1020 - *
1021 - * @return object[]
1022 - */
1023 - protected function get_form_fields( $form_id ) {
1024 - // Get form fields, include embedded and repeater child fields.
1025 - $form_fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1026 - return array_filter(
1027 - $form_fields,
1028 - function ( $form_field ) {
1029 - return ! FrmField::is_no_save_field( $form_field->type );
1030 - }
1031 - );
1032 753 }
1033 754 }