PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.7.9
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.7.9
2.7.0 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 All 43 releases
sellkit / includes / dynamic-keywords / contact-segmentation / contact-base.php

contact-base.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.7.9, at includes/dynamic-keywords/contact-segmentation/contact-base.php

181 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Dynamic_Keywords\Contact_Segmentation;
4
5 use Sellkit\Contact_Segmentation\Contact_Data;
6 use Sellkit\Database;
7
8 defined( 'ABSPATH' ) || die();
9
10 /**
11 * Contact segmentation base.
12 *
13 * @since 1.1.0
14 */
15 abstract class Contact_Segmentation_Base {
16
17 /**
18 * Contact segmentation data.
19 *
20 * @var object
21 * @since 1.1.0
22 */
23 public static $contact_segmentation = [];
24
25 /**
26 * Cart items.
27 *
28 * @var object
29 * @since 1.1.0
30 */
31 public static $cart_items = [];
32
33 /**
34 * Alert ID.
35 *
36 * @var integer|null
37 * @since 1.2.1
38 */
39 public static $alert_id = null;
40
41 /**
42 * Constructor.
43 *
44 * @since 1.1.0
45 */
46 public function __construct() {
47 if ( ! sellkit()->has_valid_dependencies() ) {
48 return;
49 }
50
51 self::$cart_items = ! empty( WC()->session->cart ) ? WC()->session->cart : '';
52 }
53
54 /**
55 * Get shortcode default data.
56 *
57 * @since 1.1.0
58 */
59 public function get_data() {
60 if ( ! class_exists( 'Sellkit\Contact_Segmentation\Contact_Data' ) ) {
61 return;
62 }
63
64 $contact_data = Contact_Data::get_instance();
65
66 if ( empty( $contact_data->get_data() ) ) {
67 return;
68 }
69
70 $this::$contact_segmentation = $contact_data->get_data();
71
72 return $contact_data->get_data();
73 }
74
75 /**
76 * Get shortcode default data.
77 *
78 * @since 1.1.0
79 * @param array $atts shortcode attributes.
80 */
81 public function shortcode_content( $atts ) {
82 $atts = shortcode_atts( [
83 'fallback' => '',
84 ], $atts );
85
86 return $atts['fallback'];
87 }
88
89 /**
90 * Get shortcode default data.
91 *
92 * @since 1.1.0
93 * @param string $type condition slug.
94 */
95 public function get_content_meta( $type ) {
96 if ( is_admin() ) {
97 return;
98 }
99
100 $this::$alert_id = get_query_var( 'alert_id' );
101
102 $alert_meta = get_post_meta( $this::$alert_id, 'conditions', true );
103
104 if ( empty( $alert_meta ) ) {
105 return;
106 }
107
108 foreach ( $alert_meta as $meta ) {
109 if ( in_array( $type, $meta, true ) ) {
110 return $meta['condition_value'];
111 }
112 }
113
114 return [];
115 }
116
117 /**
118 * Check products and categories count.
119 *
120 * @since 1.1.0
121 * @param array $list array of shortcode result.
122 */
123 public function get_result( $list ) {
124 if ( count( $list ) < 4 ) {
125 return $list;
126 }
127
128 $list = array_slice( $list, 0, 4 );
129 $list_last_item = $list[3];
130
131 array_splice( $list, -1, 2, esc_html__( 'And ', 'sellkit' ) );
132
133 array_push( $list, $list_last_item );
134
135 return $list;
136 }
137
138 /**
139 * Get Keywords type.
140 *
141 * @since 1.1.0
142 */
143 public static function get_keywords_type() {
144 return 'contact_segmentation';
145 }
146
147 /**
148 * Get keyword id.
149 *
150 * @since 1.1.0
151 * @access public
152 * @abstract
153 *
154 * @return string
155 */
156 abstract public function get_id();
157
158 /**
159 * Get keyword title.
160 *
161 * @since 1.1.0
162 * @access public
163 * @abstract
164 *
165 * @return string
166 */
167 abstract public function get_title();
168
169 /**
170 * Render content.
171 *
172 * @since 1.1.0
173 * @access public
174 * @param array $atts array of shortcode arguments.
175 * @abstract
176 *
177 * @return string
178 */
179 abstract public function render_content( $atts );
180 }
181