PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.2.3
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.2.3
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 / contact-segmentation / operators.php

operators.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.2.3, at includes/contact-segmentation/operators.php

88 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Contact_Segmentation;
4
5 defined( 'ABSPATH' ) || die();
6
7 /**
8 * Class Contact_Segmentation
9 *
10 * @package Sellkit\Contact_Segmentation
11 * @since 1.1.0
12 */
13 class Operators {
14
15 /**
16 * Operator names.
17 *
18 * @var array
19 * @since 1.1.0
20 */
21 public static $names = [];
22
23 /**
24 * Operator names.
25 *
26 * @var array
27 * @since 1.1.0
28 */
29 public static $condition_operator_names = [];
30
31 /**
32 * Operator names.
33 *
34 * @var array
35 * @since 1.1.0
36 */
37 public static $operators = [];
38
39 /**
40 * Conditions constructor.
41 *
42 * @since 1.1.0
43 */
44 public function __construct() {
45 $this->load_operators();
46 }
47
48 /**
49 * Loads all of the conditions.
50 *
51 * @since 1.1.0
52 */
53 public function load_operators() {
54 sellkit()->load_files( [
55 'contact-segmentation/operators/operator-base',
56 ] );
57
58 $path = trailingslashit( sellkit()->plugin_dir() . 'includes/contact-segmentation/operators' );
59 $file_paths = glob( $path . '*.php' );
60
61 foreach ( $file_paths as $file_path ) {
62 if ( ! file_exists( $file_path ) ) {
63 continue;
64 }
65
66 require_once $file_path;
67
68 $file_name = str_replace( '.php', '', basename( $file_path ) );
69 $operator_class = str_replace( '-', ' ', $file_name );
70 $operator_class = str_replace( ' ', '_', ucwords( $operator_class ) );
71 $operator_class = "Sellkit\Contact_Segmentation\Operators\\{$operator_class}";
72
73 if ( ! class_exists( $operator_class ) || 'operator-base' === $file_name ) {
74 continue;
75 }
76
77 $operator = new $operator_class();
78
79 $new_conditions = array_fill_keys( $operator->get_conditions(), $operator->get_name() );
80 self::$condition_operator_names = array_merge_recursive( self::$condition_operator_names, $new_conditions );
81 self::$names[ $operator->get_name() ] = $operator->get_title();
82 self::$operators[ $operator->get_name() ] = $operator;
83 }
84 }
85 }
86
87 new Operators();
88