PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +58 -21 6.28 → trunk View file →
@@ -140,9 +140,17 @@
140 140 if ( ! defined( 'ABSPATH' ) ) {
141 141 die( 'You are not allowed to call this page directly.' );
142 142 }
143 143
144 - $this->id_base = strtolower( $id_base );
144 + $this->id_base = strtolower( $id_base );
145 +
146 + /**
147 + * @since 6.31
148 + *
149 + * @param string $name
150 + */
151 + $name = apply_filters( 'frm_' . $id_base . '_action_name', $name );
152 +
145 153 $this->name = $name;
146 154 $this->option_name = 'frm_' . $this->id_base . '_action';
147 155
148 156 $default_options = array(
@@ -157,8 +165,11 @@
157 165 'tooltip' => $name,
158 166 'group' => $id_base,
159 167 'color' => '',
160 168 'keywords' => '',
169 + 'description' => '',
170 + 'is_new' => false,
171 + 'is_beta' => false,
161 172 );
162 173
163 174 $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
164 175 $group = $this->get_group( $action_options );
@@ -164,11 +175,12 @@
164 175 $group = $this->get_group( $action_options );
165 176 $action_options['group'] = $group['id'];
166 177
167 178 if ( ! isset( $action_options['color'] ) ) {
168 - $colors = array( 'green', 'orange', 'purple' );
169 - shuffle( $colors );
170 - $action_options['color'] = 'var(--' . reset( $colors ) . ')';
179 + // Deterministic fallback so all instances of the same action type render with the same color across requests.
180 + $colors = array( 'green', 'orange', 'purple' );
181 + $index = abs( crc32( $id_base ) ) % count( $colors );
182 + $action_options['color'] = 'var(--' . $colors[ $index ] . ')';
171 183 }
172 184
173 185 $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
174 186
@@ -800,14 +812,16 @@
800 812 // Fill default values
801 813 $action->post_content += $default_values;
802 814
803 815 foreach ( $default_values as $k => $vals ) {
804 - if ( is_array( $vals ) && $vals ) {
805 - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
806 - continue;
807 - }
808 - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
816 + if ( ! is_array( $vals ) || ! $vals ) {
817 + continue;
809 818 }
819 +
820 + if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
821 + continue;
822 + }
823 + $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
810 824 }
811 825
812 826 if ( ! is_array( $action->post_content['event'] ) ) {
813 827 $action->post_content['event'] = explode( ',', $action->post_content['event'] );
@@ -906,12 +920,14 @@
906 920 FrmAppHelper::unserialize_or_decode( $form->options );
907 921
908 922 // Fill with existing options
909 923 foreach ( $action->post_content as $name => $val ) {
910 - if ( isset( $form->options[ $name ] ) ) {
911 - $action->post_content[ $name ] = $form->options[ $name ];
912 - unset( $form->options[ $name ] );
924 + if ( ! isset( $form->options[ $name ] ) ) {
925 + continue;
913 926 }
927 +
928 + $action->post_content[ $name ] = $form->options[ $name ];
929 + unset( $form->options[ $name ] );
914 930 }
915 931
916 932 $action = $this->migrate_values( $action, $form );
917 933
@@ -963,11 +979,12 @@
963 979 * @return array
964 980 */
965 981 public static function default_action_opts( $class = '' ) {
966 982 return array(
967 - 'classes' => 'frmfont ' . $class,
968 - 'active' => false,
969 - 'limit' => 0,
983 + 'classes' => 'frmfont ' . $class,
984 + 'active' => false,
985 + 'limit' => 0,
986 + 'description' => '',
970 987 );
971 988 }
972 989
973 990 /**
@@ -985,18 +1002,38 @@
985 1002 return apply_filters( 'frm_action_triggers', $triggers );
986 1003 }
987 1004
988 1005 /**
1006 + * @param string $action_key The unique key for this action instance.
1007 + *
989 1008 * @return void
990 1009 */
991 - public function render_conditional_logic_call_to_action() {
1010 + public function render_conditional_logic_call_to_action( $action_key = '' ) {
1011 + $params = array(
1012 + 'class' => 'frm-h-stack-xs frm-bt-200 frm-py-md frm_show_upgrade',
1013 + 'data-upgrade' => $this->get_upgrade_text(),
1014 + 'data-medium' => 'conditional-' . $this->id_base,
1015 + 'data-content' => 'conditional-logic',
1016 + );
992 1017 // phpcs:disable Generic.WhiteSpace.ScopeIndent
993 1018 ?>
994 - <h3>
995 - <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 ?>
996 - <?php esc_html_e( 'Use Conditional Logic', 'formidable' ); ?>
997 - </a>
998 - </h3>
1019 + <div <?php FrmAppHelper::array_to_html_params( $params, true ); ?>>
1020 + <?php
1021 + FrmHtmlHelper::toggle(
1022 + 'frm_logic_cta_' . $action_key,
1023 + 'frm_logic_cta_' . $action_key,
1024 + array(
1025 + 'div_class' => 'with_frm_style frm_toggle',
1026 + 'checked' => false,
1027 + 'echo' => true,
1028 + 'disabled' => true,
1029 + )
1030 + );
1031 + ?>
1032 + <label for="frm_logic_cta_<?php echo esc_attr( $action_key ); ?>" class="frm_noallow">
1033 + <?php esc_html_e( 'Use Conditional Logic', 'formidable' ); ?>
1034 + </label>
1035 + </div>
999 1036 <?php
1000 1037 // phpcs:enable Generic.WhiteSpace.ScopeIndent
1001 1038 }
1002 1039