| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | +defined( 'ABSPATH' ) || exit; | |
| 2 | 3 | |
| 3 | 4 | use Sellkit\Contact_Segmentation\Conditions; |
| 4 | 5 | |
| 5 | 6 | /** |
| @@ -12,8 +13,12 @@ | ||
| 12 | 13 | */ |
| 13 | 14 | function sellkit_condition_match( $condition_name, $operator_name, $condition_value ) { |
| 14 | 15 | $condition_value = apply_filters( "sellkit_cs_conditions_value_{$condition_name}", $condition_value ); |
| 15 | 16 | |
| 17 | + if ( ! class_exists( 'Conditions' ) ) { | |
| 18 | + require_once __DIR__ . '/conditions.php'; | |
| 19 | + new Conditions(); | |
| 20 | + } | |
| 16 | 21 | return Conditions::match( $condition_name, $operator_name, $condition_value ); |
| 17 | 22 | } |
| 18 | 23 | |
| 19 | 24 | /** |
| @@ -22,8 +27,12 @@ | ||
| 22 | 27 | * @since 1.1.0 |
| 23 | 28 | * @param string $input_value The input value for searching. |
| 24 | 29 | */ |
| 25 | 30 | function sellkit_get_products( $input_value ) { |
| 31 | + if ( ! sellkit()->has_valid_dependencies() ) { | |
| 32 | + return []; | |
| 33 | + } | |
| 34 | + | |
| 26 | 35 | $filtered_products = []; |
| 27 | 36 | $args = [ |
| 28 | 37 | 'post_type' => 'product', |
| 29 | 38 | 'post_status' => 'any', |
| @@ -49,8 +58,12 @@ | ||
| 49 | 58 | * @param string $taxonomy The taxonomy. |
| 50 | 59 | * @param string $input_value The input value. |
| 51 | 60 | */ |
| 52 | 61 | function sellkit_get_terms( $taxonomy, $input_value ) { |
| 62 | + if ( ! sellkit()->has_valid_dependencies() ) { | |
| 63 | + return []; | |
| 64 | + } | |
| 65 | + | |
| 53 | 66 | $filtered_terms = []; |
| 54 | 67 | |
| 55 | 68 | $args = array( |
| 56 | 69 | 'taxonomy' => $taxonomy, |
| @@ -99,5 +112,27 @@ | ||
| 99 | 112 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 100 | 113 | } |
| 101 | 114 | |
| 102 | 115 | return $_SERVER['REMOTE_ADDR']; |
| 116 | +} | |
| 117 | + | |
| 118 | +/** | |
| 119 | + * Gets contact's column value. | |
| 120 | + * | |
| 121 | + * @since 1.5.0 | |
| 122 | + * @param string $column Column name. | |
| 123 | + * @return mixed|string|void | |
| 124 | + */ | |
| 125 | +function sellkit_get_funnel_contact_value_by_column( $column ) { | |
| 126 | + $results = []; | |
| 127 | + $contacts = sellkit()->db->get( 'funnel_contact', [ | |
| 128 | + 'user_id' => get_current_user_id() | |
| 129 | + ] ); | |
| 130 | + | |
| 131 | + foreach ( $contacts as $contact ) { | |
| 132 | + if ( ! empty( $contact[ $column ] ) ) { | |
| 133 | + $results[] = unserialize( $contact[ $column ] )[0]; // phpcs:ignore | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + return $results; | |
| 103 | 138 | } |