| @@ -4,8 +4,12 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package Cartflows |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | +// Exit if accessed directly. | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | +} | |
| 8 | 12 | /** |
| 9 | 13 | * Initialization |
| 10 | 14 | * |
| 11 | 15 | * @since 1.0.0 |
| @@ -12,8 +16,9 @@ | ||
| 12 | 16 | */ |
| 13 | 17 | class Cartflows_Default_Meta { |
| 14 | 18 | |
| 15 | 19 | |
| 20 | + | |
| 16 | 21 | /** |
| 17 | 22 | * Member Variable |
| 18 | 23 | * |
| 19 | 24 | * @var instance |
| @@ -40,21 +45,35 @@ | ||
| 40 | 45 | * @var flow_fields |
| 41 | 46 | */ |
| 42 | 47 | private static $flow_fields = null; |
| 43 | 48 | |
| 44 | - /** | |
| 45 | - * Member Variable | |
| 46 | - * | |
| 47 | - * @var landing_fields | |
| 48 | - */ | |
| 49 | + /** | |
| 50 | + * Member Variable | |
| 51 | + * | |
| 52 | + * @var landing_fields | |
| 53 | + */ | |
| 49 | 54 | private static $landing_fields = null; |
| 50 | 55 | |
| 51 | 56 | /** |
| 57 | + * Member Variable | |
| 58 | + * | |
| 59 | + * @var optin_fields | |
| 60 | + */ | |
| 61 | + private static $optin_fields = null; | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Member Variable | |
| 65 | + * | |
| 66 | + * @var show_design_meta | |
| 67 | + */ | |
| 68 | + private static $show_design_meta = null; | |
| 69 | + | |
| 70 | + /** | |
| 52 | 71 | * Initiator |
| 53 | 72 | */ |
| 54 | 73 | public static function get_instance() { |
| 55 | 74 | if ( ! isset( self::$instance ) ) { |
| 56 | - self::$instance = new self; | |
| 75 | + self::$instance = new self(); | |
| 57 | 76 | } |
| 58 | 77 | return self::$instance; |
| 59 | 78 | } |
| 60 | 79 | |
| @@ -61,9 +80,25 @@ | ||
| 61 | 80 | /** |
| 62 | 81 | * Constructor |
| 63 | 82 | */ |
| 64 | 83 | public function __construct() { |
| 84 | + } | |
| 65 | 85 | |
| 86 | + /** | |
| 87 | + * Show design meta options. | |
| 88 | + * | |
| 89 | + * @return string | |
| 90 | + */ | |
| 91 | + public function get_show_design_meta_value() { | |
| 92 | + | |
| 93 | + if ( null === self::$show_design_meta ) { | |
| 94 | + | |
| 95 | + $show_design = get_option( 'cartflows-legacy-meta-show-design-options', false ); | |
| 96 | + | |
| 97 | + self::$show_design_meta = $show_design ? 'yes' : 'no'; | |
| 98 | + } | |
| 99 | + | |
| 100 | + return self::$show_design_meta; | |
| 66 | 101 | } |
| 67 | 102 | |
| 68 | 103 | /** |
| 69 | 104 | * Checkout Default fields. |
| @@ -70,232 +105,389 @@ | ||
| 70 | 105 | * |
| 71 | 106 | * @param int $post_id post id. |
| 72 | 107 | * @return array |
| 73 | 108 | */ |
| 74 | - function get_checkout_fields( $post_id ) { | |
| 109 | + public function get_checkout_fields( $post_id ) { | |
| 75 | 110 | |
| 76 | 111 | if ( null === self::$checkout_fields ) { |
| 77 | - | |
| 78 | 112 | self::$checkout_fields = array( |
| 79 | - 'wcf-field-google-font-url' => array( | |
| 113 | + 'wcf-enable-design-settings' => array( | |
| 114 | + 'default' => $this->get_show_design_meta_value(), | |
| 115 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 116 | + ), | |
| 117 | + 'wcf-disable-step' => array( | |
| 118 | + 'default' => 'no', | |
| 119 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 120 | + ), | |
| 121 | + 'wcf-field-google-font-url' => array( | |
| 80 | 122 | 'default' => '', |
| 81 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 123 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 82 | 124 | ), |
| 83 | - 'wcf-checkout-products' => array( | |
| 125 | + 'wcf-checkout-products' => array( | |
| 84 | 126 | 'default' => array(), |
| 85 | 127 | 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS', |
| 86 | 128 | ), |
| 87 | - 'wcf-checkout-layout' => array( | |
| 88 | - 'default' => 'two-column', | |
| 89 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 129 | + 'wcf-checkout-layout' => array( | |
| 130 | + 'default' => 'modern-checkout', | |
| 131 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 90 | 132 | ), |
| 91 | - 'wcf-input-font-family' => array( | |
| 133 | + 'wcf-input-font-family' => array( | |
| 92 | 134 | 'default' => '', |
| 93 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 135 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 94 | 136 | ), |
| 95 | - 'wcf-input-font-weight' => array( | |
| 137 | + 'wcf-input-font-weight' => array( | |
| 96 | 138 | 'default' => '', |
| 97 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 139 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 98 | 140 | ), |
| 99 | - 'wcf-heading-font-family' => array( | |
| 141 | + 'wcf-heading-font-family' => array( | |
| 100 | 142 | 'default' => '', |
| 101 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 143 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 102 | 144 | ), |
| 103 | - 'wcf-heading-font-weight' => array( | |
| 145 | + 'wcf-heading-font-weight' => array( | |
| 104 | 146 | 'default' => '', |
| 105 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 147 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 106 | 148 | ), |
| 107 | - 'wcf-base-font-family' => array( | |
| 149 | + 'wcf-base-font-family' => array( | |
| 108 | 150 | 'default' => '', |
| 109 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 151 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 110 | 152 | ), |
| 111 | - 'wcf-advance-options-fields' => array( | |
| 153 | + 'wcf-advance-options-fields' => array( | |
| 112 | 154 | 'default' => '', |
| 113 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 155 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 114 | 156 | ), |
| 115 | - 'wcf-base-font-weight' => array( | |
| 157 | + 'wcf-remove-product-field' => array( | |
| 116 | 158 | 'default' => '', |
| 117 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 159 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 118 | 160 | ), |
| 119 | - 'wcf-button-font-family' => array( | |
| 161 | + // Custom Shipping error message start. | |
| 162 | + 'wcf-custom-no-shipping-method-message-toggle' => array( | |
| 163 | + 'default' => 'no', | |
| 164 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 165 | + ), | |
| 166 | + 'wcf-no-shipping-method-message' => array( | |
| 167 | + 'default' => __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'cartflows' ), | |
| 168 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 169 | + ), | |
| 170 | + // Custom Shipping error message end. | |
| 171 | + 'wcf-order-review-show-product-images' => array( | |
| 172 | + 'default' => 'yes', | |
| 173 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 174 | + ), | |
| 175 | + 'wcf-order-review-summary-position' => array( | |
| 176 | + 'default' => 'top', | |
| 177 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 178 | + ), | |
| 179 | + 'wcf-checkout-place-order-button-text' => array( | |
| 180 | + 'default' => __( 'Place Order', 'cartflows' ), | |
| 181 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 182 | + ), | |
| 183 | + 'wcf-checkout-place-order-button-lock' => array( | |
| 184 | + 'default' => 'yes', | |
| 185 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 186 | + ), | |
| 187 | + 'wcf-checkout-place-order-button-price-display' => array( | |
| 188 | + 'default' => 'yes', | |
| 189 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 190 | + ), | |
| 191 | + 'wcf-base-font-weight' => array( | |
| 120 | 192 | 'default' => '', |
| 121 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 193 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 122 | 194 | ), |
| 123 | - 'wcf-button-font-weight' => array( | |
| 195 | + 'wcf-button-font-family' => array( | |
| 124 | 196 | 'default' => '', |
| 125 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 197 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 126 | 198 | ), |
| 127 | - 'wcf-primary-color' => array( | |
| 199 | + 'wcf-button-font-weight' => array( | |
| 128 | 200 | 'default' => '', |
| 129 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 201 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 130 | 202 | ), |
| 131 | - 'wcf-heading-color' => array( | |
| 203 | + 'wcf-primary-color' => array( | |
| 132 | 204 | 'default' => '', |
| 133 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 205 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 134 | 206 | ), |
| 135 | - 'wcf-section-bg-color' => array( | |
| 207 | + 'wcf-heading-color' => array( | |
| 136 | 208 | 'default' => '', |
| 137 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 209 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 138 | 210 | ), |
| 139 | - 'wcf-hl-bg-color' => array( | |
| 211 | + 'wcf-section-bg-color' => array( | |
| 140 | 212 | 'default' => '', |
| 141 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 213 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 142 | 214 | ), |
| 143 | - 'wcf-field-tb-padding' => array( | |
| 215 | + 'wcf-hl-bg-color' => array( | |
| 144 | 216 | 'default' => '', |
| 145 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 217 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 146 | 218 | ), |
| 147 | - 'wcf-field-lr-padding' => array( | |
| 219 | + 'wcf-field-tb-padding' => array( | |
| 148 | 220 | 'default' => '', |
| 149 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 221 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 150 | 222 | ), |
| 151 | - 'wcf-fields-skins' => array( | |
| 223 | + 'wcf-field-lr-padding' => array( | |
| 152 | 224 | 'default' => '', |
| 153 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 225 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 154 | 226 | ), |
| 155 | - 'wcf-input-field-size' => array( | |
| 227 | + 'wcf-fields-skins' => array( | |
| 228 | + 'default' => 'modern-label', | |
| 229 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 230 | + ), | |
| 231 | + 'wcf-input-field-size' => array( | |
| 156 | 232 | 'default' => '33px', |
| 157 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 233 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 158 | 234 | ), |
| 159 | - 'wcf-field-color' => array( | |
| 235 | + 'wcf-field-color' => array( | |
| 160 | 236 | 'default' => '', |
| 161 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 237 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 162 | 238 | ), |
| 163 | - 'wcf-field-bg-color' => array( | |
| 239 | + 'wcf-field-bg-color' => array( | |
| 164 | 240 | 'default' => '', |
| 165 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 241 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 166 | 242 | ), |
| 167 | - 'wcf-field-border-color' => array( | |
| 243 | + 'wcf-field-border-color' => array( | |
| 168 | 244 | 'default' => '', |
| 169 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 245 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 170 | 246 | ), |
| 171 | - 'wcf-box-border-color' => array( | |
| 247 | + 'wcf-box-border-color' => array( | |
| 172 | 248 | 'default' => '', |
| 173 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 249 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 174 | 250 | ), |
| 175 | - 'wcf-field-label-color' => array( | |
| 251 | + 'wcf-field-label-color' => array( | |
| 176 | 252 | 'default' => '', |
| 177 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 253 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 178 | 254 | ), |
| 179 | - 'wcf-submit-tb-padding' => array( | |
| 255 | + 'wcf-submit-tb-padding' => array( | |
| 180 | 256 | 'default' => '', |
| 181 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 257 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 182 | 258 | ), |
| 183 | - 'wcf-submit-lr-padding' => array( | |
| 259 | + 'wcf-submit-lr-padding' => array( | |
| 184 | 260 | 'default' => '', |
| 185 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 261 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 186 | 262 | ), |
| 187 | - 'wcf-input-button-size' => array( | |
| 263 | + 'wcf-input-button-size' => array( | |
| 188 | 264 | 'default' => '33px', |
| 189 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 265 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 190 | 266 | ), |
| 191 | - 'wcf-submit-color' => array( | |
| 267 | + 'wcf-submit-color' => array( | |
| 192 | 268 | 'default' => '', |
| 193 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 269 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 194 | 270 | ), |
| 195 | - 'wcf-submit-hover-color' => array( | |
| 271 | + 'wcf-submit-hover-color' => array( | |
| 196 | 272 | 'default' => '', |
| 197 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 273 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 198 | 274 | ), |
| 199 | - 'wcf-submit-bg-color' => array( | |
| 275 | + 'wcf-submit-bg-color' => array( | |
| 200 | 276 | 'default' => '', |
| 201 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 277 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 202 | 278 | ), |
| 203 | - 'wcf-submit-bg-hover-color' => array( | |
| 279 | + 'wcf-submit-bg-hover-color' => array( | |
| 204 | 280 | 'default' => '', |
| 205 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 281 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 206 | 282 | ), |
| 207 | - 'wcf-submit-border-color' => array( | |
| 283 | + 'wcf-submit-border-color' => array( | |
| 208 | 284 | 'default' => '', |
| 209 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 285 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 210 | 286 | ), |
| 211 | - 'wcf-submit-border-hover-color' => array( | |
| 287 | + 'wcf-submit-border-hover-color' => array( | |
| 212 | 288 | 'default' => '', |
| 213 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 289 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 214 | 290 | ), |
| 215 | - 'wcf-active-tab' => array( | |
| 291 | + 'wcf-header-logo-image' => array( | |
| 216 | 292 | 'default' => '', |
| 217 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 293 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 218 | 294 | ), |
| 219 | - 'wcf-header-logo-image' => array( | |
| 295 | + 'wcf-header-logo-width' => array( | |
| 220 | 296 | 'default' => '', |
| 221 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 297 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 222 | 298 | ), |
| 223 | - 'wcf-header-logo-width' => array( | |
| 299 | + 'wcf-custom-script' => array( | |
| 224 | 300 | 'default' => '', |
| 225 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 301 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 226 | 302 | ), |
| 227 | - 'wcf-custom-script' => array( | |
| 303 | + 'wcf-step-custom-js' => array( | |
| 228 | 304 | 'default' => '', |
| 229 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 305 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 230 | 306 | ), |
| 231 | - ); | |
| 307 | + 'wcf-step-custom-css' => array( | |
| 308 | + 'default' => '', | |
| 309 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 310 | + ), | |
| 311 | + 'wcf-step-note' => array( | |
| 312 | + 'default' => '', | |
| 313 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 314 | + ), | |
| 232 | 315 | |
| 233 | - self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id ); | |
| 234 | - } | |
| 316 | + 'wcf-custom-checkout-fields' => array( | |
| 317 | + 'default' => 'no', | |
| 318 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 319 | + ), | |
| 320 | + 'wcf-show-coupon-field' => array( | |
| 321 | + 'default' => 'yes', | |
| 322 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 323 | + ), | |
| 324 | + 'wcf-optimize-coupon-field' => array( | |
| 325 | + 'default' => 'no', | |
| 326 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 327 | + ), | |
| 328 | + 'wcf_field_order_billing' => array( | |
| 329 | + 'default' => array(), | |
| 330 | + 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_FIELDS', | |
| 331 | + ), | |
| 332 | + 'wcf_field_order_shipping' => array( | |
| 333 | + 'default' => array(), | |
| 334 | + 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_FIELDS', | |
| 335 | + ), | |
| 336 | + 'wcf-google-autoaddress' => array( | |
| 337 | + 'default' => 'yes', | |
| 338 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 339 | + ), | |
| 235 | 340 | |
| 236 | - return self::$checkout_fields; | |
| 237 | - } | |
| 341 | + 'wcf-checkout-additional-fields' => array( | |
| 342 | + 'default' => 'yes', | |
| 343 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 344 | + ), | |
| 345 | + 'wcf-optimize-order-note-field' => array( | |
| 346 | + 'default' => 'no', | |
| 347 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 348 | + ), | |
| 238 | 349 | |
| 239 | - /** | |
| 240 | - * Save Checkout Meta fields. | |
| 241 | - * | |
| 242 | - * @param int $post_id post id. | |
| 243 | - * @return void | |
| 244 | - */ | |
| 245 | - function save_checkout_fields( $post_id ) { | |
| 350 | + 'wcf-shipto-diff-addr-fields' => array( | |
| 351 | + 'default' => 'yes', | |
| 352 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 353 | + ), | |
| 354 | + 'wcf-checkout-customer-info-text' => array( | |
| 355 | + 'default' => '', | |
| 356 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 357 | + ), | |
| 358 | + 'wcf-checkout-billing-details-text' => array( | |
| 359 | + 'default' => '', | |
| 360 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 361 | + ), | |
| 362 | + 'wcf-checkout-shipping-details-text' => array( | |
| 363 | + 'default' => '', | |
| 364 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 365 | + ), | |
| 366 | + 'wcf-checkout-your-order-text' => array( | |
| 367 | + 'default' => '', | |
| 368 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 369 | + ), | |
| 370 | + 'wcf-checkout-payment-text' => array( | |
| 371 | + 'default' => '', | |
| 372 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 373 | + ), | |
| 374 | + 'wcf-enable-checkout-field-validation-text' => array( | |
| 375 | + 'default' => 'yes', | |
| 376 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 377 | + ), | |
| 378 | + 'wcf-checkout-field-validation-text' => array( | |
| 379 | + 'default' => __( 'is required', 'cartflows' ), | |
| 380 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 381 | + ), | |
| 246 | 382 | |
| 247 | - $post_meta = $this->get_checkout_fields( $post_id ); | |
| 383 | + /** Start Instant checkout section titles */ | |
| 384 | + 'wcf-instant-checkout-shipping-options-text' => array( | |
| 385 | + 'default' => '', | |
| 386 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 387 | + ), | |
| 248 | 388 | |
| 249 | - $this->save_meta_fields( $post_id, $post_meta ); | |
| 250 | - } | |
| 389 | + 'wcf-instant-checkout-left-side-bg-color' => array( | |
| 390 | + 'default' => '', | |
| 391 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 392 | + ), | |
| 393 | + 'wcf-instant-checkout-right-side-bg-color' => array( | |
| 394 | + 'default' => '', | |
| 395 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 396 | + ), | |
| 397 | + /** End Instant checkout section titles */ | |
| 251 | 398 | |
| 252 | - /** | |
| 253 | - * Save Landing Meta fields. | |
| 254 | - * | |
| 255 | - * @param int $post_id post id. | |
| 256 | - * @return void | |
| 257 | - */ | |
| 258 | - function save_landing_fields( $post_id ) { | |
| 399 | + ); | |
| 259 | 400 | |
| 260 | - $post_meta = $this->get_landing_fields( $post_id ); | |
| 401 | + self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id ); | |
| 402 | + } | |
| 261 | 403 | |
| 262 | - $this->save_meta_fields( $post_id, $post_meta ); | |
| 404 | + return self::$checkout_fields; | |
| 263 | 405 | } |
| 264 | 406 | |
| 265 | 407 | /** |
| 266 | - * Save ThankYou Meta fields. | |
| 267 | - * | |
| 268 | - * @param int $post_id post id. | |
| 269 | - * @return void | |
| 270 | - */ | |
| 271 | - function save_thankyou_fields( $post_id ) { | |
| 272 | - | |
| 273 | - $post_meta = $this->get_thankyou_fields( $post_id ); | |
| 274 | - | |
| 275 | - $this->save_meta_fields( $post_id, $post_meta ); | |
| 276 | - } | |
| 277 | - | |
| 278 | - /** | |
| 279 | 408 | * Flow Default fields. |
| 280 | 409 | * |
| 281 | 410 | * @param int $post_id post id. |
| 282 | 411 | * @return array |
| 283 | 412 | */ |
| 284 | - function get_flow_fields( $post_id ) { | |
| 413 | + public function get_flow_fields( $post_id ) { | |
| 285 | 414 | |
| 286 | 415 | if ( null === self::$flow_fields ) { |
| 287 | - | |
| 288 | 416 | self::$flow_fields = array( |
| 289 | - 'wcf-steps' => array( | |
| 417 | + 'wcf-steps' => array( | |
| 290 | 418 | 'default' => array(), |
| 291 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 419 | + 'sanitize' => '', // This key always updated from prepared array. Not from user input and save button click. | |
| 292 | 420 | ), |
| 293 | - | |
| 294 | - 'wcf-testing' => array( | |
| 295 | - 'default' => 'yes', | |
| 296 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 421 | + 'wcf-flow-indexing' => array( | |
| 422 | + 'default' => '', | |
| 423 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 297 | 424 | ), |
| 425 | + 'wcf-testing' => array( | |
| 426 | + 'default' => 'no', | |
| 427 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 428 | + ), | |
| 429 | + 'wcf-enable-analytics' => array( | |
| 430 | + 'default' => 'no', | |
| 431 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 432 | + ), | |
| 433 | + 'wcf-flow-custom-script' => array( | |
| 434 | + 'default' => '', | |
| 435 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 436 | + ), | |
| 437 | + 'wcf-flow-custom-js' => array( | |
| 438 | + 'default' => '', | |
| 439 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 440 | + ), | |
| 441 | + 'wcf-flow-custom-css' => array( | |
| 442 | + 'default' => '', | |
| 443 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 444 | + ), | |
| 445 | + // Global Color Pallet color options. | |
| 446 | + 'wcf-enable-gcp-styling' => array( | |
| 447 | + 'default' => 'no', | |
| 448 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 449 | + ), | |
| 450 | + 'wcf-gcp-primary-color' => array( | |
| 451 | + 'default' => '#f16334', | |
| 452 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 453 | + ), | |
| 454 | + 'wcf-gcp-secondary-color' => array( | |
| 455 | + 'default' => '#000000', | |
| 456 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 457 | + ), | |
| 458 | + 'wcf-gcp-text-color' => array( | |
| 459 | + 'default' => '#4B5563', | |
| 460 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 461 | + ), | |
| 462 | + 'wcf-gcp-accent-color' => array( | |
| 463 | + 'default' => '#1F2937', | |
| 464 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 465 | + ), | |
| 466 | + 'wcf-gcp-primary-base-font-family' => array( | |
| 467 | + 'default' => '', | |
| 468 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 469 | + ), | |
| 470 | + 'instant-layout-style' => array( | |
| 471 | + 'default' => 'no', | |
| 472 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 473 | + ), | |
| 474 | + 'wcf-instant-checkout-header-logo-width' => array( | |
| 475 | + 'default' => '', | |
| 476 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 477 | + ), | |
| 478 | + 'wcf-instant-checkout-header-logo' => array( | |
| 479 | + 'default' => '', | |
| 480 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 481 | + ), | |
| 482 | + 'wcf-instant-checkout-header-logo-height' => array( | |
| 483 | + 'default' => '', | |
| 484 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 485 | + ), | |
| 486 | + 'wcf-instant-checkout-header-color' => array( | |
| 487 | + 'default' => '', | |
| 488 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 489 | + ), | |
| 298 | 490 | ); |
| 299 | 491 | } |
| 300 | 492 | |
| 301 | 493 | return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields ); |
| @@ -301,392 +493,8 @@ | ||
| 301 | 493 | return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields ); |
| 302 | 494 | } |
| 303 | 495 | |
| 304 | 496 | /** |
| 305 | - * Save Flow Meta fields. | |
| 306 | - * | |
| 307 | - * @param int $post_id post id. | |
| 308 | - * @return void | |
| 309 | - */ | |
| 310 | - function save_flow_fields( $post_id ) { | |
| 311 | - | |
| 312 | - $post_meta = $this->get_flow_fields( $post_id ); | |
| 313 | - | |
| 314 | - if ( isset( $post_meta['wcf-steps'] ) ) { | |
| 315 | - unset( $post_meta['wcf-steps'] ); | |
| 316 | - } | |
| 317 | - | |
| 318 | - $this->save_meta_fields( $post_id, $post_meta ); | |
| 319 | - } | |
| 320 | - | |
| 321 | - /** | |
| 322 | - * Save Meta fields - Common Function. | |
| 323 | - * | |
| 324 | - * @param int $post_id post id. | |
| 325 | - * @param array $post_meta options to store. | |
| 326 | - * @return void | |
| 327 | - */ | |
| 328 | - function save_meta_fields( $post_id, $post_meta ) { | |
| 329 | - | |
| 330 | - if ( ! ( $post_id && is_array( $post_meta ) ) ) { | |
| 331 | - | |
| 332 | - return; | |
| 333 | - } | |
| 334 | - | |
| 335 | - foreach ( $post_meta as $key => $data ) { | |
| 336 | - | |
| 337 | - $meta_value = false; | |
| 338 | - | |
| 339 | - // Sanitize values. | |
| 340 | - $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT'; | |
| 341 | - | |
| 342 | - switch ( $sanitize_filter ) { | |
| 343 | - | |
| 344 | - case 'FILTER_SANITIZE_STRING': | |
| 345 | - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ); | |
| 346 | - break; | |
| 347 | - | |
| 348 | - case 'FILTER_SANITIZE_URL': | |
| 349 | - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL ); | |
| 350 | - break; | |
| 351 | - | |
| 352 | - case 'FILTER_SANITIZE_NUMBER_INT': | |
| 353 | - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT ); | |
| 354 | - break; | |
| 355 | - | |
| 356 | - case 'FILTER_CARTFLOWS_ARRAY': | |
| 357 | - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) { | |
| 358 | - $meta_value = array_map( 'sanitize_text_field', $_POST[ $key ] ); | |
| 359 | - } | |
| 360 | - break; | |
| 361 | - | |
| 362 | - case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS': | |
| 363 | - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) { | |
| 364 | - | |
| 365 | - $i = 0; | |
| 366 | - $q = 0; | |
| 367 | - | |
| 368 | - foreach ( $_POST[ $key ] as $p_index => $p_data ) { | |
| 369 | - | |
| 370 | - foreach ( $p_data as $i_key => $i_value ) { | |
| 371 | - | |
| 372 | - if ( is_array( $i_value ) ) { | |
| 373 | - | |
| 374 | - foreach ( $i_value as $q_key => $q_value ) { | |
| 375 | - | |
| 376 | - $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value ); | |
| 377 | - | |
| 378 | - $q++; | |
| 379 | - } | |
| 380 | - } else { | |
| 381 | - $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value ); | |
| 382 | - } | |
| 383 | - } | |
| 384 | - | |
| 385 | - $i++; | |
| 386 | - } | |
| 387 | - } | |
| 388 | - break; | |
| 389 | - case 'FILTER_CARTFLOWS_CHECKOUT_FIELDS': | |
| 390 | - $count = 10; | |
| 391 | - $ordered_fields = array(); | |
| 392 | - $billing_fields = array(); | |
| 393 | - | |
| 394 | - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) { | |
| 395 | - $post_data = $_POST[ $key ]; | |
| 396 | - | |
| 397 | - if ( 'wcf_field_order_billing' == $key ) { | |
| 398 | - | |
| 399 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 400 | - | |
| 401 | - foreach ( $post_data as $index => $value ) { | |
| 402 | - | |
| 403 | - if ( isset( $billing_fields[ $value ] ) ) { | |
| 404 | - $ordered_fields[ $value ] = $billing_fields[ $value ]; | |
| 405 | - $ordered_fields[ $value ]['priority'] = $count; | |
| 406 | - $count += 10; | |
| 407 | - } | |
| 408 | - } | |
| 409 | - | |
| 410 | - $meta_value = $ordered_fields; | |
| 411 | - } | |
| 412 | - | |
| 413 | - if ( 'wcf_field_order_shipping' == $key ) { | |
| 414 | - | |
| 415 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 416 | - foreach ( $post_data as $index => $value ) { | |
| 417 | - | |
| 418 | - if ( isset( $shipping_fields[ $value ] ) ) { | |
| 419 | - $ordered_fields[ $value ] = $shipping_fields[ $value ]; | |
| 420 | - $ordered_fields[ $value ]['priority'] = $count; | |
| 421 | - $count += 10; | |
| 422 | - } | |
| 423 | - } | |
| 424 | - $meta_value = $ordered_fields; | |
| 425 | - } | |
| 426 | - | |
| 427 | - if ( 'wcf_label_text_field_billing' == $key ) { | |
| 428 | - | |
| 429 | - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' ); | |
| 430 | - | |
| 431 | - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) { | |
| 432 | - echo 'con 1'; | |
| 433 | - $billing_fields = $get_ordered_billing_fields; | |
| 434 | - } else { | |
| 435 | - echo 'con 2'; | |
| 436 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 437 | - } | |
| 438 | - | |
| 439 | - foreach ( $post_data as $index => $value ) { | |
| 440 | - | |
| 441 | - if ( isset( $billing_fields[ $index ] ) ) { | |
| 442 | - $ordered_fields[ $index ] = $billing_fields[ $index ]; | |
| 443 | - $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) ); | |
| 444 | - } | |
| 445 | - } | |
| 446 | - $key = 'wcf_field_order_billing'; | |
| 447 | - $meta_value = $ordered_fields; | |
| 448 | - } | |
| 449 | - | |
| 450 | - if ( 'wcf_label_text_field_shipping' == $key ) { | |
| 451 | - | |
| 452 | - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' ); | |
| 453 | - | |
| 454 | - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) { | |
| 455 | - $shipping_fields = $get_ordered_shipping_fields; | |
| 456 | - } else { | |
| 457 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 458 | - } | |
| 459 | - | |
| 460 | - foreach ( $post_data as $index => $value ) { | |
| 461 | - | |
| 462 | - if ( isset( $shipping_fields[ $index ] ) ) { | |
| 463 | - $ordered_fields[ $index ] = $shipping_fields[ $index ]; | |
| 464 | - $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) ); | |
| 465 | - } | |
| 466 | - } | |
| 467 | - $key = 'wcf_field_order_shipping'; | |
| 468 | - $meta_value = $ordered_fields; | |
| 469 | - } | |
| 470 | - | |
| 471 | - if ( 'wcf_label_placeholder_field_billing' == $key ) { | |
| 472 | - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' ); | |
| 473 | - | |
| 474 | - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) { | |
| 475 | - $billing_fields = $get_ordered_billing_fields; | |
| 476 | - } else { | |
| 477 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 478 | - } | |
| 479 | - foreach ( $post_data as $index => $value ) { | |
| 480 | - | |
| 481 | - if ( isset( $billing_fields[ $index ] ) ) { | |
| 482 | - $ordered_fields[ $index ] = $billing_fields[ $index ]; | |
| 483 | - $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) ); | |
| 484 | - } | |
| 485 | - } | |
| 486 | - | |
| 487 | - $key = 'wcf_field_order_billing'; | |
| 488 | - $meta_value = $ordered_fields; | |
| 489 | - } | |
| 490 | - | |
| 491 | - if ( 'wcf_label_placeholder_field_shipping' == $key ) { | |
| 492 | - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' ); | |
| 493 | - | |
| 494 | - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) { | |
| 495 | - $shipping_fields = $get_ordered_shipping_fields; | |
| 496 | - } else { | |
| 497 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 498 | - } | |
| 499 | - | |
| 500 | - foreach ( $post_data as $index => $value ) { | |
| 501 | - | |
| 502 | - if ( isset( $shipping_fields[ $index ] ) ) { | |
| 503 | - $ordered_fields[ $index ] = $shipping_fields[ $index ]; | |
| 504 | - $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) ); | |
| 505 | - } | |
| 506 | - } | |
| 507 | - | |
| 508 | - $key = 'wcf_field_order_shipping'; | |
| 509 | - $meta_value = $ordered_fields; | |
| 510 | - | |
| 511 | - } | |
| 512 | - | |
| 513 | - if ( 'wcf_label_default_field_billing' == $key ) { | |
| 514 | - | |
| 515 | - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' ); | |
| 516 | - | |
| 517 | - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) { | |
| 518 | - $billing_fields = $get_ordered_billing_fields; | |
| 519 | - } else { | |
| 520 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 521 | - } | |
| 522 | - | |
| 523 | - foreach ( $post_data as $index => $value ) { | |
| 524 | - | |
| 525 | - if ( isset( $billing_fields[ $index ] ) ) { | |
| 526 | - $ordered_fields[ $index ] = $billing_fields[ $index ]; | |
| 527 | - $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) ); | |
| 528 | - } | |
| 529 | - } | |
| 530 | - | |
| 531 | - $key = 'wcf_field_order_billing'; | |
| 532 | - $meta_value = $ordered_fields; | |
| 533 | - } | |
| 534 | - | |
| 535 | - if ( 'wcf_label_default_field_shipping' == $key ) { | |
| 536 | - | |
| 537 | - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' ); | |
| 538 | - | |
| 539 | - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) { | |
| 540 | - $shipping_fields = $get_ordered_shipping_fields; | |
| 541 | - } else { | |
| 542 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 543 | - } | |
| 544 | - | |
| 545 | - foreach ( $post_data as $index => $value ) { | |
| 546 | - | |
| 547 | - if ( isset( $shipping_fields[ $index ] ) ) { | |
| 548 | - $ordered_fields[ $index ] = $shipping_fields[ $index ]; | |
| 549 | - $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) ); | |
| 550 | - } | |
| 551 | - } | |
| 552 | - | |
| 553 | - $key = 'wcf_field_order_shipping'; | |
| 554 | - $meta_value = $ordered_fields; | |
| 555 | - } | |
| 556 | - | |
| 557 | - if ( 'wcf_is_required_field_billing' == $key ) { | |
| 558 | - | |
| 559 | - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' ); | |
| 560 | - | |
| 561 | - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) { | |
| 562 | - $billing_fields = $get_ordered_billing_fields; | |
| 563 | - } else { | |
| 564 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 565 | - } | |
| 566 | - | |
| 567 | - foreach ( $post_data as $index => $value ) { | |
| 568 | - | |
| 569 | - if ( isset( $billing_fields[ $index ] ) ) { | |
| 570 | - $ordered_fields[ $index ] = $billing_fields[ $index ]; | |
| 571 | - if ( 'yes' == $value ) { | |
| 572 | - | |
| 573 | - $ordered_fields[ $index ]['required'] = true; | |
| 574 | - } else { | |
| 575 | - $ordered_fields[ $index ]['required'] = false; | |
| 576 | - } | |
| 577 | - } | |
| 578 | - } | |
| 579 | - | |
| 580 | - $key = 'wcf_field_order_billing'; | |
| 581 | - $meta_value = $ordered_fields; | |
| 582 | - } | |
| 583 | - | |
| 584 | - if ( 'wcf_is_required_field_shipping' == $key ) { | |
| 585 | - | |
| 586 | - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' ); | |
| 587 | - | |
| 588 | - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) { | |
| 589 | - $shipping_fields = $get_ordered_shipping_fields; | |
| 590 | - } else { | |
| 591 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 592 | - } | |
| 593 | - | |
| 594 | - foreach ( $post_data as $index => $value ) { | |
| 595 | - | |
| 596 | - if ( isset( $shipping_fields[ $index ] ) ) { | |
| 597 | - $ordered_fields[ $index ] = $shipping_fields[ $index ]; | |
| 598 | - | |
| 599 | - if ( 'yes' == $value ) { | |
| 600 | - | |
| 601 | - $ordered_fields[ $index ]['required'] = true; | |
| 602 | - } else { | |
| 603 | - $ordered_fields[ $index ]['required'] = false; | |
| 604 | - } | |
| 605 | - } | |
| 606 | - } | |
| 607 | - | |
| 608 | - $key = 'wcf_field_order_shipping'; | |
| 609 | - $meta_value = $ordered_fields; | |
| 610 | - } | |
| 611 | - | |
| 612 | - if ( 'wcf_select_option_field_billing' == $key ) { | |
| 613 | - | |
| 614 | - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' ); | |
| 615 | - | |
| 616 | - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) { | |
| 617 | - $billing_fields = $get_ordered_billing_fields; | |
| 618 | - } else { | |
| 619 | - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id ); | |
| 620 | - } | |
| 621 | - | |
| 622 | - foreach ( $post_data as $index => $value ) { | |
| 623 | - | |
| 624 | - $options = explode( ',', $value ); | |
| 625 | - | |
| 626 | - if ( isset( $billing_fields[ $index ] ) ) { | |
| 627 | - $ordered_fields[ $index ] = $billing_fields[ $index ]; | |
| 628 | - | |
| 629 | - $ordered_fields[ $index ]['options'] = array(); | |
| 630 | - | |
| 631 | - foreach ( $options as $key => $option ) { | |
| 632 | - | |
| 633 | - $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) ); | |
| 634 | - } | |
| 635 | - } | |
| 636 | - } | |
| 637 | - | |
| 638 | - $key = 'wcf_field_order_billing'; | |
| 639 | - $meta_value = $ordered_fields; | |
| 640 | - } | |
| 641 | - | |
| 642 | - if ( 'wcf_select_option_field_shipping' == $key ) { | |
| 643 | - | |
| 644 | - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' ); | |
| 645 | - | |
| 646 | - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) { | |
| 647 | - $shipping_fields = $get_ordered_shipping_fields; | |
| 648 | - } else { | |
| 649 | - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id ); | |
| 650 | - } | |
| 651 | - | |
| 652 | - foreach ( $post_data as $index => $value ) { | |
| 653 | - | |
| 654 | - $options = explode( ',', $value ); | |
| 655 | - | |
| 656 | - if ( isset( $shipping_fields[ $index ] ) ) { | |
| 657 | - | |
| 658 | - $ordered_fields[ $index ] = $shipping_fields[ $index ]; | |
| 659 | - | |
| 660 | - $ordered_fields[ $index ]['options'] = array(); | |
| 661 | - | |
| 662 | - foreach ( $options as $key => $option ) { | |
| 663 | - | |
| 664 | - $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) ); | |
| 665 | - } | |
| 666 | - } | |
| 667 | - } | |
| 668 | - | |
| 669 | - $key = 'wcf_field_order_shipping'; | |
| 670 | - $meta_value = $ordered_fields; | |
| 671 | - } | |
| 672 | - } | |
| 673 | - break; | |
| 674 | - | |
| 675 | - default: | |
| 676 | - $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT ); | |
| 677 | - break; | |
| 678 | - } | |
| 679 | - | |
| 680 | - if ( false !== $meta_value ) { | |
| 681 | - update_post_meta( $post_id, $key, $meta_value ); | |
| 682 | - } else { | |
| 683 | - delete_post_meta( $post_id, $key ); | |
| 684 | - } | |
| 685 | - } | |
| 686 | - } | |
| 687 | - | |
| 688 | - /** | |
| 689 | 497 | * Get checkout meta. |
| 690 | 498 | * |
| 691 | 499 | * @param int $post_id post id. |
| 692 | 500 | * @param string $key options key. |
| @@ -692,23 +500,18 @@ | ||
| 692 | 500 | * @param string $key options key. |
| 693 | 501 | * @param mix $default options default value. |
| 694 | 502 | * @return string |
| 695 | 503 | */ |
| 696 | - function get_flow_meta_value( $post_id, $key, $default = false ) { | |
| 697 | - | |
| 504 | + public function get_flow_meta_value( $post_id, $key, $default = false ) { | |
| 698 | 505 | $value = $this->get_save_meta( $post_id, $key ); |
| 699 | 506 | |
| 700 | 507 | if ( ! $value ) { |
| 701 | - | |
| 702 | 508 | if ( $default ) { |
| 703 | - | |
| 704 | 509 | $value = $default; |
| 705 | 510 | } else { |
| 706 | - | |
| 707 | 511 | $fields = $this->get_flow_fields( $post_id ); |
| 708 | 512 | |
| 709 | 513 | if ( isset( $fields[ $key ]['default'] ) ) { |
| 710 | - | |
| 711 | 514 | $value = $fields[ $key ]['default']; |
| 712 | 515 | } |
| 713 | 516 | } |
| 714 | 517 | } |
| @@ -723,29 +526,25 @@ | ||
| 723 | 526 | * @param string $key options key. |
| 724 | 527 | * @param mix $default options default value. |
| 725 | 528 | * @return string |
| 726 | 529 | */ |
| 727 | - function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) { | |
| 530 | + public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) { | |
| 728 | 531 | |
| 729 | 532 | $value = $this->get_save_meta( $post_id, $key ); |
| 730 | 533 | |
| 731 | 534 | if ( ! $value ) { |
| 732 | - | |
| 733 | - if ( $default ) { | |
| 734 | - | |
| 535 | + if ( false !== $default ) { | |
| 735 | 536 | $value = $default; |
| 736 | 537 | } else { |
| 737 | - | |
| 738 | 538 | $fields = $this->get_checkout_fields( $post_id ); |
| 739 | 539 | |
| 740 | 540 | if ( isset( $fields[ $key ]['default'] ) ) { |
| 741 | - | |
| 742 | 541 | $value = $fields[ $key ]['default']; |
| 743 | 542 | } |
| 744 | 543 | } |
| 745 | 544 | } |
| 746 | 545 | |
| 747 | - return $value; | |
| 546 | + return apply_filters( "cartflows_checkout_meta_{$key}", $value ); | |
| 748 | 547 | } |
| 749 | 548 | |
| 750 | 549 | /** |
| 751 | 550 | * Get post meta. |
| @@ -753,13 +552,11 @@ | ||
| 753 | 552 | * @param int $post_id post id. |
| 754 | 553 | * @param string $key options key. |
| 755 | 554 | * @return string |
| 756 | 555 | */ |
| 757 | - function get_save_meta( $post_id, $key ) { | |
| 556 | + public function get_save_meta( $post_id, $key ) { | |
| 758 | 557 | |
| 759 | - $value = get_post_meta( $post_id, $key, true ); | |
| 760 | - | |
| 761 | - return $value; | |
| 558 | + return get_post_meta( $post_id, $key, true ); | |
| 762 | 559 | } |
| 763 | 560 | |
| 764 | 561 | /** |
| 765 | 562 | * Thank You Default fields. |
| @@ -766,75 +563,137 @@ | ||
| 766 | 563 | * |
| 767 | 564 | * @param int $post_id post id. |
| 768 | 565 | * @return array |
| 769 | 566 | */ |
| 770 | - function get_thankyou_fields( $post_id ) { | |
| 567 | + public function get_thankyou_fields( $post_id ) { | |
| 771 | 568 | |
| 772 | 569 | if ( null === self::$thankyou_fields ) { |
| 773 | - | |
| 774 | 570 | self::$thankyou_fields = array( |
| 775 | - 'wcf-field-google-font-url' => array( | |
| 571 | + 'wcf-enable-design-settings' => array( | |
| 572 | + 'default' => $this->get_show_design_meta_value(), | |
| 573 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 574 | + ), | |
| 575 | + 'wcf-disable-step' => array( | |
| 576 | + 'default' => 'no', | |
| 577 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 578 | + ), | |
| 579 | + 'wcf-field-google-font-url' => array( | |
| 776 | 580 | 'default' => '', |
| 777 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 581 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 778 | 582 | ), |
| 779 | - 'wcf-active-tab' => array( | |
| 583 | + 'wcf-tq-primary-color' => array( | |
| 780 | 584 | 'default' => '', |
| 781 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 585 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 782 | 586 | ), |
| 783 | - 'wcf-tq-text-color' => array( | |
| 587 | + 'wcf-tq-text-color' => array( | |
| 784 | 588 | 'default' => '', |
| 785 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 589 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 786 | 590 | ), |
| 787 | - 'wcf-tq-font-family' => array( | |
| 591 | + 'wcf-tq-font-family' => array( | |
| 788 | 592 | 'default' => '', |
| 789 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 593 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 790 | 594 | ), |
| 791 | - 'wcf-tq-heading-color' => array( | |
| 595 | + 'wcf-tq-font-size' => array( | |
| 792 | 596 | 'default' => '', |
| 793 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 597 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 794 | 598 | ), |
| 795 | - 'wcf-tq-heading-font-family' => array( | |
| 599 | + 'wcf-tq-heading-color' => array( | |
| 796 | 600 | 'default' => '', |
| 797 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 601 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 798 | 602 | ), |
| 799 | - 'wcf-tq-heading-font-wt' => array( | |
| 603 | + 'wcf-tq-heading-font-family' => array( | |
| 800 | 604 | 'default' => '', |
| 801 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 605 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 802 | 606 | ), |
| 803 | - 'wcf-tq-container-width' => array( | |
| 607 | + 'wcf-tq-heading-font-wt' => array( | |
| 804 | 608 | 'default' => '', |
| 805 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 609 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 806 | 610 | ), |
| 807 | - 'wcf-tq-section-bg-color' => array( | |
| 611 | + 'wcf-tq-container-width' => array( | |
| 808 | 612 | 'default' => '', |
| 809 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 613 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 810 | 614 | ), |
| 811 | - 'wcf-tq-advance-options-fields' => array( | |
| 615 | + 'wcf-tq-section-bg-color' => array( | |
| 812 | 616 | 'default' => '', |
| 813 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 617 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 814 | 618 | ), |
| 815 | - 'wcf-show-overview-section' => array( | |
| 619 | + 'wcf-tq-advance-options-fields' => array( | |
| 620 | + 'default' => '', | |
| 621 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 622 | + ), | |
| 623 | + 'wcf-show-overview-section' => array( | |
| 816 | 624 | 'default' => 'yes', |
| 817 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 625 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 818 | 626 | ), |
| 819 | - 'wcf-show-details-section' => array( | |
| 627 | + 'wcf-show-details-section' => array( | |
| 820 | 628 | 'default' => 'yes', |
| 821 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 629 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 822 | 630 | ), |
| 823 | - 'wcf-show-billing-section' => array( | |
| 631 | + 'wcf-show-billing-section' => array( | |
| 824 | 632 | 'default' => 'yes', |
| 825 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 633 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 826 | 634 | ), |
| 827 | - 'wcf-show-shipping-section' => array( | |
| 635 | + 'wcf-show-shipping-section' => array( | |
| 828 | 636 | 'default' => 'yes', |
| 829 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 637 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 830 | 638 | ), |
| 831 | - 'wcf-custom-script' => array( | |
| 639 | + 'wcf-show-tq-redirect-section' => array( | |
| 832 | 640 | 'default' => '', |
| 833 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 641 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 834 | 642 | ), |
| 643 | + 'wcf-tq-redirect-link' => array( | |
| 644 | + 'default' => '', | |
| 645 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 646 | + ), | |
| 647 | + 'wcf-tq-layout' => array( | |
| 648 | + 'default' => 'legacy-tq-layout', | |
| 649 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 650 | + ), | |
| 651 | + 'wcf-tq-text' => array( | |
| 652 | + 'default' => __( 'Thank you. Your order has been received.', 'cartflows' ), | |
| 653 | + 'sanitize' => 'FILTER_WP_KSES_POST', | |
| 654 | + ), | |
| 655 | + 'wcf-custom-script' => array( | |
| 656 | + 'default' => '', | |
| 657 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 658 | + ), | |
| 659 | + 'wcf-step-custom-js' => array( | |
| 660 | + 'default' => '', | |
| 661 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 662 | + ), | |
| 663 | + 'wcf-step-custom-css' => array( | |
| 664 | + 'default' => '', | |
| 665 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 666 | + ), | |
| 667 | + 'wcf-step-note' => array( | |
| 668 | + 'default' => '', | |
| 669 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 670 | + ), | |
| 671 | + 'wcf-instant-thankyou-order-review-summary-position' => array( | |
| 672 | + 'default' => 'top', | |
| 673 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 674 | + ), | |
| 675 | + 'wcf-instant-thankyou-right-side-bg-color' => array( | |
| 676 | + 'default' => '', | |
| 677 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 678 | + ), | |
| 679 | + 'wcf-instant-thankyou-left-side-bg-color' => array( | |
| 680 | + 'default' => '', | |
| 681 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 682 | + ), | |
| 683 | + 'wcf-tq-button-text-color' => array( | |
| 684 | + 'default' => '', | |
| 685 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 686 | + ), | |
| 687 | + 'wcf-tq-button-background-color' => array( | |
| 688 | + 'default' => '', | |
| 689 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 690 | + ), | |
| 691 | + 'wcf-tq-button-font-family' => array( | |
| 692 | + 'default' => '', | |
| 693 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 694 | + ), | |
| 835 | 695 | ); |
| 836 | - | |
| 837 | 696 | } |
| 838 | 697 | |
| 839 | 698 | return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id ); |
| 840 | 699 | } |
| @@ -846,49 +705,42 @@ | ||
| 846 | 705 | * @param string $key options key. |
| 847 | 706 | * @param mix $default options default value. |
| 848 | 707 | * @return string |
| 849 | 708 | */ |
| 850 | - function get_thankyou_meta_value( $post_id, $key, $default = false ) { | |
| 709 | + public function get_thankyou_meta_value( $post_id, $key, $default = false ) { | |
| 851 | 710 | |
| 852 | 711 | $value = $this->get_save_meta( $post_id, $key ); |
| 853 | 712 | |
| 854 | 713 | if ( ! $value ) { |
| 855 | - | |
| 856 | 714 | if ( $default ) { |
| 857 | - | |
| 858 | 715 | $value = $default; |
| 859 | 716 | } else { |
| 860 | - | |
| 861 | 717 | $fields = $this->get_thankyou_fields( $post_id ); |
| 862 | 718 | |
| 863 | 719 | if ( isset( $fields[ $key ]['default'] ) ) { |
| 864 | - | |
| 865 | 720 | $value = $fields[ $key ]['default']; |
| 866 | 721 | } |
| 867 | 722 | } |
| 868 | 723 | } |
| 869 | 724 | |
| 870 | - return $value; | |
| 725 | + return apply_filters( "cartflows_thankyou_meta_{$key}", $value ); | |
| 871 | 726 | } |
| 872 | 727 | |
| 873 | - /** | |
| 874 | - * Get Landing section meta. | |
| 875 | - * | |
| 876 | - * @param int $post_id post id. | |
| 877 | - * @param string $key options key. | |
| 878 | - * @param mix $default options default value. | |
| 879 | - * @return string | |
| 880 | - */ | |
| 881 | - function get_landing_meta_value( $post_id, $key, $default = false ) { | |
| 728 | + /** | |
| 729 | + * Get Landing section meta. | |
| 730 | + * | |
| 731 | + * @param int $post_id post id. | |
| 732 | + * @param string $key options key. | |
| 733 | + * @param mix $default options default value. | |
| 734 | + * @return string | |
| 735 | + */ | |
| 736 | + public function get_landing_meta_value( $post_id, $key, $default = false ) { | |
| 882 | 737 | |
| 883 | 738 | $value = $this->get_save_meta( $post_id, $key ); |
| 884 | 739 | if ( ! $value ) { |
| 885 | - | |
| 886 | 740 | if ( $default ) { |
| 887 | - | |
| 888 | 741 | $value = $default; |
| 889 | 742 | } else { |
| 890 | - | |
| 891 | 743 | $fields = $this->get_landing_fields( $post_id ); |
| 892 | 744 | |
| 893 | 745 | if ( isset( $fields[ $key ]['default'] ) ) { |
| 894 | 746 | $value = $fields[ $key ]['default']; |
| @@ -899,25 +751,245 @@ | ||
| 899 | 751 | return $value; |
| 900 | 752 | } |
| 901 | 753 | |
| 902 | 754 | /** |
| 903 | - * Thank You Default fields. | |
| 755 | + * Landing Default fields. | |
| 904 | 756 | * |
| 905 | 757 | * @param int $post_id post id. |
| 906 | 758 | * @return array |
| 907 | 759 | */ |
| 908 | - function get_landing_fields( $post_id ) { | |
| 760 | + public function get_landing_fields( $post_id ) { | |
| 909 | 761 | |
| 910 | 762 | if ( null === self::$landing_fields ) { |
| 911 | - | |
| 912 | 763 | self::$landing_fields = array( |
| 913 | - 'wcf-custom-script' => array( | |
| 764 | + 'wcf-disable-step' => array( | |
| 765 | + 'default' => 'no', | |
| 766 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 767 | + ), | |
| 768 | + 'wcf-custom-script' => array( | |
| 914 | 769 | 'default' => '', |
| 915 | - 'sanitize' => 'FILTER_DEFAULT', | |
| 770 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 916 | 771 | ), |
| 772 | + 'wcf-step-custom-js' => array( | |
| 773 | + 'default' => '', | |
| 774 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 775 | + ), | |
| 776 | + 'wcf-step-custom-css' => array( | |
| 777 | + 'default' => '', | |
| 778 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 779 | + ), | |
| 780 | + 'wcf-step-note' => array( | |
| 781 | + 'default' => '', | |
| 782 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 783 | + ), | |
| 917 | 784 | ); |
| 918 | 785 | } |
| 919 | 786 | return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id ); |
| 787 | + } | |
| 788 | + | |
| 789 | + /** | |
| 790 | + * Optin Default fields. | |
| 791 | + * | |
| 792 | + * @param int $post_id post id. | |
| 793 | + * @return array | |
| 794 | + */ | |
| 795 | + public function get_optin_fields( $post_id ) { | |
| 796 | + | |
| 797 | + if ( null === self::$optin_fields ) { | |
| 798 | + self::$optin_fields = array( | |
| 799 | + | |
| 800 | + 'wcf-disable-step' => array( | |
| 801 | + 'default' => 'no', | |
| 802 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 803 | + ), | |
| 804 | + 'wcf-optin-product' => array( | |
| 805 | + 'default' => array(), | |
| 806 | + 'sanitize' => 'FILTER_CARTFLOWS_ARRAY', | |
| 807 | + ), | |
| 808 | + | |
| 809 | + /* Style */ | |
| 810 | + 'wcf-enable-design-settings' => array( | |
| 811 | + 'default' => $this->get_show_design_meta_value(), | |
| 812 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 813 | + ), | |
| 814 | + 'wcf-field-google-font-url' => array( | |
| 815 | + 'default' => '', | |
| 816 | + 'sanitize' => 'FILTER_SANITIZE_URL', | |
| 817 | + ), | |
| 818 | + 'wcf-primary-color' => array( | |
| 819 | + 'default' => '', | |
| 820 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 821 | + ), | |
| 822 | + 'wcf-base-font-family' => array( | |
| 823 | + 'default' => '', | |
| 824 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 825 | + ), | |
| 826 | + 'wcf-input-fields-skins' => array( | |
| 827 | + 'default' => '', | |
| 828 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 829 | + ), | |
| 830 | + 'wcf-input-font-family' => array( | |
| 831 | + 'default' => '', | |
| 832 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 833 | + ), | |
| 834 | + 'wcf-input-font-weight' => array( | |
| 835 | + 'default' => '', | |
| 836 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 837 | + ), | |
| 838 | + 'wcf-input-field-size' => array( | |
| 839 | + 'default' => '33px', | |
| 840 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 841 | + ), | |
| 842 | + 'wcf-field-tb-padding' => array( | |
| 843 | + 'default' => '', | |
| 844 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 845 | + ), | |
| 846 | + 'wcf-field-lr-padding' => array( | |
| 847 | + 'default' => '', | |
| 848 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 849 | + ), | |
| 850 | + 'wcf-field-color' => array( | |
| 851 | + 'default' => '', | |
| 852 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 853 | + ), | |
| 854 | + 'wcf-field-bg-color' => array( | |
| 855 | + 'default' => '', | |
| 856 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 857 | + ), | |
| 858 | + 'wcf-field-border-color' => array( | |
| 859 | + 'default' => '', | |
| 860 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 861 | + ), | |
| 862 | + 'wcf-field-label-color' => array( | |
| 863 | + 'default' => '', | |
| 864 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 865 | + ), | |
| 866 | + 'wcf-submit-button-text' => array( | |
| 867 | + 'default' => __( 'Submit', 'cartflows' ), | |
| 868 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 869 | + ), | |
| 870 | + 'wcf-submit-font-size' => array( | |
| 871 | + 'default' => '', | |
| 872 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 873 | + ), | |
| 874 | + 'wcf-button-font-family' => array( | |
| 875 | + 'default' => '', | |
| 876 | + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY', | |
| 877 | + ), | |
| 878 | + 'wcf-button-font-weight' => array( | |
| 879 | + 'default' => '', | |
| 880 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 881 | + ), | |
| 882 | + 'wcf-submit-button-size' => array( | |
| 883 | + 'default' => '33px', | |
| 884 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 885 | + ), | |
| 886 | + 'wcf-submit-tb-padding' => array( | |
| 887 | + 'default' => '', | |
| 888 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 889 | + ), | |
| 890 | + 'wcf-submit-lr-padding' => array( | |
| 891 | + 'default' => '', | |
| 892 | + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', | |
| 893 | + ), | |
| 894 | + 'wcf-submit-button-position' => array( | |
| 895 | + 'default' => 'center', | |
| 896 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 897 | + ), | |
| 898 | + 'wcf-submit-color' => array( | |
| 899 | + 'default' => '', | |
| 900 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 901 | + ), | |
| 902 | + 'wcf-submit-hover-color' => array( | |
| 903 | + 'default' => '', | |
| 904 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 905 | + ), | |
| 906 | + 'wcf-submit-bg-color' => array( | |
| 907 | + 'default' => '', | |
| 908 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 909 | + ), | |
| 910 | + 'wcf-submit-bg-hover-color' => array( | |
| 911 | + 'default' => '', | |
| 912 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 913 | + ), | |
| 914 | + 'wcf-submit-border-color' => array( | |
| 915 | + 'default' => '', | |
| 916 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 917 | + ), | |
| 918 | + 'wcf-submit-border-hover-color' => array( | |
| 919 | + 'default' => '', | |
| 920 | + 'sanitize' => 'FILTER_SANITIZE_COLOR', | |
| 921 | + ), | |
| 922 | + | |
| 923 | + /* Settings */ | |
| 924 | + 'wcf-optin-pass-fields' => array( | |
| 925 | + 'default' => '', | |
| 926 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 927 | + ), | |
| 928 | + 'wcf-optin-pass-specific-fields' => array( | |
| 929 | + 'default' => 'first_name', | |
| 930 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 931 | + ), | |
| 932 | + | |
| 933 | + /* Script */ | |
| 934 | + 'wcf-custom-script' => array( | |
| 935 | + 'default' => '', | |
| 936 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 937 | + ), | |
| 938 | + 'wcf-step-custom-js' => array( | |
| 939 | + 'default' => '', | |
| 940 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 941 | + ), | |
| 942 | + 'wcf-step-custom-css' => array( | |
| 943 | + 'default' => '', | |
| 944 | + 'sanitize' => 'FILTER_SCRIPT', | |
| 945 | + ), | |
| 946 | + | |
| 947 | + 'wcf-step-note' => array( | |
| 948 | + 'default' => '', | |
| 949 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 950 | + ), | |
| 951 | + | |
| 952 | + /* Custom Fields Options*/ | |
| 953 | + 'wcf-optin-enable-custom-fields' => array( | |
| 954 | + 'default' => 'no', | |
| 955 | + 'sanitize' => 'FILTER_SANITIZE_STRING', | |
| 956 | + ), | |
| 957 | + | |
| 958 | + 'wcf-optin-fields-billing' => array( | |
| 959 | + 'default' => \Cartflows_Helper::get_optin_default_fields(), | |
| 960 | + 'sanitize' => 'FILTER_CARTFLOWS_OPTIN_FIELDS', | |
| 961 | + ), | |
| 962 | + ); | |
| 963 | + } | |
| 964 | + return apply_filters( 'cartflows_optin_meta_options', self::$optin_fields, $post_id ); | |
| 965 | + } | |
| 966 | + | |
| 967 | + /** | |
| 968 | + * Get optin meta. | |
| 969 | + * | |
| 970 | + * @param int $post_id post id. | |
| 971 | + * @param string $key options key. | |
| 972 | + * @param mix $default options default value. | |
| 973 | + * @return string | |
| 974 | + */ | |
| 975 | + public function get_optin_meta_value( $post_id = 0, $key = '', $default = false ) { | |
| 976 | + | |
| 977 | + $value = $this->get_save_meta( $post_id, $key ); | |
| 978 | + | |
| 979 | + if ( ! $value ) { | |
| 980 | + if ( false !== $default ) { | |
| 981 | + $value = $default; | |
| 982 | + } else { | |
| 983 | + $fields = $this->get_optin_fields( $post_id ); | |
| 984 | + | |
| 985 | + if ( isset( $fields[ $key ]['default'] ) ) { | |
| 986 | + $value = $fields[ $key ]['default']; | |
| 987 | + } | |
| 988 | + } | |
| 989 | + } | |
| 990 | + | |
| 991 | + return apply_filters( "cartflows_optin_meta_{$key}", $value ); | |
| 920 | 992 | } |
| 921 | 993 | } |
| 922 | 994 | |
| 923 | 995 | /** |