PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8.2
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
formidable / classes / controllers / FrmFormTemplatesController.php

FrmFormTemplatesController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.8.2, at classes/controllers/FrmFormTemplatesController.php

872 lines 23.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Templates Controller class.
4 *
5 * @package Formidable
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die( 'You are not allowed to call this page directly.' );
10 }
11
12 /**
13 * Class FrmFormTemplatesController.
14 * Handles the Form Templates page in the admin area.
15 *
16 * @since 6.7
17 */
18 class FrmFormTemplatesController {
19
20 /**
21 * The slug of the Form Templates page.
22 *
23 * @var string PAGE_SLUG Unique identifier for the "Form Templates" page.
24 */
25 const PAGE_SLUG = 'formidable-form-templates';
26
27 /**
28 * The script handle.
29 *
30 * @var string SCRIPT_HANDLE Unique handle for the admin script.
31 */
32 const SCRIPT_HANDLE = 'frm-form-templates';
33
34 /**
35 * The required user capability to view form templates.
36 *
37 * @var string REQUIRED_CAPABILITY Required capability to access the view form templates.
38 */
39 const REQUIRED_CAPABILITY = 'frm_view_forms';
40
41 /**
42 * The keys of the featured templates.
43 *
44 * Contains the unique keys for the templates that are considered "featured":
45 * "Contact Us", "Stripe Payment", "User Registration", "Create WordPress Post", "Survey", and "Quiz".
46 *
47 * @var array FEATURED_TEMPLATES_KEYS Unique keys for the featured templates.
48 */
49 const FEATURED_TEMPLATES_KEYS = array( 20872734, 28223640, 20874748, 20882522, 20908981, 28109851 );
50
51 /**
52 * Option name to store favorite templates.
53 *
54 * @var string FAVORITE_TEMPLATES_OPTION Unique identifier for storing favorite templates.
55 */
56 const FAVORITE_TEMPLATES_OPTION = 'frm_favorite_templates';
57
58 /**
59 * Instance of the Form Template API handler.
60 *
61 * @var FrmFormTemplateApi $form_template_api Form Template API handler.
62 */
63 private static $form_template_api;
64
65 /**
66 * Templates fetched from the API.
67 *
68 * @var array $templates Templates information from API.
69 */
70 private static $templates = array();
71
72 /**
73 * Featured templates.
74 *
75 * @var array $featured_templates Associative array with the featured templates' information.
76 */
77 private static $featured_templates = array();
78
79 /**
80 * List of user favorite templates.
81 *
82 * @var array $favorite_templates List of templates that the user has marked as favorites.
83 */
84 private static $favorite_templates = array();
85
86 /**
87 * Templates fetched from the published form by user.
88 *
89 * @var array $custom_templates Templates information from published form.
90 */
91 private static $custom_templates = array();
92
93 /**
94 * Categories for organizing templates.
95 *
96 * @var array $categories Categories for organizing templates.
97 */
98 private static $categories = array();
99
100 /**
101 * Status of API request, true if expired.
102 *
103 * @var bool $is_expired Whether the API request is expired or not.
104 */
105 private static $is_expired = false;
106
107 /**
108 * The type of license received from the API.
109 *
110 * @var string $license_type License type received from the API.
111 */
112 private static $license_type = '';
113
114 /**
115 * Path to views.
116 *
117 * @var string $view_path Path to form templates views.
118 */
119 private static $view_path = '';
120
121 /**
122 * Upgrade URL.
123 *
124 * @var string $upgrade_link URL for upgrading accounts.
125 */
126 private static $upgrade_link = '';
127
128 /**
129 * Renew URL.
130 *
131 * @var string $renew_link URL for renewing accounts.
132 */
133 private static $renew_link = '';
134
135 /**
136 * Initialize hooks for template page only.
137 *
138 * @since 6.7
139 */
140 public static function load_admin_hooks() {
141 self::init_template_resources();
142
143 // Use the same priority as Applications so Form Templates appear directly under Applications.
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 );
147
148 if ( self::is_templates_page() ) {
149 add_action( 'admin_init', __CLASS__ . '::set_form_templates_data' );
150 add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 );
151 add_filter( 'frm_show_footer_links', '__return_false' );
152 }
153 }
154
155 /**
156 * Add Form Templates menu item to sidebar and define index page.
157 *
158 * @since 6.7
159 *
160 * @return void
161 */
162 public static function menu() {
163 $label = __( 'Form Templates', 'formidable' );
164
165 add_submenu_page(
166 'formidable',
167 'Formidable | ' . $label,
168 $label,
169 self::REQUIRED_CAPABILITY,
170 self::PAGE_SLUG,
171 array( __CLASS__, 'render' )
172 );
173 }
174
175 /**
176 * Renders the Form Templates page in the WordPress admin area.
177 *
178 * Sets up template data, fetches relevant information, determines which blocks to render,
179 * and includes the view file for displaying the Form Templates page.
180 *
181 * @since 6.7
182 *
183 * @return void
184 */
185 public static function render() {
186 // Include SVG images for icons.
187 FrmAppHelper::include_svg();
188
189 $view_path = self::get_view_path();
190 $upgrade_link = self::get_upgrade_link();
191 $renew_link = self::get_renew_link();
192 $license_type = self::get_license_type();
193 $pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
194 $expired = self::is_expired();
195
196 // Get various template types and categories.
197 $templates = self::get_templates();
198 $favorite_templates = self::get_favorite_templates();
199 $featured_templates = self::get_featured_templates();
200 $custom_templates = self::get_custom_templates();
201 $categories = self::get_categories();
202
203 // Render the view.
204 include $view_path . 'index.php';
205 }
206
207 /**
208 * Renders a modal component in the WordPress admin area.
209 *
210 * @since 6.7
211 *
212 * @return void
213 */
214 public static function render_modal() {
215 $view_path = self::$view_path;
216 $view_parts = array();
217
218 // Check if the current page is the form templates page.
219 if ( self::is_templates_page() ) {
220 // User and license-related variables.
221 $user = wp_get_current_user();
222 $expired = self::is_expired();
223 $upgrade_link = self::get_upgrade_link();
224 $renew_link = self::get_renew_link();
225 $published_forms = self::get_published_forms();
226
227 // Add `create-template` modal view.
228 $view_parts[] = 'modals/create-template-modal.php';
229
230 // Add 'leave-email' and 'code-from-email' modals views for users without Pro or free access.
231 if ( ! FrmAppHelper::pro_is_installed() && ! self::$form_template_api->has_free_access() ) {
232 $view_parts[] = 'modals/leave-email-modal.php';
233 $view_parts[] = 'modals/code-from-email-modal.php';
234 }
235
236 // Add 'upgrade' modal view for non-elite users.
237 if ( 'elite' !== FrmAddonsController::license_type() ) {
238 $view_parts[] = 'modals/upgrade-modal.php';
239 }
240
241 // Add 'renew-account' modal view for expired users.
242 if ( $expired ) {
243 $view_parts[] = 'modals/renew-account-modal.php';
244 }
245 }//end if
246
247 // Check if the current page is the form builder page.
248 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
249 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
250
251 if ( 'edit' === $action || 'settings' === $action ) {
252 $view_parts[] = 'modals/name-your-form-modal.php';
253 }
254 }
255
256 // Render the view.
257 include $view_path . 'modal.php';
258 }
259
260 /**
261 * Initializes and organizes form template data by performing the following actions:
262 * - Instantiates the Form Template API class
263 * - Retrieves and sets templates, including featured ones
264 * - Organizes and categorizes templates
265 * - Formats custom templates
266 * - Updates global variables to reflect the current state
267 *
268 * @since 6.7
269 *
270 * @return void
271 */
272 public static function set_form_templates_data() {
273 self::$form_template_api = new FrmFormTemplateApi();
274
275 self::init_favorite_templates();
276 self::fetch_and_format_custom_templates();
277 self::retrieve_and_set_templates();
278 self::organize_and_set_categories();
279 self::assign_featured_templates();
280 }
281
282 /**
283 * Initialize favorite templates from WordPress options.
284 *
285 * @since 6.7
286 *
287 * @return void
288 */
289 private static function init_favorite_templates() {
290 $default_option_structure = array(
291 'default' => array(),
292 'custom' => array(),
293 );
294
295 $favorites = get_option( self::FAVORITE_TEMPLATES_OPTION, $default_option_structure );
296 $favorites = wp_parse_args( $favorites, $default_option_structure );
297
298 // Set the favorite templates property and remove empty values.
299 self::$favorite_templates = array(
300 'default' => array_filter( (array) $favorites['default'] ),
301 'custom' => array_filter( (array) $favorites['custom'] ),
302 );
303 }
304
305 /**
306 * Handle AJAX request to add or remove favorite templates.
307 *
308 * Manages the $favorite_templates by using WordPress options to
309 * add or remove templates from the favorites list.
310 *
311 * @since 6.7
312 *
313 * @return void
314 */
315 public static function ajax_add_or_remove_favorite() {
316 // Check permission and nonce.
317 FrmAppHelper::permission_check( self::REQUIRED_CAPABILITY );
318 check_ajax_referer( 'frm_ajax', 'nonce' );
319
320 // Set up form templates environment, ensuring data is ready for processing.
321 self::set_form_templates_data();
322
323 // Get posted data.
324 $template_id = FrmAppHelper::get_post_param( 'template_id', '', 'absint' );
325 $operation = FrmAppHelper::get_post_param( 'operation', '', 'sanitize_text_field' );
326 $is_custom_template = FrmAppHelper::get_post_param( 'is_custom_template', '', 'rest_sanitize_boolean' );
327
328 // Determine the key based on whether it's a custom template or not.
329 $key = $is_custom_template ? 'custom' : 'default';
330
331 // Perform add or remove operation.
332 if ( 'add' === $operation ) {
333 self::$favorite_templates[ $key ][] = $template_id;
334 } elseif ( 'remove' === $operation ) {
335 $position = array_search( $template_id, self::$favorite_templates[ $key ], true );
336 if ( $position !== false ) {
337 unset( self::$favorite_templates[ $key ][ $position ] );
338 }
339 }
340
341 // Update the favorite templates option.
342 update_option( self::FAVORITE_TEMPLATES_OPTION, self::$favorite_templates );
343
344 // Return the updated list of favorite templates.
345 wp_send_json_success( self::$favorite_templates );
346 }
347
348 /**
349 * Create a custom template from a form.
350 *
351 * @since 6.7
352 *
353 * @return void
354 */
355 public static function ajax_create_template() {
356 // Check permission and nonce.
357 FrmAppHelper::permission_check( self::REQUIRED_CAPABILITY );
358 check_ajax_referer( 'frm_ajax', 'nonce' );
359
360 // Set up form templates environment, ensuring data is ready for processing.
361 self::set_form_templates_data();
362
363 // Get posted data.
364 $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
365 $new_form_id = FrmForm::duplicate( $form_id, 1, true );
366
367 if ( ! $new_form_id ) {
368 // Send an error response if form duplication fails.
369 $response = array(
370 'message' => __( 'There was an error creating a template.', 'formidable' ),
371 );
372 } else {
373 FrmForm::update( $new_form_id, FrmFormsController::get_modal_values() );
374
375 // Send a success response with redirect URL.
376 $response = array(
377 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ) . '&_wpnonce=' . wp_create_nonce(),
378 );
379 }
380
381 // Send response.
382 echo wp_json_encode( $response );
383 wp_die();
384 }
385
386 /**
387 * Fetch and format custom templates.
388 *
389 * Retrieves the custom templates, formats them, and assigns them to the class property.
390 *
391 * @since 6.7
392 *
393 * @return void
394 */
395 private static function fetch_and_format_custom_templates() {
396 // Get all custom templates that are not default templates.
397 $custom_templates = FrmForm::getAll(
398 array(
399 'is_template' => 1,
400 'default_template' => 0,
401 'status' => array( null, '', 'published' ),
402 ),
403 'name'
404 );
405
406 // Extract IDs from the custom templates for matching with favorite templates.
407 $custom_templates_ids = wp_list_pluck( $custom_templates, 'id' );
408
409 // Refine the list of favorite templates to include only those present in custom templates.
410 self::$favorite_templates['custom'] = array_intersect( self::$favorite_templates['custom'], $custom_templates_ids );
411
412 foreach ( $custom_templates as $template ) {
413 $template = array(
414 'id' => absint( $template->id ),
415 'name' => $template->name,
416 'key' => $template->form_key,
417 'description' => $template->description,
418 'link' => FrmForm::get_edit_link( absint( $template->id ) ),
419 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable&frm_action=duplicate&new_template=true&id=' . absint( $template->id ) ) ),
420 'released' => $template->created_at,
421 'installed' => 1,
422 'is_custom' => true,
423 'created_at' => $template->created_at,
424 );
425
426 // Mark the template as favorite if it's in the favorite templates list.
427 $template['is_favorite'] = in_array( $template['id'], self::$favorite_templates['custom'], true );
428
429 // Add the formatted template to the custom templates list.
430 array_unshift( self::$custom_templates, $template );
431 }
432 }
433
434 /**
435 * Retrieve and set templates.
436 *
437 * Gets the templates from the API and assigns them to the class property.
438 * Also handles any errors returned from the API.
439 *
440 * @since 6.7
441 *
442 * @return void
443 */
444 private static function retrieve_and_set_templates() {
445 self::$templates = self::$form_template_api->get_api_info();
446
447 self::$is_expired = FrmAddonsController::is_license_expired();
448 self::$license_type = FrmAddonsController::license_type();
449 }
450
451 /**
452 * Organize and set categories.
453 *
454 * Iterates through templates to organize categories, performs filtering, sorting,
455 * and adds special categories.
456 *
457 * @since 6.7
458 *
459 * @return void
460 */
461 private static function organize_and_set_categories() {
462 // Iterate through templates to assign categories.
463 foreach ( self::$templates as $key => &$template ) {
464 // Skip the template if the categories are not set.
465 if ( ! isset( $template['categories'] ) ) {
466 unset( self::$templates[ $key ] );
467 continue;
468 }
469
470 // Add a new key for category slugs.
471 $template['category_slugs'] = array();
472
473 // Increment the count for each category.
474 foreach ( $template['categories'] as $category ) {
475 $category_slug = sanitize_title( $category );
476
477 // Add the slug to the new array.
478 $template['category_slugs'][] = $category_slug;
479
480 if ( ! isset( self::$categories[ $category_slug ] ) ) {
481 self::$categories[ $category_slug ] = array(
482 'name' => $category,
483 'count' => 0,
484 );
485 }
486
487 self::$categories[ $category_slug ]['count']++;
488 }
489
490 // Mark the template as favorite if it's in the favorite templates list.
491 $template['is_favorite'] = in_array( $template['id'], self::$favorite_templates['default'], true );
492 }//end foreach
493
494 // Unset the reference `$template` variable.
495 unset( $template );
496
497 // Filter out certain and redundant categories.
498 // 'PayPal', 'Stripe', and 'Twilio' are included elsewhere and should be ignored in this context.
499 $redundant_cats = array_merge( array( 'PayPal', 'Stripe', 'Twilio' ), FrmFormsHelper::ignore_template_categories() );
500 foreach ( $redundant_cats as $redundant_cat ) {
501 $category_slug = sanitize_title( $redundant_cat );
502 unset( self::$categories[ $category_slug ] );
503 }
504
505 // Sort the categories by keys alphabetically.
506 ksort( self::$categories );
507
508 // Add special categories.
509 $special_categories = array(
510 'favorites' => array(
511 'name' => __( 'Favorites', 'formidable' ),
512 'count' => self::get_favorite_templates_count(),
513 ),
514 'custom' => array(
515 'name' => __( 'Custom', 'formidable' ),
516 'count' => count( self::$custom_templates ),
517 ),
518 );
519 // Add the 'Available Templates' category for non-elite users.
520 if ( 'elite' !== FrmAddonsController::license_type() ) {
521 $special_categories['available-templates'] = array(
522 'name' => __( 'Available Templates', 'formidable' ),
523 // Assigned via JavaScript.
524 'count' => 0,
525 );
526 }
527 $special_categories['all-templates'] = array(
528 'name' => __( 'All Templates', 'formidable' ),
529 'count' => self::get_template_count(),
530 );
531 $special_categories['free-templates'] = array(
532 'name' => __( 'Free Templates', 'formidable' ),
533 // Assigned via JavaScript.
534 'count' => 0,
535 );
536
537 self::$categories = array_merge(
538 $special_categories,
539 self::$categories
540 );
541 }
542
543 /**
544 * Assign featured templates.
545 *
546 * Iterates through FEATURED_TEMPLATES_KEYS and adds matching templates to
547 * the `featured_templates` class property.
548 *
549 * @since 6.7
550 *
551 * @return void
552 */
553 private static function assign_featured_templates() {
554 foreach ( self::FEATURED_TEMPLATES_KEYS as $key ) {
555 if ( isset( self::$templates[ $key ] ) ) {
556 self::$templates[ $key ]['is_featured'] = true;
557 self::$featured_templates[] = self::$templates[ $key ];
558 }
559 }
560 }
561
562 /**
563 * Get the total count of favorite templates.
564 *
565 * @since 6.7
566 *
567 * @return int
568 */
569 public static function get_favorite_templates_count() {
570 $custom_count = count( self::$favorite_templates['custom'] );
571 $default_count = count( self::$favorite_templates['default'] );
572
573 return $custom_count + $default_count;
574 }
575
576 /**
577 * Initializes essential resources.
578 *
579 * @since 6.7
580 *
581 * @return void
582 */
583 private static function init_template_resources() {
584 self::$view_path = FrmAppHelper::plugin_path() . '/classes/views/form-templates/';
585
586 self::$upgrade_link = FrmAppHelper::admin_upgrade_link(
587 array(
588 'medium' => 'form-templates',
589 'content' => 'upgrade',
590 )
591 );
592
593 self::$renew_link = FrmAppHelper::admin_upgrade_link(
594 array(
595 'medium' => 'form-templates',
596 'content' => 'renew',
597 )
598 );
599 }
600
601 /**
602 * Adds a Cancel button to the header of the Form Templates page.
603 *
604 * It's hidden by default and will show when the user clicks on 'Create Form' from
605 * another place in Formidable Forms.
606 *
607 * @since 6.7
608 *
609 * @return void
610 */
611 public static function get_header_cancel_button() {
612 echo '
613 <a class="button frm-button-secondary frm_hidden" href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '" role="button">
614 ' . esc_html__( 'Cancel', 'formidable' ) . '
615 </a>';
616 }
617
618 /**
619 * Append 'new_template' query parameter to navigation links if it exists in the URL.
620 *
621 * @since 6.7
622 *
623 * @param array $nav_items Navigation items.
624 * @param array $nav_args Additional navigation arguments.
625 * @return array Modified navigation items with 'new_template' query parameter.
626 */
627 public static function append_new_template_to_nav( $nav_items, $nav_args ) {
628 $is_new_template = FrmAppHelper::simple_get( 'new_template' );
629
630 // Append 'new_template=true' to each nav item's link if 'new_template' exists in the URL.
631 if ( $is_new_template ) {
632 foreach ( $nav_items as &$item ) {
633 $item['link'] .= '&new_template=true';
634 }
635 }
636
637 return $nav_items;
638 }
639
640 /**
641 * Enqueues "Form Templates" scripts and styles.
642 *
643 * @since 6.7
644 *
645 * @return void
646 */
647 public static function enqueue_assets() {
648 $plugin_url = FrmAppHelper::plugin_url();
649 $version = FrmAppHelper::plugin_version();
650 $js_dependencies = array(
651 'wp-i18n',
652 // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
653 'wp-hooks',
654 'formidable_dom',
655 );
656
657 // Enqueue styles that needed.
658 wp_enqueue_style( 'formidable-admin' );
659 wp_enqueue_style( 'formidable-grids' );
660
661 // Register and enqueue "Form Templates" style.
662 wp_register_style( self::SCRIPT_HANDLE, $plugin_url . '/css/admin/form-templates.css', array(), $version );
663 wp_enqueue_style( self::SCRIPT_HANDLE );
664
665 // Register and enqueue "Form Templates" script.
666 wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/form-templates.js', $js_dependencies, $version, true );
667 wp_localize_script( self::SCRIPT_HANDLE, 'frmFormTemplatesVars', self::get_js_variables() );
668 wp_enqueue_script( self::SCRIPT_HANDLE );
669
670 /**
671 * Fires after "Form Templates" enqueue assets.
672 *
673 * @since 6.7
674 */
675 do_action( 'frm_form_templates_enqueue_assets' );
676
677 self::dequeue_scripts();
678 }
679
680 /**
681 * Get "Form Templates" JS variables as an array.
682 *
683 * @since 6.7
684 *
685 * @return array
686 */
687 private static function get_js_variables() {
688 $js_variables = array(
689 'FEATURED_TEMPLATES_KEYS' => self::FEATURED_TEMPLATES_KEYS,
690 'templatesCount' => self::get_template_count(),
691 'favoritesCount' => array(
692 'total' => self::get_favorite_templates_count(),
693 'default' => count( self::$favorite_templates['default'] ),
694 'custom' => count( self::$favorite_templates['custom'] ),
695 ),
696 'customCount' => count( self::$custom_templates ),
697 'upgradeLink' => self::$upgrade_link,
698 );
699
700 /**
701 * Filters `js_variables` passed to the "Form Templates".
702 *
703 * @since 6.7
704 *
705 * @param array $js_variables Array of js_variables passed to "Form Templates".
706 */
707 return apply_filters( 'frm_form_templates_js_variables', $js_variables );
708 }
709
710 /**
711 * Dequeue scripts and styles on "Form Templates".
712 *
713 * Avoid extra scripts loading on "Form Templates" page that aren't needed.
714 *
715 * @since 6.7
716 *
717 * @return void
718 */
719 private static function dequeue_scripts() {
720 wp_dequeue_script( 'frm-surveys-admin' );
721 wp_dequeue_script( 'frm-quizzes-form-action' );
722 }
723
724 /**
725 * Check if the current page is the form templates page.
726 *
727 * @since 6.7
728 *
729 * @return bool True if the current page is the form templates page, false otherwise.
730 */
731 public static function is_templates_page() {
732 return FrmAppHelper::is_admin_page( self::PAGE_SLUG );
733 }
734
735 /**
736 * Get the list of templates.
737 *
738 * @since 6.7
739 *
740 * @return array A list of templates.
741 */
742 public static function get_templates() {
743 return self::$templates;
744 }
745
746 /**
747 * Get the total number of templates.
748 *
749 * @since 6.8
750 *
751 * @return int
752 */
753 public static function get_template_count() {
754 if ( empty( self::$templates ) ) {
755 self::$form_template_api = new FrmFormTemplateApi();
756 self::retrieve_and_set_templates();
757 }
758 return count( self::$templates );
759 }
760
761 /**
762 * Get the published forms based on applied filters.
763 *
764 * @since 6.7
765 *
766 * @return array An array of published forms.
767 */
768 public static function get_published_forms() {
769 $where = apply_filters( 'frm_forms_dropdown', array(), '' );
770 return FrmForm::get_published_forms( $where );
771 }
772
773 /**
774 * Get the list of featured templates.
775 *
776 * @since 6.7
777 *
778 * @return array A list of featured templates.
779 */
780 public static function get_featured_templates() {
781 return self::$featured_templates;
782 }
783
784 /**
785 * Get the list of categories.
786 *
787 * @since 6.7
788 *
789 * @return array A list of categories.
790 */
791 public static function get_categories() {
792 return self::$categories;
793 }
794
795 /**
796 * Get the user's favorite form templates.
797 *
798 * @since 6.7
799 *
800 * @return array The IDs of the user's favorite form templates.
801 */
802 public static function get_favorite_templates() {
803 return self::$favorite_templates;
804 }
805
806 /**
807 * Get the list of custom templates.
808 *
809 * @since 6.7
810 *
811 * @return array A list of custom templates.
812 */
813 public static function get_custom_templates() {
814 return self::$custom_templates;
815 }
816
817 /**
818 * Get the license type.
819 *
820 * @since 6.7
821 *
822 * @return string The license type.
823 */
824 public static function get_license_type() {
825 return self::$license_type;
826 }
827
828 /**
829 * Checks if the API request was expired.
830 *
831 * @since 6.7
832 *
833 * @return bool True if the API request was expired, false otherwise.
834 */
835 public static function is_expired() {
836 return self::$is_expired;
837 }
838
839 /**
840 * Get the path to form templates views.
841 *
842 * @since 6.7
843 *
844 * @return string Path to views.
845 */
846 public static function get_view_path() {
847 return self::$view_path;
848 }
849
850 /**
851 * Get the upgrade link.
852 *
853 * @since 6.7
854 *
855 * @return string URL for upgrading accounts.
856 */
857 public static function get_upgrade_link() {
858 return self::$upgrade_link;
859 }
860
861 /**
862 * Get the renewal link.
863 *
864 * @since 6.7
865 *
866 * @return string URL for renewing accounts.
867 */
868 public static function get_renew_link() {
869 return self::$renew_link;
870 }
871 }
872