PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / trunk
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster vtrunk
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / settings / class.php

class.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster trunk, at includes/settings/class.php

101 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Settings;
4
5 defined( 'ABSPATH' ) || exit;
6 /**
7 * Sellkit settings.
8 *
9 * @since 1.1.0
10 */
11 class Sellkit_Settings {
12 /**
13 * The class instance.
14 *
15 * @var Object Class instance.
16 * @since 1.1.0
17 */
18 public static $instance = null;
19
20 /**
21 * Class Instance.
22 *
23 * @since 1.1.0
24 * @return Sellkit_Settings|null
25 */
26 public static function get_instance() {
27 if ( null === self::$instance ) {
28 self::$instance = new self();
29 }
30
31 return self::$instance;
32 }
33
34 /**
35 * Class construct.
36 *
37 * @since 1.1.0
38 */
39 public function __construct() {
40 add_action( 'wp', [ $this, 'apply_sellkit_cart_settings' ] );
41 }
42
43 /**
44 * Apply sellkit cart settings in frontend.
45 *
46 * @since 1.1.0
47 * @return void
48 */
49 public function apply_sellkit_cart_settings() {
50 $options = get_option( 'sellkit', [] );
51
52 if ( is_admin() || ! function_exists( 'WC' ) || ! is_cart() ) {
53 return;
54 }
55
56 // Escape default woocommerce cart page.
57 if ( array_key_exists( 'skip_cart_page', $options ) && '1' === $options['skip_cart_page'] ) {
58 if ( WC()->cart->cart_contents_count > 0 ) {
59 echo esc_url( wc_get_checkout_url() );
60 wp_safe_redirect( wc_get_checkout_url() );
61 exit();
62 }
63 }
64
65 // Set default woocommerce empty cart page template.
66 if (
67 empty( $options['empty_cart_template'] )
68 || empty( $options['empty_cart_template'][0] )
69 || ! defined( 'ELEMENTOR_VERSION' )
70 || WC()->cart->cart_contents_count > 0
71 ) {
72 return;
73 }
74
75 $template_id = $options['empty_cart_template'][0];
76
77 if ( (int) $template_id <= 0 ) {
78 return;
79 }
80
81 add_action( 'template_redirect', function() {
82 jupiterx_add_filter( 'jupiterx_layout', 'c' );
83
84 sellkit()->load_files( [
85 'templates/canvas',
86 ] );
87
88 exit;
89 }, 5 );
90
91 add_filter( 'the_content', function() use ( $template_id ) {
92 ob_start();
93 $content = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( (int) $template_id, true );
94 echo do_shortcode( $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor template HTML; wp_kses_post strips required style/script.
95 return ob_get_clean();
96 } );
97 }
98 }
99
100 Sellkit_Settings::get_instance();
101