PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.13
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.13
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 / shortcodes / class-wpfnl-shortcode-next-step-button.php

class-wpfnl-shortcode-next-step-button.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.13, at includes/core/shortcodes/class-wpfnl-shortcode-next-step-button.php

178 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Next step shortcode class
4 *
5 * @package
6 */
7 namespace WPFunnels\Shortcodes;
8
9 use WPFunnels\Wpfnl_functions;
10
11 /**
12 * Class WC_Shortcode_Optin
13 *
14 * @package WPFunnels\Shortcodes
15 */
16 class Wpfnl_Shortcode_NextStepButton {
17
18 /**
19 * Attributes
20 *
21 * @var array
22 */
23 protected $attributes = array();
24
25
26 /**
27 * Wpfnl_Shortcode_Order_details constructor.
28 *
29 * @param array $attributes
30 */
31 public function __construct( $attributes = array() ) {
32
33 $this->attributes = $this->parse_attributes( $attributes );
34
35
36 }
37
38
39 /**
40 * Get shortcode attributes.
41 *
42 * @since 3.2.0
43 * @return array
44 */
45 public function get_attributes() {
46 return $this->attributes;
47 }
48
49
50 /**
51 * Parse attributes
52 *
53 * @param $attributes
54 *
55 * @return array
56 */
57 protected function parse_attributes( $attributes ) {
58
59 $attributes = shortcode_atts(
60 array(
61 'btn_text' => '',
62 'background_color' => '',
63 'color' => '',
64 'padding' => '',
65 'class' => '',
66 'button_type' => '',
67 'data_url' => '',
68 'border_radius' => '',
69 'font_size' => '',
70 'width' => '',
71 'border' => '',
72 'align' => '',
73 'target' => '',
74 'icon' => '',
75 'icon_position' => 'before',
76 'font_family' => '',
77 'font_weight' => '',
78 'text_transform' => '',
79 'letter_spacing' => '',
80 'line_height' => '',
81 'box_shadow' => '',
82 'display' => 'inline-block',
83 'custom_id' => '',
84 'custom_attrs' => '',
85 ),
86 $attributes
87 );
88 return $attributes;
89 }
90
91 /**
92 * Get wrapper classes
93 *
94 * @return array
95 */
96 protected function get_wrapper_classes() {
97 $classes = array( 'wpfnl', 'wpfnl-order-details-wrapper' );
98 return $classes;
99 }
100
101
102 /**
103 * Generates the HTML output for the customizable button shortcode in WPFunnels.
104 *
105 * This function checks if the current step type is 'landing' or 'custom'.
106 * If valid, it renders a next-step button with a variety of customizable
107 * style and data attributes based on shortcode inputs.
108 *
109 * @return string|false HTML markup for the button or false if step type is invalid.
110 * @since 3.5.19
111 */
112 public function get_content(){
113 if (Wpfnl_functions::check_if_this_is_step_type('landing') || Wpfnl_functions::check_if_this_is_step_type('custom')) {
114
115 $products_array = get_post_meta(get_the_ID(), 'checkout_product_selector', true);
116 $products = $products_array ? implode(",", $products_array) : '';
117
118 // Build inline styles dynamically
119 $style = 'cursor: pointer;';
120 $style .= !empty($this->attributes['background_color']) ? 'background-color: ' . esc_html($this->attributes['background_color']) . ';' : '';
121 $style .= !empty($this->attributes['color']) ? 'color: ' . esc_html($this->attributes['color']) . ';' : '';
122 $style .= !empty($this->attributes['padding']) ? 'padding: ' . esc_html($this->attributes['padding']) . ';' : '';
123 $style .= !empty($this->attributes['border_radius']) ? 'border-radius: ' . esc_html($this->attributes['border_radius']) . ';' : '';
124 $style .= !empty($this->attributes['font_size']) ? 'font-size: ' . esc_html($this->attributes['font_size']) . ';' : '';
125 $style .= !empty($this->attributes['width']) ? 'width: ' . esc_html($this->attributes['width']) . ';' : '';
126 $style .= !empty($this->attributes['border']) ? 'border: ' . esc_html($this->attributes['border']) . ';' : '';
127 $style .= !empty($this->attributes['font_family']) ? 'font-family: ' . esc_html($this->attributes['font_family']) . ';' : '';
128 $style .= !empty($this->attributes['font_weight']) ? 'font-weight: ' . esc_html($this->attributes['font_weight']) . ';' : '';
129 $style .= !empty($this->attributes['text_transform']) ? 'text-transform: ' . esc_html($this->attributes['text_transform']) . ';' : '';
130 $style .= !empty($this->attributes['letter_spacing']) ? 'letter-spacing: ' . esc_html($this->attributes['letter_spacing']) . ';' : '';
131 $style .= !empty($this->attributes['line_height']) ? 'line-height: ' . esc_html($this->attributes['line_height']) . ';' : '';
132 $style .= !empty($this->attributes['box_shadow']) ? 'box-shadow: ' . esc_html($this->attributes['box_shadow']) . ';' : '';
133 $style .= !empty($this->attributes['display']) ? 'display: ' . esc_html($this->attributes['display']) . ';' : '';
134
135 // Alignment
136 $align_style = !empty($this->attributes['align']) ? 'text-align: ' . esc_attr($this->attributes['align']) . ';' : '';
137
138 // Button Text with optional icon
139 $btn_text = isset($this->attributes['btn_text']) && $this->attributes['btn_text'] ? esc_html($this->attributes['btn_text']) : 'Get Now';
140 $icon = isset($this->attributes['icon']) ? $this->attributes['icon'] : '';
141 $icon_position = isset($this->attributes['icon_position']) ? $this->attributes['icon_position'] : 'before';
142
143 $button_label = '';
144 if (!empty($icon) && $icon_position === 'before') {
145 $button_label .= $icon . ' ';
146 }
147 $button_label .= $btn_text;
148 if (!empty($icon) && $icon_position === 'after') {
149 $button_label .= ' ' . $icon;
150 }
151
152 $html = '';
153 do_action('wpfunnels/before_next_step_button');
154
155 $html .= '<div class="next-step-button-wrapper" style="' . $align_style . '">';
156 $html .= '<a href="#"
157 data-button-type="' . esc_attr($this->attributes['button_type']) . '"
158 data-url="' . esc_url($this->attributes['data_url']) . '"
159 data-id="' . get_the_ID() . '"
160 data-products="' . esc_attr($products) . '"
161 id="' . esc_attr(!empty($this->attributes['custom_id']) ? $this->attributes['custom_id'] : 'wpfunnels_next_step_controller') . '"
162 style="' . $style . '"
163 class="' . esc_attr($this->attributes['class']) . ' next-step-button btn-default"
164 target="' . esc_attr($this->attributes['target']) . '"'
165 . (!empty($this->attributes['custom_attrs']) ? ' ' . $this->attributes['custom_attrs'] : '') . '>';
166
167 $html .= $button_label;
168
169 $html .= '</a></div><span class="wpfnl-alert" id="wpfnl-next-button-loader"></span>';
170
171 do_action('wpfunnels/after_next_step_button');
172
173 return $html;
174 }
175 return false;
176 }
177 }
178