PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.1
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 / helpers / FrmOnboardingWizardHelper.php

FrmOnboardingWizardHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.16.1, at classes/helpers/FrmOnboardingWizardHelper.php

142 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Onboarding Wizard Helper 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 * Provides helper functions for managing onboarding wizard in the admin area.
14 *
15 * @since 6.9
16 */
17 class FrmOnboardingWizardHelper {
18
19 /**
20 * Echo attributes for the addon's label tag.
21 *
22 * @since 6.9
23 *
24 * @param string $addon_key The key of addon.
25 * @param array $addon The array of addon's information.
26 * @return void
27 */
28 public static function add_addon_label_attributes( $addon_key, $addon ) {
29 $id = 'frm-onboarding-' . $addon_key . '-addon';
30 $attributes = array(
31 'for' => $id,
32 'class' => 'frm-option-box',
33 'data-title' => $addon['title'],
34 );
35
36 if ( ! empty( $addon['is-checked'] ) ) {
37 $attributes['class'] .= ' frm-checked';
38 }
39 if ( ! empty( $addon['is-disabled'] ) ) {
40 $attributes['class'] .= ' frm-disabled';
41 }
42 if ( ! empty( $addon['rel'] ) ) {
43 $attributes['rel'] = $addon['rel'];
44 }
45 if ( ! empty( $addon['is-vendor'] ) ) {
46 $attributes['data-is-vendor'] = 'true';
47 }
48 if ( ! empty( $addon['is-installed'] ) ) {
49 $attributes['data-is-installed'] = 'true';
50 }
51
52 FrmAppHelper::array_to_html_params( $attributes, true );
53 }
54
55 /**
56 * Echo attributes for the addon's input tag.
57 *
58 * @since 6.9
59 *
60 * @param string $addon_key The key of addon.
61 * @param array $addon The array of addon's information.
62 * @return void
63 */
64 public static function add_addon_input_attributes( $addon_key, $addon ) {
65 $id = 'frm-onboarding-' . $addon_key . '-addon';
66 $attributes = array(
67 'type' => 'checkbox',
68 'name' => $id,
69 'id' => $id,
70 );
71
72 if ( ! empty( $addon['is-checked'] ) ) {
73 $attributes['checked'] = 'checked';
74 }
75 if ( ! empty( $addon['is-disabled'] ) ) {
76 $attributes['disabled'] = 'disabled';
77 }
78
79 FrmAppHelper::array_to_html_params( $attributes, true );
80 }
81
82 /**
83 * Renders the Onboarding Wizard page footer in the WordPress admin area.
84 *
85 * @since 6.9
86 *
87 * @param array $args
88 * @return void
89 */
90 public static function print_footer( $args = array() ) {
91 $defaults = array(
92 'footer-class' => '',
93 'display-back-button' => false,
94 // Primary Button Args.
95 'primary-button-text' => esc_html__( 'Next Step', 'formidable' ),
96 'primary-button-class' => '',
97 'primary-button-href' => '#',
98 'primary-button-role' => 'button',
99 'primary-button-with-icon' => false,
100 // Secondary Button Args.
101 'secondary-button-text' => esc_html__( 'Skip', 'formidable' ),
102 'secondary-button-class' => '',
103 'secondary-button-href' => '#',
104 'secondary-button-role' => 'button',
105 'secondary-button-skip-step' => true,
106 );
107 $args = wp_parse_args( $args, $defaults );
108
109 // Set the primary button attributes.
110 $primary_button_attributes = array(
111 'href' => $args['primary-button-href'],
112 );
113 $primary_button_attributes['class'] = trim( 'button button-primary frm-button-primary frm-sharp frm_large ' . $args['primary-button-class'] );
114 if ( ! empty( $args['primary-button-id'] ) ) {
115 $primary_button_attributes['id'] = $args['primary-button-id'];
116 }
117 if ( ! empty( $args['primary-button-plugin'] ) ) {
118 $primary_button_attributes['data-plugin'] = $args['primary-button-plugin'];
119 }
120 if ( ! empty( $args['primary-button-role'] ) ) {
121 $primary_button_attributes['role'] = $args['primary-button-role'];
122 }
123
124 // Set the secondary button attributes.
125 $secondary_button_attributes = array(
126 'href' => $args['secondary-button-href'],
127 );
128 $secondary_button_attributes['class'] = trim( 'button button-secondary frm-button-secondary frm-sharp frm_large ' . $args['secondary-button-class'] );
129 if ( $args['secondary-button-skip-step'] ) {
130 $secondary_button_attributes['class'] .= ' frm-onboarding-skip-step';
131 }
132 if ( ! empty( $args['secondary-button-id'] ) ) {
133 $secondary_button_attributes['id'] = $args['secondary-button-id'];
134 }
135 if ( ! empty( $args['secondary-button-role'] ) ) {
136 $secondary_button_attributes['role'] = $args['secondary-button-role'];
137 }
138
139 require FrmOnboardingWizardController::get_view_path() . 'footer.php';
140 }
141 }
142