| @@ -34,10 +34,9 @@ | ||
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Echo the settings update form |
| 37 | 37 | * |
| 38 | - * @param WP_Post $instance Current settings | |
| 39 | - * @param array $args | |
| 38 | + * @param array $instance Current settings | |
| 40 | 39 | */ |
| 41 | 40 | public function form( $instance, $args = array() ) { |
| 42 | 41 | echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>'; |
| 43 | 42 | |
| @@ -50,11 +49,8 @@ | ||
| 50 | 49 | public function get_defaults() { |
| 51 | 50 | return array(); |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | - /** | |
| 55 | - * @return array | |
| 56 | - */ | |
| 57 | 53 | public function get_switch_fields() { |
| 58 | 54 | return array(); |
| 59 | 55 | } |
| 60 | 56 | |
| @@ -97,9 +93,8 @@ | ||
| 97 | 93 | 'plugin' => $this->id_base, |
| 98 | 94 | 'tooltip' => $name, |
| 99 | 95 | 'group' => $id_base, |
| 100 | 96 | 'color' => '', |
| 101 | - 'keywords' => '', | |
| 102 | 97 | ); |
| 103 | 98 | |
| 104 | 99 | $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options ); |
| 105 | 100 | $group = $this->get_group( $action_options ); |
| @@ -110,9 +105,9 @@ | ||
| 110 | 105 | shuffle( $colors ); |
| 111 | 106 | $action_options['color'] = 'var(--' . reset( $colors ) . ')'; |
| 112 | 107 | } |
| 113 | 108 | |
| 114 | - $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade'; | |
| 109 | + $upgrade_class = $action_options['classes'] === 'frm_show_upgrade'; | |
| 115 | 110 | if ( $action_options['group'] === $id_base ) { |
| 116 | 111 | $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false; |
| 117 | 112 | $action_options['classes'] = $group['icon']; |
| 118 | 113 | } elseif ( ! isset( $action_options['classes'] ) || empty( $action_options['classes'] ) || $upgrade_class ) { |
| @@ -202,20 +197,15 @@ | ||
| 202 | 197 | public function get_field_id( $field_name ) { |
| 203 | 198 | return $field_name . '_' . $this->number; |
| 204 | 199 | } |
| 205 | 200 | |
| 206 | - /** | |
| 207 | - * @param int|string $number | |
| 208 | - * @return void | |
| 209 | - */ | |
| 201 | + // Private Function. Don't worry about this. | |
| 202 | + | |
| 210 | 203 | public function _set( $number ) { |
| 211 | 204 | $this->number = $number; |
| 212 | 205 | $this->id = $this->id_base . '-' . $number; |
| 213 | 206 | } |
| 214 | 207 | |
| 215 | - /** | |
| 216 | - * @return object | |
| 217 | - */ | |
| 218 | 208 | public function prepare_new( $form_id = false ) { |
| 219 | 209 | if ( $form_id ) { |
| 220 | 210 | $this->form_id = $form_id; |
| 221 | 211 | } |
| @@ -252,11 +242,8 @@ | ||
| 252 | 242 | |
| 253 | 243 | return $this->save_settings( $action ); |
| 254 | 244 | } |
| 255 | 245 | |
| 256 | - /** | |
| 257 | - * @return void | |
| 258 | - */ | |
| 259 | 246 | public function duplicate_form_actions( $form_id, $old_id ) { |
| 260 | 247 | if ( $form_id == $old_id ) { |
| 261 | 248 | // don't duplicate the actions if this is a template getting updated |
| 262 | 249 | return; |
| @@ -292,11 +279,8 @@ | ||
| 292 | 279 | |
| 293 | 280 | return $post_id; |
| 294 | 281 | } |
| 295 | 282 | |
| 296 | - /** | |
| 297 | - * @param object $action | |
| 298 | - */ | |
| 299 | 283 | public function duplicate_one( $action, $form_id ) { |
| 300 | 284 | global $frm_duplicate_ids; |
| 301 | 285 | |
| 302 | 286 | $action->menu_order = $form_id; |
| @@ -399,8 +383,9 @@ | ||
| 399 | 383 | $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
| 400 | 384 | $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
| 401 | 385 | $new_instance['menu_order'] = $this->form_id; |
| 402 | 386 | $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
| 387 | + | |
| 403 | 388 | $instance = $this->update( $new_instance, $old_instance ); |
| 404 | 389 | |
| 405 | 390 | /** |
| 406 | 391 | * Filter an action's settings before saving. |
| @@ -435,25 +420,19 @@ | ||
| 435 | 420 | /** |
| 436 | 421 | * If the status of the action has changed, update it |
| 437 | 422 | * |
| 438 | 423 | * @since 3.04 |
| 439 | - * | |
| 440 | - * @param array $new_instance | |
| 441 | - * @param stdClass|array $old_instance | |
| 442 | - * @return void | |
| 443 | 424 | */ |
| 444 | 425 | protected function maybe_update_status( $new_instance, $old_instance ) { |
| 445 | - if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) { | |
| 446 | - return; | |
| 426 | + if ( $new_instance['post_status'] !== $old_instance->post_status ) { | |
| 427 | + self::clear_cache(); | |
| 428 | + wp_update_post( | |
| 429 | + array( | |
| 430 | + 'ID' => $new_instance['ID'], | |
| 431 | + 'post_status' => $new_instance['post_status'], | |
| 432 | + ) | |
| 433 | + ); | |
| 447 | 434 | } |
| 448 | - | |
| 449 | - self::clear_cache(); | |
| 450 | - wp_update_post( | |
| 451 | - array( | |
| 452 | - 'ID' => $new_instance['ID'], | |
| 453 | - 'post_status' => $new_instance['post_status'], | |
| 454 | - ) | |
| 455 | - ); | |
| 456 | 435 | } |
| 457 | 436 | |
| 458 | 437 | public function save_settings( $settings ) { |
| 459 | 438 | self::clear_cache(); |
| @@ -523,13 +502,10 @@ | ||
| 523 | 502 | } |
| 524 | 503 | |
| 525 | 504 | /** |
| 526 | 505 | * @since 3.04 |
| 527 | - * | |
| 528 | 506 | * @param array $args |
| 529 | 507 | * @param string $default_status |
| 530 | - * | |
| 531 | - * @return void | |
| 532 | 508 | */ |
| 533 | 509 | protected static function prepare_get_action( &$args, $default_status = 'publish' ) { |
| 534 | 510 | if ( is_numeric( $args ) ) { |
| 535 | 511 | // for reverse compatibility. $limit was changed to $args |
| @@ -567,14 +543,9 @@ | ||
| 567 | 543 | return ! empty( $payment_actions ); |
| 568 | 544 | } |
| 569 | 545 | |
| 570 | 546 | public function get_all( $form_id = false, $atts = array() ) { |
| 571 | - if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) { | |
| 572 | - $atts['limit'] = $this->action_options['limit']; | |
| 573 | - } | |
| 574 | - | |
| 575 | 547 | self::prepare_get_action( $atts, 'any' ); |
| 576 | - | |
| 577 | 548 | $limit = $atts['limit']; |
| 578 | 549 | |
| 579 | 550 | if ( $form_id ) { |
| 580 | 551 | $this->form_id = $form_id; |
| @@ -616,11 +587,8 @@ | ||
| 616 | 587 | |
| 617 | 588 | return $settings; |
| 618 | 589 | } |
| 619 | 590 | |
| 620 | - /** | |
| 621 | - * @return array | |
| 622 | - */ | |
| 623 | 591 | public static function action_args( $form_id = 0, $limit = 99 ) { |
| 624 | 592 | $args = array( |
| 625 | 593 | 'post_type' => FrmFormActionsController::$action_post_type, |
| 626 | 594 | 'post_status' => 'publish', |
| @@ -635,11 +603,8 @@ | ||
| 635 | 603 | |
| 636 | 604 | return $args; |
| 637 | 605 | } |
| 638 | 606 | |
| 639 | - /** | |
| 640 | - * @param WP_Post|array $action | |
| 641 | - */ | |
| 642 | 607 | public function prepare_action( $action ) { |
| 643 | 608 | $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content ); |
| 644 | 609 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 645 | 610 | |
| @@ -649,9 +614,9 @@ | ||
| 649 | 614 | $action->post_content += $default_values; |
| 650 | 615 | |
| 651 | 616 | foreach ( $default_values as $k => $vals ) { |
| 652 | 617 | if ( is_array( $vals ) && ! empty( $vals ) ) { |
| 653 | - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { | |
| 618 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { | |
| 654 | 619 | continue; |
| 655 | 620 | } |
| 656 | 621 | $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
| 657 | 622 | } |
| @@ -663,11 +628,8 @@ | ||
| 663 | 628 | |
| 664 | 629 | return $action; |
| 665 | 630 | } |
| 666 | 631 | |
| 667 | - /** | |
| 668 | - * @return void | |
| 669 | - */ | |
| 670 | 632 | public function destroy( $form_id = false, $type = 'default' ) { |
| 671 | 633 | global $wpdb; |
| 672 | 634 | |
| 673 | 635 | $this->form_id = $form_id; |
| @@ -691,10 +653,8 @@ | ||
| 691 | 653 | /** |
| 692 | 654 | * Delete the action cache when a form action is created, deleted, or updated |
| 693 | 655 | * |
| 694 | 656 | * @since 2.0.5 |
| 695 | - * | |
| 696 | - * @return void | |
| 697 | 657 | */ |
| 698 | 658 | public static function clear_cache() { |
| 699 | 659 | FrmDb::cache_delete_group( 'frm_actions' ); |
| 700 | 660 | } |
| @@ -702,11 +662,8 @@ | ||
| 702 | 662 | public function get_settings() { |
| 703 | 663 | return self::get_action_for_form( $this->form_id, $this->id_base ); |
| 704 | 664 | } |
| 705 | 665 | |
| 706 | - /** | |
| 707 | - * @return array | |
| 708 | - */ | |
| 709 | 666 | public function get_global_defaults() { |
| 710 | 667 | $defaults = $this->get_defaults(); |
| 711 | 668 | |
| 712 | 669 | if ( ! isset( $defaults['event'] ) ) { |
| @@ -824,14 +781,11 @@ | ||
| 824 | 781 | /** |
| 825 | 782 | * Prepare the logic value for comparison against the entered value |
| 826 | 783 | * |
| 827 | 784 | * @since 2.01.02 |
| 828 | - * | |
| 829 | 785 | * @deprecated 4.06.02 |
| 830 | 786 | * |
| 831 | 787 | * @param array|string $logic_value |
| 832 | - * | |
| 833 | - * @return void | |
| 834 | 788 | */ |
| 835 | 789 | private static function prepare_logic_value( &$logic_value, $action, $entry ) { |
| 836 | 790 | if ( is_array( $logic_value ) ) { |
| 837 | 791 | $logic_value = reset( $logic_value ); |
| @@ -879,13 +833,8 @@ | ||
| 879 | 833 | |
| 880 | 834 | return $observed_value; |
| 881 | 835 | } |
| 882 | 836 | |
| 883 | - /** | |
| 884 | - * @param string $class | |
| 885 | - * | |
| 886 | - * @return array | |
| 887 | - */ | |
| 888 | 837 | public static function default_action_opts( $class = '' ) { |
| 889 | 838 | return array( |
| 890 | 839 | 'classes' => 'frm_icon_font ' . $class, |
| 891 | 840 | 'active' => false, |
| @@ -904,11 +853,8 @@ | ||
| 904 | 853 | |
| 905 | 854 | return apply_filters( 'frm_action_triggers', $triggers ); |
| 906 | 855 | } |
| 907 | 856 | |
| 908 | - /** | |
| 909 | - * @return void | |
| 910 | - */ | |
| 911 | 857 | public function render_conditional_logic_call_to_action() { |
| 912 | 858 | ?> |
| 913 | 859 | <h3> |
| 914 | 860 | <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 ); ?>"> |
| @@ -917,11 +863,8 @@ | ||
| 917 | 863 | </h3> |
| 918 | 864 | <?php |
| 919 | 865 | } |
| 920 | 866 | |
| 921 | - /** | |
| 922 | - * @return string | |
| 923 | - */ | |
| 924 | 867 | protected function get_upgrade_text() { |
| 925 | 868 | return __( 'Conditional form actions', 'formidable' ); |
| 926 | 869 | } |
| 927 | 870 | } |