PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.5
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.5
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 / data-store / class-wpfnl-step-metas.php

class-wpfnl-step-metas.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.5, at includes/core/data-store/class-wpfnl-step-metas.php

211 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Step metas
4 *
5 * @package
6 */
7 namespace WPFunnels\Metas;
8
9 class Wpfnl_Step_Meta_keys
10 {
11
12 /**
13 * List of all meta keys used
14 * in different step initializations
15 *
16 * @param string $type
17 *
18 * @return mixed
19 */
20 public static function get_meta_keys($type = 'landing')
21 {
22 $meta_keys = [
23 'landing' => [],
24 'checkout' => [
25 '_wpfnl_checkout_products' => [],
26 '_wpfnl_checkout_discount' => [],
27 '_wpfnl_checkout_coupon' => '',
28 '_wpfnl_checkout_collapsible_coupon' => '',
29 '_wpfnl_express_checkout_enabled' => 'no',
30 ],
31 'thankyou' => [
32 '_wpfnl_thankyou_text' => '',
33 '_wpfnl_thankyou_redirect_link' => '',
34 '_wpfnl_thankyou_order_overview' => 'on',
35 '_wpfnl_thankyou_order_details' => 'on',
36 '_wpfnl_thankyou_billing_details' => 'on',
37 '_wpfnl_thankyou_shipping_details' => 'on',
38 ],
39 'upsell' => [
40 '_wpfnl_upsell_product' => [],
41 '_wpfnl_upsell_discount_type' => '',
42 '_wpfnl_upsell_discount_value' => '',
43 '_wpfnl_upsell_product_price' => '',
44 '_wpfnl_upsell_product_sale_price' => '',
45 '_wpfnl_upsell_hide_image' => 'off',
46 '_wpfnl_upsell_next_step_yes' => '',
47 '_wpfnl_upsell_next_step_no' => '',
48 ],
49 'downsell' => [
50 '_wpfnl_downsell_product' => [],
51 '_wpfnl_downsell_discount_type' => '',
52 '_wpfnl_downsell_discount_value' => '',
53 '_wpfnl_downsell_product_price' => '',
54 '_wpfnl_downsell_product_sale_price' => '',
55 '_wpfnl_downsell_hide_image' => 'off',
56 '_wpfnl_downsell_next_step_yes' => '',
57 '_wpfnl_downsell_next_step_no' => '',
58 ],
59 'custom' => [],
60 'trigger' => [],
61 ];
62 $meta_keys = apply_filters( 'wpfunnels/supported_steps_key', $meta_keys );
63
64 return $meta_keys[$type];
65 }
66
67
68 /**
69 * Get meta keys and its sanitization fields for landing step
70 *
71 * @return array[]
72 * @since 3.1.0
73 *
74 * @todo : Need to add all landing meta data within this function
75 */
76 public static function get_landing_meta() {
77 return array(
78 '_wpfnl_custom_script' => array(
79 'default' => '',
80 'sanitize_func' => 'FILTER_SCRIPT',
81 ),
82 '_wpfnl_custom_css' => array(
83 'default' => '',
84 'sanitize_func' => 'FILTER_SCRIPT',
85 ),
86 );
87 }
88
89 /**
90 * Get meta keys and its sanitization fields for checkout step
91 *
92 * @return array[]
93 * @since 3.1.0
94 *
95 * @todo : Need to add all checkout meta data within this function
96 */
97 public static function get_checkout_meta() {
98 return array(
99 '_wpfnl_custom_script' => array(
100 'default' => '',
101 'sanitize_func' => 'FILTER_SCRIPT',
102 ),
103 '_wpfnl_custom_css' => array(
104 'default' => '',
105 'sanitize_func' => 'FILTER_SCRIPT',
106 ),
107 '_wpfnl_express_checkout_enabled' => array(
108 'default' => 'yes',
109 'sanitize_func' => 'FILTER_DEFAULT',
110 ),
111 '_wpfnl_express_checkout_position' => array(
112 'default' => 'top',
113 'sanitize_func' => 'FILTER_DEFAULT',
114 ),
115 );
116 }
117
118 /**
119 * Get meta keys and its sanitization fields for thankyou step
120 *
121 * @return array[]
122 * @since 3.1.0
123 *
124 * @todo : Need to add all thankyou meta data within this function
125 */
126 public static function get_thankyou_meta() {
127 return array(
128 '_wpfnl_custom_script' => array(
129 'default' => '',
130 'sanitize_func' => 'FILTER_SCRIPT',
131 ),
132 '_wpfnl_custom_css' => array(
133 'default' => '',
134 'sanitize_func' => 'FILTER_SCRIPT',
135 ),
136 );
137 }
138
139 /**
140 * Get meta keys and its sanitization fields for offer step
141 *
142 * @return array[]
143 * @since 3.1.0
144 *
145 * @todo : Need to add all offer meta data within this function
146 */
147 public static function get_offer_meta() {
148 return array(
149 '_wpfnl_custom_script' => array(
150 'default' => '',
151 'sanitize_func' => 'FILTER_SCRIPT',
152 ),
153 '_wpfnl_custom_css' => array(
154 'default' => '',
155 'sanitize_func' => 'FILTER_SCRIPT',
156 ),
157 );
158 }
159
160 /**
161 * Get meta keys and its sanitization fields for custom step
162 *
163 * @return array[]
164 * @since 3.1.0
165 *
166 * @todo : Need to add all custom meta data within this function
167 */
168 public static function get_custom_meta() {
169 return array(
170 '_wpfnl_custom_script' => array(
171 'default' => '',
172 'sanitize_func' => 'FILTER_SCRIPT',
173 ),
174 '_wpfnl_custom_css' => array(
175 'default' => '',
176 'sanitize_func' => 'FILTER_SCRIPT',
177 ),
178 );
179 }
180
181
182 /**
183 * Save meta field of steps
184 *
185 * @param $step_id
186 * @param $settings
187 * @param $default_meta
188 * @since 3.1.0
189 */
190 public static function save_meta( $step_id, $settings, $default_meta ) {
191 foreach ( $default_meta as $key => $data ) {
192 if ( ! isset( $settings[ $key ] ) ) {
193 continue;
194 }
195 $sanitize_filter = $data['sanitize_func'];
196 $meta_value = '';
197 switch ( $sanitize_filter ) {
198 case 'FILTER_SCRIPT':
199 $meta_value = htmlentities( wp_unslash( $settings[ $key ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
200 break;
201 case 'FILTER_DEFAULT':
202 $meta_value = sanitize_text_field( $settings[ $key ] );
203 break;
204 default:
205 break;
206 }
207 update_post_meta($step_id, $key, $meta_value );
208 }
209 }
210 }
211