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/controllers/FrmFormActionsController.php +429 -48 6.28 → trunk View file →
@@ -10,9 +10,9 @@
10 10 */
11 11 public static $action_post_type = 'frm_form_actions';
12 12
13 13 /**
14 - * @var array|null
14 + * @var Frm_Form_Action_Factory|null
15 15 */
16 16 public static $registered_actions;
17 17
18 18 /**
@@ -37,8 +37,9 @@
37 37 'has_archive' => false,
38 38 )
39 39 );
40 40
41 + self::maybe_setup_unlicensed_action_gate();
41 42 self::actions_init();
42 43 }
43 44
44 45 public static function actions_init() {
@@ -53,29 +54,33 @@
53 54 public static function register_actions() {
54 55 $action_classes = array(
55 56 'on_submit' => 'FrmOnSubmitAction',
56 57 'email' => 'FrmEmailAction',
58 + 'gated_content' => 'FrmGatedContentAction',
57 59 'wppost' => 'FrmDefPostAction',
58 60 'register' => 'FrmDefRegAction',
59 - 'paypal' => 'FrmDefPayPalAction',
61 + 'stripe' => 'FrmStripeLiteAction',
62 + 'square' => 'FrmSquareAction',
63 + 'paypal' => 'FrmPayPalLiteAction',
64 + 'paypal-legacy' => 'FrmDefPayPalLegacyAction',
60 65 'payment' => 'FrmTransLiteAction',
61 66 'quiz' => 'FrmDefQuizAction',
62 67 'quiz_outcome' => 'FrmDefQuizOutcomeAction',
68 + 'api' => 'FrmDefApiAction',
63 69 'mailchimp' => 'FrmDefMlcmpAction',
64 - 'api' => 'FrmDefApiAction',
65 - 'salesforce' => 'FrmDefSalesforceAction',
66 70 'activecampaign' => 'FrmDefActiveCampaignAction',
67 71 'constantcontact' => 'FrmDefConstContactAction',
68 72 'getresponse' => 'FrmDefGetResponseAction',
73 + 'mailpoet' => 'FrmDefMailpoetAction',
74 + 'convertkit' => 'FrmDefConvertKitAction',
75 + 'aweber' => 'FrmDefAweberAction',
76 + 'twilio' => 'FrmDefTwilioAction',
77 + 'salesforce' => 'FrmDefSalesforceAction',
69 78 'hubspot' => 'FrmDefHubspotAction',
79 + 'highrise' => 'FrmDefHighriseAction',
70 80 'zapier' => 'FrmDefZapierAction',
81 + 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
71 82 'n8n' => 'FrmDefN8NAction',
72 - 'twilio' => 'FrmDefTwilioAction',
73 - 'highrise' => 'FrmDefHighriseAction',
74 - 'mailpoet' => 'FrmDefMailpoetAction',
75 - 'aweber' => 'FrmDefAweberAction',
76 - 'convertkit' => 'FrmDefConvertKitAction',
77 - 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
78 83 );
79 84
80 85 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
81 86 $action_classes = self::maybe_unset_highrise( $action_classes );
@@ -82,14 +87,66 @@
82 87
83 88 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php';
84 89 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php';
85 90
91 + // This needs to be called after we include default_actions.php or FrmDefPayPalLegacyAction will never exist.
92 + if ( 'FrmPayPalLiteAction' === $action_classes['paypal'] || ! class_exists( 'FrmPaymentAction' ) || ! class_exists( 'FrmDefPayPalLegacyAction' ) ) {
93 + unset( $action_classes['paypal-legacy'] );
94 + }
95 +
86 96 foreach ( $action_classes as $action_class ) {
87 97 self::$registered_actions->register( $action_class );
88 98 }
99 +
100 + self::apply_default_action_descriptions();
89 101 }
90 102
91 103 /**
104 + * Sets default descriptions on registered actions from a central list.
105 + *
106 + * Keeps the description when an add-on replaces a base action class without its own.
107 + *
108 + * @since 6.31
109 + *
110 + * @return void
111 + */
112 + private static function apply_default_action_descriptions() {
113 + $descriptions = array(
114 + 'on_submit' => __( 'Success messages', 'formidable' ),
115 + 'email' => __( 'Autoresponder alerts', 'formidable' ),
116 + 'wppost' => __( 'Content publishing', 'formidable' ),
117 + 'register' => __( 'Account creation', 'formidable' ),
118 + 'payment' => __( 'Transaction alerts', 'formidable' ),
119 + 'stripe' => __( 'Payment gateway', 'formidable' ),
120 + 'square' => __( 'Payment gateway', 'formidable' ),
121 + 'paypal' => __( 'Payment gateway', 'formidable' ),
122 + 'quiz' => __( 'Automated grading', 'formidable' ),
123 + 'quiz_outcome' => __( 'Result logic', 'formidable' ),
124 + 'aweber' => __( 'List triggers', 'formidable' ),
125 + 'mailchimp' => __( 'Subscription confirmation', 'formidable' ),
126 + 'zapier' => __( 'App automation', 'formidable' ),
127 + 'n8n' => __( 'Workflow automation', 'formidable' ),
128 + 'twilio' => __( 'Text notifications', 'formidable' ),
129 + 'activecampaign' => __( 'Contact automation', 'formidable' ),
130 + 'salesforce' => __( 'Lead automation', 'formidable' ),
131 + 'constantcontact' => __( 'Content distribution', 'formidable' ),
132 + 'getresponse' => __( 'Success notifications', 'formidable' ),
133 + 'hubspot' => __( 'CRM alerts', 'formidable' ),
134 + 'mailpoet' => __( 'Plugin automation', 'formidable' ),
135 + 'api' => __( 'System integration', 'formidable' ),
136 + 'googlespreadsheet' => __( 'Spreadsheet sync', 'formidable' ),
137 + 'convertkit' => __( 'Broadcast publishing', 'formidable' ),
138 + 'gated_content' => __( 'Access control', 'formidable' ),
139 + );
140 +
141 + foreach ( self::$registered_actions->actions as $action ) {
142 + if ( $action->action_options['description'] === '' && isset( $descriptions[ $action->id_base ] ) ) {
143 + $action->action_options['description'] = $descriptions[ $action->id_base ];
144 + }
145 + }
146 + }
147 +
148 + /**
92 149 * Remove the Highrise action if it is not registered.
93 150 *
94 151 * @since 6.23
95 152 *
@@ -136,8 +193,19 @@
136 193 foreach ( $groups as $group ) {
137 194 if ( isset( $group['actions'] ) ) {
138 195 $grouped = array_merge( $grouped, $group['actions'] );
139 196 }
197 +
198 + // Also collect actions from sections
199 + if ( ! isset( $group['sections'] ) ) {
200 + continue;
201 + }
202 +
203 + foreach ( $group['sections'] as $section ) {
204 + if ( isset( $section['actions'] ) ) {
205 + $grouped = array_merge( $grouped, $section['actions'] );
206 + }
207 + }
140 208 }
141 209
142 210 foreach ( $action_controls as $action ) {
143 211 if ( isset( $groups[ $action->id_base ] ) || in_array( $action->id_base, $grouped, true ) ) {
@@ -164,31 +232,47 @@
164 232 *
165 233 * @return array
166 234 */
167 235 public static function form_action_groups() {
236 + // Get all action controls to check which are active
237 + $action_controls = self::get_form_actions();
238 +
239 + // Determine which actions are currently available
240 + $available_actions = self::get_available_my_actions( $action_controls );
241 +
242 + // Featured actions are add-ons that are NOT currently available
243 + $all_addon_actions = array(
244 + 'api',
245 + 'register',
246 + 'n8n',
247 + 'quiz',
248 + 'quiz_outcome',
249 + 'googlespreadsheet',
250 + );
251 + $featured_actions = array_diff( $all_addon_actions, $available_actions );
252 +
168 253 $groups = array(
169 - 'misc' => array(
170 - 'name' => '',
171 - 'icon' => 'frmfont frm_shuffle_icon',
172 - 'actions' => array(
173 - 'email',
174 - 'wppost',
175 - 'register',
176 - 'quiz',
177 - 'quiz_outcome',
178 - 'twilio',
254 + 'my_actions' => array(
255 + 'name' => __( 'My Actions', 'formidable' ),
256 + 'icon' => 'frmfont frm_shuffle_icon',
257 + 'sections' => array(
258 + 'active' => array(
259 + 'name' => '',
260 + 'actions' => $available_actions,
261 + ),
262 + 'featured' => array(
263 + 'name' => __( 'Featured', 'formidable' ),
264 + 'actions' => array_values( $featured_actions ),
265 + ),
179 266 ),
180 267 ),
181 - 'payment' => array(
182 - 'name' => __( 'eCommerce', 'formidable' ),
268 + 'payment' => array(
269 + 'name' => __( 'E-Commerce', 'formidable' ),
183 270 'icon' => 'frmfont frm_credit_card_alt_icon',
184 - 'actions' => array(
185 - 'paypal',
186 - 'payment',
187 - ),
271 + 'actions' => self::get_payment_actions( $action_controls ),
188 272 ),
189 - 'marketing' => array(
190 - 'name' => __( 'Email Marketing', 'formidable' ),
273 + 'marketing' => array(
274 + 'name' => __( 'Marketing', 'formidable' ),
191 275 'icon' => 'frmfont frm_mail_bulk_icon',
192 276 'actions' => array(
193 277 'mailchimp',
194 278 'activecampaign',
@@ -196,15 +280,21 @@
196 280 'getresponse',
197 281 'aweber',
198 282 'mailpoet',
199 283 'convertkit',
284 + 'twilio',
200 285 ),
201 286 ),
202 - 'crm' => array(
287 + 'crm' => array(
203 288 'name' => __( 'CRM', 'formidable' ),
204 289 'icon' => 'frmfont frm_address_card_icon',
205 290 'actions' => self::get_crm_actions(),
206 291 ),
292 + 'misc' => array(
293 + 'name' => __( 'Misc', 'formidable' ),
294 + 'icon' => 'frmfont frm_shuffle_icon',
295 + 'actions' => self::get_misc_actions( $action_controls ),
296 + ),
207 297 );
208 298
209 299 return apply_filters( 'frm_action_groups', $groups );
210 300 }
@@ -209,8 +299,102 @@
209 299 return apply_filters( 'frm_action_groups', $groups );
210 300 }
211 301
212 302 /**
303 + * Get the actions that are currently available (active) for My Actions section.
304 + *
305 + * @since 6.31
306 + *
307 + * @param array $action_controls The registered action controls.
308 + *
309 + * @return array
310 + */
311 + private static function get_available_my_actions( $action_controls ) {
312 + $available = array(
313 + 'on_submit',
314 + 'email',
315 + 'stripe',
316 + 'square',
317 + 'paypal',
318 + );
319 +
320 + // Include all actions that are marked as active, including custom actions.
321 + // This ensures custom actions appear in "My Actions" when enabled.
322 + foreach ( $action_controls as $action_id => $action_control ) {
323 + if ( ! in_array( $action_id, $available, true ) && ! empty( $action_control->action_options['active'] ) ) {
324 + $available[] = $action_id;
325 + }
326 + }
327 +
328 + return $available;
329 + }
330 +
331 + /**
332 + * Get the actions to include in the Misc section.
333 + *
334 + * @since 6.31
335 + *
336 + * @param array $action_controls The registered action controls.
337 + *
338 + * @return array
339 + */
340 + private static function get_misc_actions( $action_controls ) {
341 + $misc_actions = array(
342 + 'on_submit',
343 + 'email',
344 + 'wppost',
345 + 'register',
346 + 'api',
347 + 'n8n',
348 + 'quiz',
349 + 'quiz_outcome',
350 + 'googlespreadsheet',
351 + );
352 +
353 + // Include all active actions that aren't in specific groups (payment, marketing, crm).
354 + // This ensures custom actions appear in "Misc" when enabled.
355 + $payment_actions = self::get_payment_actions( $action_controls );
356 + $marketing_actions = array( 'mailchimp', 'activecampaign', 'constantcontact', 'getresponse', 'aweber', 'mailpoet', 'convertkit', 'twilio' );
357 +
358 + $excluded_actions = array_merge( $payment_actions, $marketing_actions, self::get_crm_actions() );
359 +
360 + foreach ( $action_controls as $action_id => $action_control ) {
361 + if ( ! in_array( $action_id, $misc_actions, true ) && ! in_array( $action_id, $excluded_actions, true ) && ! empty( $action_control->action_options['active'] ) ) {
362 + $misc_actions[] = $action_id;
363 + }
364 + }
365 +
366 + return $misc_actions;
367 + }
368 +
369 + /**
370 + * Get the actions to include in the E-Commerce section.
371 + *
372 + * @since 6.33
373 + *
374 + * @param array $action_controls
375 + *
376 + * @return array
377 + */
378 + private static function get_payment_actions( $action_controls ) {
379 + $payment_actions = array(
380 + 'paypal',
381 + 'stripe',
382 + 'square',
383 + );
384 +
385 + if ( isset( $action_controls['paypal-legacy'] ) ) {
386 + $payment_actions[] = 'paypal-legacy';
387 + }
388 +
389 + if ( isset( $action_controls['payment'] ) ) {
390 + $payment_actions[] = 'payment';
391 + }
392 +
393 + return $payment_actions;
394 + }
395 +
396 + /**
213 397 * Get the actions to include in the CRM section.
214 398 *
215 399 * @since 6.23
216 400 *
@@ -219,8 +403,9 @@
219 403 private static function get_crm_actions() {
220 404 $crm_actions = array(
221 405 'salesforce',
222 406 'hubspot',
407 + 'zapier',
223 408 );
224 409
225 410 // Only include Highrise when the add-on is active.
226 411 // This is because Highrise is deprecated. We don't want to show it in Lite.
@@ -277,8 +462,12 @@
277 462 $classes .= ' frm_active_action';
278 463 } else {
279 464 $classes .= ' frm_inactive_action';
280 465
466 + if ( str_contains( $action_control->action_options['classes'], 'frm_show_expired_modal' ) ) {
467 + $classes .= ' frm_show_expired_modal';
468 + }
469 +
281 470 if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) {
282 471 $group_class .= ' frm-default-show';
283 472 }
284 473
@@ -299,20 +488,42 @@
299 488
300 489 if ( $requires && 'free' !== $requires ) {
301 490 $data['data-requires'] = $requires;
302 491 }
492 +
493 + $learn_more_slug = ! empty( $action_control->action_options['learn-more'] )
494 + ? $action_control->action_options['learn-more']
495 + : self::get_learn_more_slug( $action_control->id_base );
496 +
497 + if ( $learn_more_slug ) {
498 + $data['data-learn-more'] = FrmAppHelper::get_doc_url(
499 + $learn_more_slug,
500 + 'settings-' . $action_control->id_base,
501 + ! str_contains( $learn_more_slug, '/' )
502 + );
503 + }
303 504 }//end if
304 505
305 - // HTML to include on the icon.
306 - $icon_atts = array();
506 + include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php';
507 + }
307 508
308 - if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
309 - $icon_atts = array(
509 + /**
510 + * Get the HTML attributes for the action icon.
511 + *
512 + * @since 6.31
513 + *
514 + * @param object $action_control
515 + *
516 + * @return array
517 + */
518 + public static function get_action_icon_atts( $action_control ) {
519 + if ( 'var(--primary-700)' !== $action_control->action_options['color'] ) {
520 + return array(
310 521 'style' => '--primary-700:' . $action_control->action_options['color'],
311 522 );
312 523 }
313 524
314 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php';
525 + return array();
315 526 }
316 527
317 528 /**
318 529 * @param string $action
@@ -321,13 +532,13 @@
321 532 */
322 533 public static function get_form_actions( $action = 'all' ) {
323 534 $temp_actions = self::$registered_actions;
324 535
325 - if ( ! $temp_actions ) {
536 + if ( $temp_actions ) {
537 + $temp_actions = $temp_actions->actions;
538 + } else {
326 539 self::actions_init();
327 540 $temp_actions = self::$registered_actions->actions;
328 - } else {
329 - $temp_actions = $temp_actions->actions;
330 541 }
331 542
332 543 $actions = array();
333 544
@@ -379,8 +590,12 @@
379 590 }
380 591
381 592 self::maybe_show_limit_warning( $form->id, $form_actions );
382 593
594 + echo '<p class="frm-mb-lg frm-no-actions-message' . ( $form_actions ? ' frm_hidden' : '' ) . '"> '
595 + . esc_html__( 'No actions have been added yet. Select an action above to get started.', 'formidable' )
596 + . '</p>';
597 +
383 598 foreach ( $form_actions as $action ) {
384 599 if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
385 600 // Don't try and show settings if action no longer exists
386 601 continue;
@@ -447,13 +662,18 @@
447 662 public static function add_form_action() {
448 663 FrmAppHelper::permission_check( 'frm_edit_forms' );
449 664 check_ajax_referer( 'frm_ajax', 'nonce' );
450 665
666 + $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
667 + $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
668 + $lite_actions = array_fill_keys( self::get_lite_actions(), true );
669 +
670 + if ( ! FrmAppHelper::pro_is_connected() && ! isset( $lite_actions[ $action_type ] ) ) {
671 + wp_die();
672 + }
673 +
451 674 global $frm_vars;
452 675
453 - $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
454 - $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
455 -
456 676 /**
457 677 * @var FrmFormAction
458 678 */
459 679 $action_control = self::get_form_actions( $action_type );
@@ -458,10 +678,16 @@
458 678 */
459 679 $action_control = self::get_form_actions( $action_type );
460 680 $action_control->_set( $action_key );
461 681
462 - $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
463 - $form_action = $action_control->prepare_new( $form_id );
682 + $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
683 + $form_action = $action_control->prepare_new( $form_id );
684 + $existing_titles = (array) FrmAppHelper::get_post_param( 'existing_titles', array(), 'sanitize_text_field' );
685 +
686 + if ( $existing_titles ) {
687 + $form_action->post_title = self::get_unique_action_title( $form_action->post_title, $existing_titles );
688 + }
689 +
464 690 $use_logging = self::should_show_log_message( $action_type );
465 691 $values = array();
466 692 $form = self::fields_to_values( $form_id, $values );
467 693
@@ -468,8 +694,29 @@
468 694 include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
469 695 wp_die();
470 696 }
471 697
698 + /**
699 + * Returns the first available title not in $existing_titles, appending " (2)", " (3)", etc. if needed.
700 + *
701 + * @since 6.31
702 + *
703 + * @param string $base_title Default action title from the action type.
704 + * @param string[] $existing_titles Titles currently visible in the form editor.
705 + *
706 + * @return string
707 + */
708 + private static function get_unique_action_title( $base_title, array $existing_titles ) {
709 + $taken = array_flip( $existing_titles );
710 + $title = $base_title;
711 +
712 + for ( $n = 2; isset( $taken[ $title ] ); $n++ ) {
713 + $title = $base_title . ' (' . $n . ')';
714 + }
715 +
716 + return $title;
717 + }
718 +
472 719 public static function fill_action() {
473 720 FrmAppHelper::permission_check( 'frm_edit_forms' );
474 721 check_ajax_referer( 'frm_ajax', 'nonce' );
475 722
@@ -497,9 +744,25 @@
497 744 *
498 745 * @return bool
499 746 */
500 747 private static function should_show_log_message( $action_type ) {
501 - $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
748 + $logging = array(
749 + 'activecampaign',
750 + 'api',
751 + 'aweber',
752 + 'campaignmonitor',
753 + 'constantcontact',
754 + 'convertkit',
755 + 'getresponse',
756 + 'googlespreadsheet',
757 + 'hubspot',
758 + 'mailchimp',
759 + 'mailpoet',
760 + 'n8n',
761 + 'salesforce',
762 + 'twilio',
763 + 'zapier',
764 + );
502 765 return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' );
503 766 }
504 767
505 768 /**
@@ -599,14 +862,17 @@
599 862 *
600 863 * @return void
601 864 */
602 865 public static function delete_missing_actions( $old_actions ) {
603 - if ( $old_actions ) {
604 - foreach ( $old_actions as $old_id ) {
605 - wp_delete_post( $old_id );
606 - }
607 - FrmDb::cache_delete_group( 'frm_actions' );
866 + if ( ! $old_actions ) {
867 + return;
608 868 }
869 +
870 + foreach ( $old_actions as $old_id ) {
871 + wp_delete_post( $old_id );
872 + }
873 +
874 + FrmDb::cache_delete_group( 'frm_actions' );
609 875 }
610 876
611 877 /**
612 878 * @param int|string $entry_id
@@ -796,8 +1062,123 @@
796 1062 * @return bool|null
797 1063 */
798 1064 public static function prevent_wpml_translations( $null, $post_type ) {
799 1065 return self::$action_post_type === $post_type ? false : $null;
1066 + }
1067 +
1068 + /**
1069 + * If Pro is not connected, hook a filter that will force all non-Lite
1070 + * actions to inactive so the upgrade popup is shown instead.
1071 + *
1072 + * @since 6.31
1073 + *
1074 + * @return void
1075 + */
1076 + private static function maybe_setup_unlicensed_action_gate() {
1077 + if ( FrmAppHelper::pro_is_connected() ) {
1078 + return;
1079 + }
1080 +
1081 + add_filter( 'frm_registered_form_actions', array( self::class, 'disable_unlicensed_actions' ), 100 );
1082 + }
1083 +
1084 + /**
1085 + * For every registered action that is not a Lite action, add a per-action
1086 + * options filter that forces it to inactive with the upgrade class.
1087 + *
1088 + * Runs inside apply_filters('frm_registered_form_actions') at priority 100,
1089 + * so the per-key option filters are in place before the class constructors
1090 + * run in the foreach loop that follows.
1091 + *
1092 + * @since 6.31
1093 + *
1094 + * @param array $actions Map of action_key => class_name.
1095 + *
1096 + * @return array
1097 + */
1098 + public static function disable_unlicensed_actions( $actions ) {
1099 + $lite_actions = array_fill_keys( self::get_lite_actions(), true );
1100 +
1101 + foreach ( array_keys( $actions ) as $key ) {
1102 + if ( isset( $lite_actions[ $key ] ) ) {
1103 + continue;
1104 + }
1105 +
1106 + add_filter(
1107 + 'frm_' . $key . '_action_options',
1108 + function ( $options ) {
1109 + $options['active'] = false;
1110 +
1111 + if ( ! str_contains( $options['classes'], 'frm_show_upgrade' ) ) {
1112 + $options['classes'] .= ' frm_show_upgrade';
1113 + }
1114 +
1115 + return $options;
1116 + }
1117 + );
1118 + }//end foreach
1119 +
1120 + return $actions;
1121 + }
1122 +
1123 + /**
1124 + * Get action keys that are available in Lite without a Pro license.
1125 + *
1126 + * @since 6.31
1127 + *
1128 + * @return string[]
1129 + */
1130 + public static function get_lite_actions() {
1131 + return apply_filters( 'frm_lite_form_actions', array( 'on_submit', 'email', 'payment', 'stripe', 'square', 'paypal', 'gated_content' ) );
1132 + }
1133 +
1134 + /**
1135 + * Single source of truth for learn-more URL slugs used in
1136 + * upgrade modals for non-Lite form actions.
1137 + *
1138 + * Slugs without '/' are KB doc slugs (knowledgebase/ prefix is added).
1139 + * Slugs with '/' are direct paths (e.g. features/) used as-is.
1140 + *
1141 + * @since 6.31
1142 + *
1143 + * @return array<string,string> Map of action_key => URL slug.
1144 + */
1145 + public static function get_action_learn_more_links() {
1146 + return array(
1147 + 'wppost' => 'features/user-submitted-posts-wordpress-forms',
1148 + 'register' => 'user-registration',
1149 + 'paypal' => 'features/paypal-wordpress-payments',
1150 + 'quiz' => 'quiz-maker-forms',
1151 + 'quiz_outcome' => 'quiz-maker-forms',
1152 + 'aweber' => 'features/aweber-addon',
1153 + 'mailchimp' => 'features/mailchimp-addon',
1154 + 'zapier' => 'features/form-entry-routing-with-zapier',
1155 + 'twilio' => 'features/twilio-sms-form-notifications',
1156 + 'activecampaign' => 'features/entries-to-activecampaign',
1157 + 'salesforce' => 'features/form-entries-to-salesforce',
1158 + 'constantcontact' => 'features/entries-to-constant-contact',
1159 + 'getresponse' => 'features/form-entries-to-getresponse',
1160 + 'hubspot' => 'features/form-entries-to-hubspot',
1161 + 'mailpoet' => 'features/mailpoet-newsletters-addon',
1162 + 'api' => 'features/wordpress-form-api',
1163 + 'googlespreadsheet' => 'features/google-sheets',
1164 + 'n8n' => 'features/connect-your-forms-to-any-app-with-n8n',
1165 + 'convertkit' => 'features/convertkit',
1166 + );
1167 + }
1168 +
1169 + /**
1170 + * Look up the learn-more doc slug for a given action key.
1171 + *
1172 + * @since 6.31
1173 + *
1174 + * @param string $action_key Action identifier (e.g. 'register').
1175 + *
1176 + * @return string Doc slug or empty string.
1177 + */
1178 + private static function get_learn_more_slug( $action_key ) {
1179 + $links = self::get_action_learn_more_links();
1180 + return $links[ $action_key ] ?? '';
800 1181 }
801 1182 }
802 1183
803 1184 class Frm_Form_Action_Factory {