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

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