PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.10.6
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.10.6
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / widgets / bricks / NextStep.php

NextStep.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.10.6, at includes/core/widgets/bricks/NextStep.php

264 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Namespace for the NextStep class.
4 * This class is part of the WPFunnels\Widgets\Bricks namespace.
5 */
6 namespace WPFunnels\Widgets\Bricks;
7
8 require_once get_template_directory() . '/includes/elements/base.php';
9
10 use \Bricks\Element;
11 use WPFunnels\Wpfnl_functions;
12
13 if (! defined('ABSPATH')) {
14 exit;
15 } // Exit if accessed directly
16
17 /**
18 * Class NextStep
19 *
20 * Represents a NextStep element in the WP Funnels plugin.
21 * This class extends the Element class.
22 *
23 * @package WPFunnels\Widgets\Bricks
24 */
25 class NextStep extends Element {
26
27 // Element properties
28 public $category = 'wpfunnels'; // Use predefined element category 'general'
29 public $name = 'wpfnl_next_step'; // Make sure to prefix your elements
30 public $icon = 'fa-solid fa-cart-shopping'; // Themify icon font class
31 public $scripts = []; // Script(s) run when element is rendered on frontend or updated in builder
32 public $tag = 'button';
33
34
35 /**
36 * Return localised element label
37 *
38 * @return string
39 * @since 3.1.0
40 */
41 public function get_label()
42 {
43 return esc_html__('Next Step', 'wpfnl');
44 }
45
46
47 /**
48 * Set builder controls
49 *
50 * @since 3.1.0
51 */
52 public function set_controls() {
53 $this->controls['button_type_selector'] = [
54 'tab' => 'content',
55 'label' => esc_html__( 'Select Button Type', 'wpfnl' ),
56 'type' => 'select',
57 'options' => [
58 'checkout' => 'Next Step',
59 'url-path' => 'Go To URL Path',
60 'another-funnel' => 'Another Funnel',
61 ],
62 'inline' => false,
63 'placeholder' => esc_html__( 'Select Type', 'wpfnl' ),
64 'default' => '',
65 ];
66
67 $this->controls['url_path_field'] = [
68 'tab' => 'content',
69 'label' => esc_html__( 'URL Path', 'wpfnl' ),
70 'type' => 'link',
71 'pasteStyles' => false,
72 'placeholder' => esc_html__( 'http://yoursite.com', 'wpfnl' ),
73 'required' => [ 'button_type_selector', '=', 'url-path' ],
74 ];
75
76 $this->controls['another_funnel_field'] = [
77 'tab' => 'content',
78 'label' => esc_html__( 'Choose Funnel', 'wpfnl' ),
79 'type' => 'select',
80 'options' => Wpfnl_functions::get_funnel_list(),
81 'inline' => false,
82 'placeholder' => esc_html__( 'Select a Funnel', 'wpfnl' ),
83 'default' => '',
84 'required' => [ 'button_type_selector', '=', 'another-funnel' ],
85 ];
86
87
88 $this->controls['buttonTypeSeparator'] = [
89 'type' => 'separator',
90 ];
91
92 //---text---
93 $this->controls['text'] = [
94 'label' => esc_html__( 'Button Title', 'wpfnl' ),
95 'type' => 'text',
96 'default' => esc_html__( 'Next Step', 'wpfnl' ),
97 'placeholder' => esc_html__( 'Next Step', 'wpfnl' ),
98 ];
99
100 $this->controls['size'] = [
101 'label' => esc_html__( 'Size', 'wpfnl' ),
102 'type' => 'select',
103 'options' => $this->control_options['buttonSizes'],
104 'inline' => true,
105 'reset' => true,
106 'placeholder' => esc_html__( 'Default', 'wpfnl' ),
107 ];
108
109 $this->controls['style'] = [
110 'label' => esc_html__( 'Style', 'wpfnl' ),
111 'type' => 'select',
112 'options' => $this->control_options['styles'],
113 'inline' => true,
114 'reset' => true,
115 'default' => 'primary',
116 'placeholder' => esc_html__( 'None', 'wpfnl' ),
117 ];
118
119 $this->controls['circle'] = [
120 'label' => esc_html__( 'Circle', 'wpfnl' ),
121 'type' => 'checkbox',
122 'reset' => true,
123 ];
124
125 $this->controls['outline'] = [
126 'label' => esc_html__( 'Outline', 'wpfnl' ),
127 'type' => 'checkbox',
128 'reset' => true,
129 ];
130
131 // Icon
132 $this->controls['iconSeparator'] = [
133 'label' => esc_html__( 'Icon', 'wpfnl' ),
134 'type' => 'separator',
135 ];
136
137 $this->controls['icon'] = [
138 'label' => esc_html__( 'Icon', 'wpfnl' ),
139 'type' => 'icon',
140 ];
141
142 $this->controls['iconTypography'] = [
143 'label' => esc_html__( 'Typography', 'bricks' ),
144 'type' => 'typography',
145 'css' => [
146 [
147 'property' => 'font',
148 'selector' => 'i',
149 ],
150 ],
151 'exclude' => [
152 'font-family',
153 'font-weight',
154 'font-style',
155 'text-align',
156 'text-decoration',
157 'text-transform',
158 'line-height',
159 'letter-spacing',
160 ],
161 'required' => [ 'icon.icon', '!=', '' ],
162 ];
163
164 $this->controls['iconPosition'] = [
165 'label' => esc_html__( 'Position', 'wpfnl' ),
166 'type' => 'select',
167 'options' => $this->control_options['iconPosition'],
168 'inline' => true,
169 'placeholder' => esc_html__( 'Right', 'wpfnl' ),
170 'required' => [ 'icon', '!=', '' ],
171 ];
172
173 $this->controls['iconGap'] = [
174 'label' => esc_html__( 'Gap', 'wpfnl' ),
175 'type' => 'number',
176 'units' => true,
177 'css' => [
178 [
179 'property' => 'gap',
180 ],
181 ],
182 'required' => [ 'icon', '!=', '' ],
183 ];
184
185 $this->controls['iconSpace'] = [
186 'label' => esc_html__( 'Space between', 'wpfnl' ),
187 'type' => 'checkbox',
188 'css' => [
189 [
190 'property' => 'justify-content',
191 'value' => 'space-between',
192 ],
193 ],
194 'required' => [ 'icon', '!=', '' ],
195 ];
196 }
197
198
199 /**
200 * Render the widget output on the frontend.
201 *
202 * Written in PHP and used to generate the final HTML.
203 *
204 * @since 3.1.0
205 *
206 * @access public
207 */
208 public function render() {
209 $settings = $this->settings;
210
211 $this->set_attribute( '_root', 'class', 'bricks-button' );
212
213 if ( ! empty( $settings['size'] ) ) {
214 $this->set_attribute( '_root', 'class', $settings['size'] );
215 }
216
217 if ( ! empty( $settings['style'] ) ) {
218 // Outline
219 if ( isset( $settings['outline'] ) ) {
220 $this->set_attribute( '_root', 'class', 'outline' );
221 $this->set_attribute( '_root', 'class', "bricks-color-{$settings['style']}" );
222 }
223
224 // Fill (= default)
225 else {
226 $this->set_attribute( '_root', 'class', "bricks-background-{$settings['style']}" );
227 }
228 }
229
230 // Button circle
231 if ( isset( $settings['circle'] ) ) {
232 $this->set_attribute( '_root', 'class', 'circle' );
233 }
234
235 if ( isset( $settings['block'] ) ) {
236 $this->set_attribute( '_root', 'class', 'block' );
237 }
238
239 $output = "<a href='#' class='wpfnl-next-step-button' id='wpfunnels_next_step_controller' role='button'><span {$this->render_attributes( '_root' )} >";
240
241 $icon = ! empty( $settings['icon'] ) ? self::render_icon( $settings['icon'] ) : false;
242 $icon_position = ! empty( $settings['iconPosition'] ) ? $settings['iconPosition'] : 'right';
243
244 if ( $icon && $icon_position === 'left' ) {
245 $output .= $icon;
246 }
247
248 if ( ! empty( $settings['text'] ) ) {
249 $output .= trim( $settings['text'] );
250 }
251
252 if ( $icon && $icon_position === 'right' ) {
253 $output .= $icon;
254 }
255
256 $output .= "</span></a>";
257
258 echo $output;
259 }
260
261
262
263 }
264