@@ -2,16 +2,16 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormAction { |
| 4 | 4 | |
| 5 | - public $id_base; // Root id for all actions of this type. |
|
| 6 | - public $name; // Name for this action type. |
|
| 5 | + public $id_base; // Root id for all actions of this type. |
|
| 6 | + public $name; // Name for this action type. |
|
| 7 | 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() |
|
| 8 | + public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
| 9 | + public $control_options; // Option array passed to wp_register_widget_control() |
|
| 10 | 10 | |
| 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. |
|
| 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. |
|
| 15 | 15 | |
| 16 | 16 | // Member functions that you must over-ride. |
| 17 | 17 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * - height: currently not used but may be needed in the future |
| 70 | 70 | */ |
| 71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
| 72 | - if ( ! defined('ABSPATH') ) { |
|
| 73 | - die('You are not allowed to call this page directly.'); |
|
| 72 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 73 | + die( 'You are not allowed to call this page directly.' ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->id_base = strtolower($id_base); |
|
| 76 | + $this->id_base = strtolower( $id_base ); |
|
| 77 | 77 | $this->name = $name; |
| 78 | 78 | $this->option_name = 'frm_' . $this->id_base . '_action'; |
| 79 | 79 | |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $default_values = $this->get_global_defaults(); |
| 144 | 144 | |
| 145 | 145 | // fill default values |
| 146 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
| 146 | + $post_content = wp_parse_args( $post_content, $default_values ); |
|
| 147 | 147 | |
| 148 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
| 149 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
| 148 | + if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) { |
|
| 149 | + $post_content['event'] = array( reset( $this->action_options['event'] ) ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $form_action = array( |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
| 160 | 160 | 'menu_order' => $this->form_id, |
| 161 | 161 | ); |
| 162 | - unset($post_content); |
|
| 162 | + unset( $post_content ); |
|
| 163 | 163 | |
| 164 | 164 | return (object) $form_action; |
| 165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $action = $this->prepare_new(); |
| 171 | 171 | |
| 172 | - return $this->save_settings($action); |
|
| 172 | + return $this->save_settings( $action ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function duplicate_form_actions( $form_id, $old_id ) { |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $this->form_id = $form_id; |
| 185 | 185 | foreach ( $actions as $action ) { |
| 186 | - $this->duplicate_one($action, $form_id); |
|
| 187 | - unset($action); |
|
| 186 | + $this->duplicate_one( $action, $form_id ); |
|
| 187 | + unset( $action ); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | * @return integer $post_id |
| 197 | 197 | */ |
| 198 | 198 | public function maybe_create_action( $action, $forms ) { |
| 199 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
| 199 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
| 200 | 200 | // Update action only |
| 201 | 201 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
| 202 | 202 | $post_id = $this->save_settings( $action ); |
| 203 | 203 | } else { |
| 204 | 204 | // Create action |
| 205 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
| 206 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
| 205 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
| 206 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] ); |
|
| 207 | 207 | } |
| 208 | 208 | return $post_id; |
| 209 | 209 | } |
@@ -214,47 +214,47 @@ discard block |
||
| 214 | 214 | $action->menu_order = $form_id; |
| 215 | 215 | $switch = $this->get_global_switch_fields(); |
| 216 | 216 | foreach ( (array) $action->post_content as $key => $val ) { |
| 217 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
| 218 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
| 217 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
| 218 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
| 219 | 219 | } else if ( ! is_array( $val ) ) { |
| 220 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 221 | - } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
| 220 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 221 | + } else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
| 222 | 222 | // loop through each value if empty |
| 223 | - if ( empty( $switch[ $key ] ) ) { |
|
| 224 | - $switch[ $key ] = array_keys( $val ); |
|
| 223 | + if ( empty( $switch[$key] ) ) { |
|
| 224 | + $switch[$key] = array_keys( $val ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - foreach ( $switch[ $key ] as $subkey ) { |
|
| 228 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
| 227 | + foreach ( $switch[$key] as $subkey ) { |
|
| 228 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - unset($key, $val); |
|
| 232 | + unset( $key, $val ); |
|
| 233 | 233 | } |
| 234 | - unset($action->ID); |
|
| 234 | + unset( $action->ID ); |
|
| 235 | 235 | |
| 236 | - return $this->save_settings($action); |
|
| 236 | + return $this->save_settings( $action ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | private function duplicate_array_walk( $action, $subkey, $val ) { |
| 240 | 240 | global $frm_duplicate_ids; |
| 241 | 241 | |
| 242 | - if ( is_array($subkey) ) { |
|
| 242 | + if ( is_array( $subkey ) ) { |
|
| 243 | 243 | foreach ( $subkey as $subkey2 ) { |
| 244 | 244 | foreach ( (array) $val as $ck => $cv ) { |
| 245 | - if ( is_array($cv) ) { |
|
| 246 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
| 247 | - } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
| 248 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
| 245 | + if ( is_array( $cv ) ) { |
|
| 246 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
| 247 | + } else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
| 248 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | } else { |
| 253 | 253 | foreach ( (array) $val as $ck => $cv ) { |
| 254 | - if ( is_array($cv) ) { |
|
| 255 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
| 256 | - } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
| 257 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
| 254 | + if ( is_array( $cv ) ) { |
|
| 255 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
| 256 | + } else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
| 257 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
| 282 | - $settings = $_POST[ $this->option_name ]; |
|
| 281 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
| 282 | + $settings = $_POST[$this->option_name]; |
|
| 283 | 283 | } else { |
| 284 | 284 | return; |
| 285 | 285 | } |
@@ -287,19 +287,19 @@ discard block |
||
| 287 | 287 | $action_ids = array(); |
| 288 | 288 | |
| 289 | 289 | foreach ( $settings as $number => $new_instance ) { |
| 290 | - $this->_set($number); |
|
| 290 | + $this->_set( $number ); |
|
| 291 | 291 | |
| 292 | - if ( ! isset($new_instance['post_title']) ) { |
|
| 292 | + if ( ! isset( $new_instance['post_title'] ) ) { |
|
| 293 | 293 | // settings were never opened, so don't update |
| 294 | 294 | $action_ids[] = $new_instance['ID']; |
| 295 | 295 | $this->updated = true; |
| 296 | 296 | continue; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
| 299 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
| 300 | 300 | |
| 301 | - $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
| 302 | - $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
| 301 | + $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
| 302 | + $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
| 303 | 303 | $new_instance['menu_order'] = $this->form_id; |
| 304 | 304 | $new_instance['post_status'] = 'publish'; |
| 305 | 305 | $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this ); |
| 323 | 323 | |
| 324 | - $instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this); |
|
| 324 | + $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
|
| 325 | 325 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
| 326 | 326 | |
| 327 | 327 | if ( false !== $instance ) { |
| 328 | - $all_instances[ $number ] = $instance; |
|
| 328 | + $all_instances[$number] = $instance; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $action_ids[] = $this->save_settings($instance); |
|
| 331 | + $action_ids[] = $this->save_settings( $instance ); |
|
| 332 | 332 | |
| 333 | 333 | $this->updated = true; |
| 334 | 334 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | public function get_single_action( $id ) { |
| 345 | - $action = get_post($id); |
|
| 345 | + $action = get_post( $id ); |
|
| 346 | 346 | if ( $action ) { |
| 347 | 347 | $action = $this->prepare_action( $action ); |
| 348 | 348 | $this->_set( $id ); |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public function get_one( $form_id ) { |
| 354 | - return $this->get_all($form_id, 1); |
|
| 354 | + return $this->get_all( $form_id, 1 ); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
| 358 | 358 | $action_controls = FrmFormActionsController::get_form_actions( $type ); |
| 359 | - if ( empty($action_controls) ) { |
|
| 359 | + if ( empty( $action_controls ) ) { |
|
| 360 | 360 | // don't continue if there are no available actions |
| 361 | 361 | return array(); |
| 362 | 362 | } |
@@ -377,12 +377,12 @@ discard block |
||
| 377 | 377 | // some plugins/themes are formatting the post_excerpt |
| 378 | 378 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 379 | 379 | |
| 380 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
| 380 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
| 381 | 381 | continue; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
| 385 | - $settings[ $action->ID ] = $action; |
|
| 384 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
| 385 | + $settings[$action->ID] = $action; |
|
| 386 | 386 | |
| 387 | 387 | if ( count( $settings ) >= $limit ) { |
| 388 | 388 | break; |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | if ( 1 === $limit ) { |
| 393 | - $settings = reset($settings); |
|
| 393 | + $settings = reset( $settings ); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | return $settings; |
@@ -423,33 +423,33 @@ discard block |
||
| 423 | 423 | global $frm_vars; |
| 424 | 424 | $frm_vars['action_type'] = $type; |
| 425 | 425 | |
| 426 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 426 | + add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
| 427 | 427 | $query = self::action_args( $form_id, $limit ); |
| 428 | 428 | $query['post_status'] = 'any'; |
| 429 | 429 | $query['suppress_filters'] = false; |
| 430 | 430 | |
| 431 | 431 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
| 432 | - unset($query); |
|
| 432 | + unset( $query ); |
|
| 433 | 433 | |
| 434 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 434 | + remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
| 435 | 435 | |
| 436 | - if ( empty($actions) ) { |
|
| 436 | + if ( empty( $actions ) ) { |
|
| 437 | 437 | return array(); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $settings = array(); |
| 441 | 441 | foreach ( $actions as $action ) { |
| 442 | - if ( count($settings) >= $limit ) { |
|
| 442 | + if ( count( $settings ) >= $limit ) { |
|
| 443 | 443 | continue; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $action = $this->prepare_action($action); |
|
| 446 | + $action = $this->prepare_action( $action ); |
|
| 447 | 447 | |
| 448 | - $settings[ $action->ID ] = $action; |
|
| 448 | + $settings[$action->ID] = $action; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | if ( 1 === $limit ) { |
| 452 | - $settings = reset($settings); |
|
| 452 | + $settings = reset( $settings ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | return $settings; |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | public function prepare_action( $action ) { |
| 475 | - $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
|
| 475 | + $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content ); |
|
| 476 | 476 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 477 | 477 | |
| 478 | 478 | $default_values = $this->get_global_defaults(); |
@@ -481,16 +481,16 @@ discard block |
||
| 481 | 481 | $action->post_content += $default_values; |
| 482 | 482 | |
| 483 | 483 | foreach ( $default_values as $k => $vals ) { |
| 484 | - if ( is_array($vals) && ! empty($vals) ) { |
|
| 485 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
| 484 | + if ( is_array( $vals ) && ! empty( $vals ) ) { |
|
| 485 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
| 486 | 486 | continue; |
| 487 | 487 | } |
| 488 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
| 488 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( ! is_array($action->post_content['event']) ) { |
|
| 493 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
| 492 | + if ( ! is_array( $action->post_content['event'] ) ) { |
|
| 493 | + $action->post_content['event'] = explode( ',', $action->post_content['event'] ); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $action; |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
| 513 | 513 | |
| 514 | 514 | foreach ( $post_ids as $id ) { |
| 515 | - wp_delete_post($id); |
|
| 515 | + wp_delete_post( $id ); |
|
| 516 | 516 | } |
| 517 | 517 | self::clear_cache(); |
| 518 | 518 | } |
@@ -533,11 +533,11 @@ discard block |
||
| 533 | 533 | public function get_global_defaults() { |
| 534 | 534 | $defaults = $this->get_defaults(); |
| 535 | 535 | |
| 536 | - if ( ! isset($defaults['event']) ) { |
|
| 536 | + if ( ! isset( $defaults['event'] ) ) { |
|
| 537 | 537 | $defaults['event'] = array( 'create' ); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if ( ! isset($defaults['conditions']) ) { |
|
| 540 | + if ( ! isset( $defaults['conditions'] ) ) { |
|
| 541 | 541 | $defaults['conditions'] = array( |
| 542 | 542 | 'send_stop' => '', |
| 543 | 543 | 'any_all' => '', |
@@ -557,18 +557,18 @@ discard block |
||
| 557 | 557 | * Migrate settings from form->options into new action. |
| 558 | 558 | */ |
| 559 | 559 | public function migrate_to_2( $form, $update = 'update' ) { |
| 560 | - $action = $this->prepare_new($form->id); |
|
| 561 | - $form->options = maybe_unserialize($form->options); |
|
| 560 | + $action = $this->prepare_new( $form->id ); |
|
| 561 | + $form->options = maybe_unserialize( $form->options ); |
|
| 562 | 562 | |
| 563 | 563 | // fill with existing options |
| 564 | 564 | foreach ( $action->post_content as $name => $val ) { |
| 565 | - if ( isset( $form->options[ $name ] ) ) { |
|
| 566 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
| 567 | - unset( $form->options[ $name ] ); |
|
| 565 | + if ( isset( $form->options[$name] ) ) { |
|
| 566 | + $action->post_content[$name] = $form->options[$name]; |
|
| 567 | + unset( $form->options[$name] ); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - $action = $this->migrate_values($action, $form); |
|
| 571 | + $action = $this->migrate_values( $action, $form ); |
|
| 572 | 572 | |
| 573 | 573 | // check if action already exists |
| 574 | 574 | $post_id = get_posts( array( |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | 'numberposts' => 1, |
| 579 | 579 | ) ); |
| 580 | 580 | |
| 581 | - if ( empty($post_id) ) { |
|
| 581 | + if ( empty( $post_id ) ) { |
|
| 582 | 582 | // create action now |
| 583 | - $post_id = $this->save_settings($action); |
|
| 583 | + $post_id = $this->save_settings( $action ); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | if ( $post_id && 'update' == $update ) { |
| 587 | 587 | global $wpdb; |
| 588 | - $form->options = maybe_serialize($form->options); |
|
| 588 | + $form->options = maybe_serialize( $form->options ); |
|
| 589 | 589 | |
| 590 | 590 | // update form options |
| 591 | 591 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
| 592 | - wp_cache_delete( $form->id, 'frm_form'); |
|
| 592 | + wp_cache_delete( $form->id, 'frm_form' ); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | return $post_id; |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | continue; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if ( is_array($condition['hide_opt']) ) { |
|
| 617 | - $condition['hide_opt'] = reset($condition['hide_opt']); |
|
| 616 | + if ( is_array( $condition['hide_opt'] ) ) { |
|
| 617 | + $condition['hide_opt'] = reset( $condition['hide_opt'] ); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | if ( $condition['hide_opt'] == 'current_user' ) { |
@@ -623,18 +623,18 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] ); |
| 625 | 625 | |
| 626 | - $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); |
|
| 626 | + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] ); |
|
| 627 | 627 | |
| 628 | 628 | if ( $notification['conditions']['send_stop'] == 'send' ) { |
| 629 | 629 | $stop = $stop ? false : true; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - $met[ $stop ] = $stop; |
|
| 632 | + $met[$stop] = $stop; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
| 636 | - $stop = ($notification['conditions']['send_stop'] == 'send'); |
|
| 637 | - } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) { |
|
| 636 | + $stop = ( $notification['conditions']['send_stop'] == 'send' ); |
|
| 637 | + } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) { |
|
| 638 | 638 | $stop = false; |
| 639 | 639 | } |
| 640 | 640 | |
@@ -652,8 +652,8 @@ discard block |
||
| 652 | 652 | private static function get_value_from_entry( $entry, $field_id ) { |
| 653 | 653 | $observed_value = ''; |
| 654 | 654 | |
| 655 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
| 656 | - $observed_value = $entry->metas[ $field_id ]; |
|
| 655 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
| 656 | + $observed_value = $entry->metas[$field_id]; |
|
| 657 | 657 | } else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
| 658 | 658 | $field = FrmField::getOne( $field_id ); |
| 659 | 659 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field, array( 'links' => false, 'truncate' => false ) ); |