| @@ -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 | /** |
| @@ -107,5 +112,27 @@ | ||
| 107 | 112 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 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; | |
| 111 | 138 | } |