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