PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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/FrmFormTemplatesController.php +31 -66 6.256.18 View file →
@@ -19,9 +19,9 @@
19 19
20 20 /**
21 21 * The slug of the Form Templates page.
22 22 *
23 - * @var string Unique identifier for the "Form Templates" page.
23 + * @var string PAGE_SLUG Unique identifier for the "Form Templates" page.
24 24 */
25 25 const PAGE_SLUG = 'formidable-form-templates';
26 26
27 27 /**
@@ -26,9 +26,9 @@
26 26
27 27 /**
28 28 * The script handle.
29 29 *
30 - * @var string Unique handle for the admin script.
30 + * @var string SCRIPT_HANDLE Unique handle for the admin script.
31 31 */
32 32 const SCRIPT_HANDLE = 'frm-form-templates';
33 33
34 34 /**
@@ -33,33 +33,26 @@
33 33
34 34 /**
35 35 * The required user capability to view form templates.
36 36 *
37 - * @var string Required capability to access the view form templates.
37 + * @var string REQUIRED_CAPABILITY Required capability to access the view form templates.
38 38 */
39 39 const REQUIRED_CAPABILITY = 'frm_view_forms';
40 40
41 41 /**
42 - * The IDs of the featured templates.
42 + * The keys of the featured templates.
43 43 *
44 - * Contains the unique IDs for the templates that are considered "featured":
44 + * Contains the unique keys for the templates that are considered "featured":
45 45 * "Contact Us", "Stripe Payment", "User Registration", "Create WordPress Post", "Survey", and "Quiz".
46 46 *
47 - * @var array Unique IDs for the featured templates.
47 + * @var array FEATURED_TEMPLATES_KEYS Unique keys for the featured templates.
48 48 */
49 - const FEATURED_TEMPLATES_IDS = array( 20872734, 28223640, 20874748, 20882522, 20908981, 28109851 );
49 + const FEATURED_TEMPLATES_KEYS = array( 20872734, 28223640, 20874748, 20882522, 20908981, 28109851 );
50 50
51 51 /**
52 - * The IDs of the free templates.
53 - *
54 - * @var array Unique IDs for the free templates.
55 - */
56 - const FREE_TEMPLATES_IDS = array( 20872734, 28223640 );
57 -
58 - /**
59 52 * Option name to store favorite templates.
60 53 *
61 - * @var string Unique identifier for storing favorite templates.
54 + * @var string FAVORITE_TEMPLATES_OPTION Unique identifier for storing favorite templates.
62 55 */
63 56 const FAVORITE_TEMPLATES_OPTION = 'frm_favorite_templates';
64 57
65 58 /**
@@ -147,15 +140,15 @@
147 140 public static function load_admin_hooks() {
148 141 self::init_template_resources();
149 142
150 143 // Use the same priority as Applications so Form Templates appear directly under Applications.
151 - add_action( 'admin_menu', self::class . '::menu', 14 );
152 - add_action( 'admin_footer', self::class . '::render_modal' );
153 - add_filter( 'frm_form_nav_list', self::class . '::append_new_template_to_nav', 10, 2 );
144 + add_action( 'admin_menu', __CLASS__ . '::menu', 14 );
145 + add_action( 'admin_footer', __CLASS__ . '::render_modal' );
146 + add_filter( 'frm_form_nav_list', __CLASS__ . '::append_new_template_to_nav', 10, 2 );
154 147
155 148 if ( self::is_templates_page() ) {
156 - add_action( 'admin_init', self::class . '::set_form_templates_data' );
157 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
149 + add_action( 'admin_init', __CLASS__ . '::set_form_templates_data' );
150 + add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 );
158 151 add_filter( 'frm_show_footer_links', '__return_false' );
159 152 }
160 153 }
161 154
@@ -174,9 +167,9 @@
174 167 'Formidable | ' . $label,
175 168 $label,
176 169 self::REQUIRED_CAPABILITY,
177 170 self::PAGE_SLUG,
178 - array( self::class, 'render' )
171 + array( __CLASS__, 'render' )
179 172 );
180 173 }
181 174
182 175 /**
@@ -232,15 +225,12 @@
232 225
233 226 // Add `create-template` modal view.
234 227 $view_parts[] = 'modals/create-template-modal.php';
235 228
236 - if ( FrmFormTemplatesHelper::needs_get_free_templates_banner() ) {
237 - $leave_email_args = array(
238 - 'title' => esc_html__( 'Get 30+ Free Form Templates', 'formidable' ),
239 - 'description' => esc_html__( 'Just add your email address and you\'ll get 30+ free form templates to your account.', 'formidable' ),
240 - 'submit_button_text' => esc_html_x( 'Get Templates', 'get free templates modal submit button text', 'formidable' ),
241 - );
242 - $view_parts[] = 'modals/leave-email-modal.php';
229 + // Add 'leave-email' and 'code-from-email' modals views for users without Pro or free access.
230 + if ( ! FrmAppHelper::pro_is_installed() && ! self::$form_template_api->has_free_access() ) {
231 + $view_parts[] = 'modals/leave-email-modal.php';
232 + $view_parts[] = 'modals/code-from-email-modal.php';
243 233 }
244 234
245 235 // Add 'upgrade' modal view for non-elite users.
246 236 if ( 'elite' !== FrmAddonsController::license_type() ) {
@@ -391,37 +381,8 @@
391 381 wp_die();
392 382 }
393 383
394 384 /**
395 - * Handle AJAX request to subscribe the user to ActiveCampaign.
396 - *
397 - * @since 6.25
398 - *
399 - * @return void
400 - */
401 - public static function ajax_get_free_templates() {
402 - FrmAppHelper::permission_check( self::REQUIRED_CAPABILITY );
403 - check_ajax_referer( 'frm_ajax', 'nonce' );
404 -
405 - $email = FrmAppHelper::get_post_param( 'email', '', 'sanitize_email' );
406 -
407 - if ( empty( $email ) || ! is_email( $email ) ) {
408 - wp_send_json_error(
409 - array( 'message' => __( 'Please enter a valid email address.', 'formidable' ) ),
410 - WP_Http::BAD_REQUEST
411 - );
412 - }
413 -
414 - self::$form_template_api = new FrmFormTemplateApi();
415 - self::$form_template_api->reset_cached();
416 -
417 - FrmEmailCollectionHelper::subscribe_to_active_campaign( $email );
418 - self::$form_template_api::set_free_license_code( '1' );
419 -
420 - wp_send_json_success();
421 - }
422 -
423 - /**
424 385 * Fetch and format custom templates.
425 386 *
426 387 * Retrieves the custom templates, formats them, and assigns them to the class property.
427 388 *
@@ -498,9 +459,9 @@
498 459 private static function organize_and_set_categories() {
499 460 // Iterate through templates to assign categories.
500 461 foreach ( self::$templates as $key => &$template ) {
501 462 // Skip the template if the categories are not set.
502 - if ( ! isset( $template['categories'] ) || ! isset( $template['id'] ) ) {
463 + if ( ! isset( $template['categories'] ) ) {
503 464 unset( self::$templates[ $key ] );
504 465 continue;
505 466 }
506 467
@@ -564,8 +525,13 @@
564 525 $special_categories['all-items'] = array(
565 526 'name' => __( 'All Templates', 'formidable' ),
566 527 'count' => self::get_template_count(),
567 528 );
529 + $special_categories['free-templates'] = array(
530 + 'name' => __( 'Free Templates', 'formidable' ),
531 + // Assigned via JavaScript.
532 + 'count' => 0,
533 + );
568 534
569 535 self::$categories = array_merge(
570 536 $special_categories,
571 537 self::$categories
@@ -574,9 +540,9 @@
574 540
575 541 /**
576 542 * Assign featured templates.
577 543 *
578 - * Iterates through FEATURED_TEMPLATES_IDS and adds matching templates to
544 + * Iterates through FEATURED_TEMPLATES_KEYS and adds matching templates to
579 545 * the `featured_templates` class property.
580 546 *
581 547 * @since 6.7
582 548 *
@@ -582,9 +548,9 @@
582 548 *
583 549 * @return void
584 550 */
585 551 private static function assign_featured_templates() {
586 - foreach ( self::FEATURED_TEMPLATES_IDS as $key ) {
552 + foreach ( self::FEATURED_TEMPLATES_KEYS as $key ) {
587 553 if ( isset( self::$templates[ $key ] ) ) {
588 554 self::$templates[ $key ]['is_featured'] = true;
589 555 self::$featured_templates[] = self::$templates[ $key ];
590 556 }
@@ -718,18 +684,17 @@
718 684 * @return array
719 685 */
720 686 private static function get_js_variables() {
721 687 $js_variables = array(
722 - 'FEATURED_TEMPLATES_IDS' => self::FEATURED_TEMPLATES_IDS,
723 - 'FREE_TEMPLATES_IDS' => self::FREE_TEMPLATES_IDS,
724 - 'templatesCount' => self::get_template_count(),
725 - 'favoritesCount' => array(
688 + 'FEATURED_TEMPLATES_KEYS' => self::FEATURED_TEMPLATES_KEYS,
689 + 'templatesCount' => self::get_template_count(),
690 + 'favoritesCount' => array(
726 691 'total' => self::get_favorite_templates_count(),
727 692 'default' => count( self::$favorite_templates['default'] ),
728 693 'custom' => count( self::$favorite_templates['custom'] ),
729 694 ),
730 - 'customCount' => count( self::$custom_templates ),
731 - 'upgradeLink' => self::$upgrade_link,
695 + 'customCount' => count( self::$custom_templates ),
696 + 'upgradeLink' => self::$upgrade_link,
732 697 );
733 698
734 699 /**
735 700 * Filters `js_variables` passed to the "Form Templates".