| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | -namespace PXLBSAdminify\Inc\Classes\Notifications\Base; | |
| 3 | -use PXLBSAdminify\Inc\Classes\Helper; | |
| 2 | +namespace WPAdminify\Inc\Classes\Notifications\Base; | |
| 3 | +use WPAdminify\Inc\Classes\Helper; | |
| 4 | 4 | |
| 5 | 5 | // No, Direct access Sir !!! |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 7 | exit; |
| @@ -170,12 +170,33 @@ | ||
| 170 | 170 | ) { |
| 171 | 171 | $is_local = true; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - return apply_filters( 'pxlbsadminify_is_local', $is_local ); | |
| 174 | + return apply_filters( 'jltwp_adminify_is_local', $is_local ); | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | + * Get IP Address | |
| 179 | + * | |
| 180 | + * @author Jewel Theme <support@jeweltheme.com> | |
| 181 | + */ | |
| 182 | + public function get_user_ip_address() { | |
| 183 | + $response = wp_remote_get( 'https://icanhazip.com/' ); | |
| 184 | + | |
| 185 | + if ( is_wp_error( $response ) ) { | |
| 186 | + return ''; | |
| 187 | + } | |
| 188 | + | |
| 189 | + $ip_address = trim( wp_remote_retrieve_body( $response ) ); | |
| 190 | + | |
| 191 | + if ( ! filter_var( $ip_address, FILTER_VALIDATE_IP ) ) { | |
| 192 | + return ''; | |
| 193 | + } | |
| 194 | + | |
| 195 | + return $ip_address; | |
| 196 | + } | |
| 197 | + | |
| 198 | + /** | |
| 178 | 199 | * Get Collection Data |
| 179 | 200 | * |
| 180 | 201 | * @return void |
| 181 | 202 | * @author Jewel Theme <support@jeweltheme.com> |
| @@ -181,25 +202,55 @@ | ||
| 181 | 202 | * @author Jewel Theme <support@jeweltheme.com> |
| 182 | 203 | */ |
| 183 | 204 | public function get_collect_data( $user_id, $arr = [] ){ |
| 184 | 205 | |
| 206 | + $billing_phone = ''; | |
| 207 | + $billing_company = ''; | |
| 208 | + $billing_address_1 = ''; | |
| 209 | + $billing_address_2 = ''; | |
| 210 | + $billing_city = ''; | |
| 211 | + $billing_postcode = ''; | |
| 212 | + $billing_country = ''; | |
| 213 | + $billing_state = ''; | |
| 214 | + | |
| 215 | + // WooCommerce . | |
| 216 | + if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { | |
| 217 | + $billing_phone = get_user_meta( $user_id, 'billing_phone', true ); | |
| 218 | + $billing_company = get_user_meta( $user_id, 'billing_company', true ); | |
| 219 | + $billing_address_1 = get_user_meta( $user_id, 'billing_address_1', true ); | |
| 220 | + $billing_address_2 = get_user_meta( $user_id, 'billing_address_2', true ); | |
| 221 | + $billing_city = get_user_meta( $user_id, 'billing_city', true ); | |
| 222 | + $billing_postcode = get_user_meta( $user_id, 'billing_postcode', true ); | |
| 223 | + $billing_country = get_user_meta( $user_id, 'billing_country', true ); | |
| 224 | + $billing_state = get_user_meta( $user_id, 'billing_state', true ); | |
| 225 | + } | |
| 226 | + | |
| 185 | 227 | $all_plugins = $this->get_plugins_list(); |
| 186 | 228 | $active_deactivate_plugins = $all_plugins['active_plugins'] . $all_plugins['deactivated_plugins']; |
| 187 | 229 | |
| 188 | 230 | $data = array( |
| 231 | + 'phone' => $billing_phone, | |
| 232 | + 'company' => $billing_company, | |
| 233 | + 'address_1' => $billing_address_1, | |
| 234 | + 'address_2' => $billing_address_2, | |
| 235 | + 'city' => $billing_city, | |
| 236 | + 'postcode' => $billing_postcode, | |
| 237 | + 'country' => $billing_country, | |
| 238 | + 'state' => $billing_state, | |
| 239 | + 'list_id' => [3, 23], | |
| 240 | + 'tag_id' => [103, 40, 45], | |
| 189 | 241 | 'server' => $this->get_server_info(), |
| 190 | 242 | 'wp' => $this->get_wp_info(), |
| 243 | + 'number_of_users' => $this->get_user_counts(), | |
| 191 | 244 | 'site_language' => \get_bloginfo( 'language' ), |
| 192 | 245 | 'active_inactive_plugins' => $active_deactivate_plugins, |
| 193 | 246 | 'site_name' => $this->get_site_name(), |
| 194 | - 'site_source' => 'https://wpadminify.com', | |
| 247 | + 'site_source' => 'https://jeweltheme.com', | |
| 195 | 248 | 'is_local' => $this->is_local_server(), |
| 196 | - 'ip_address' => '', | |
| 197 | - 'site_url' => \get_site_url(), // custom field end / need to be create this in . | |
| 198 | - 'is_active_product' => 1, | |
| 199 | - 'list_id' => [3, 23], | |
| 200 | - 'tag_id' => [103, 40, 45], | |
| 201 | - 'installed_product_slug' => PXLBSADMINIFY_SLUG, | |
| 249 | + 'ip_address' => $this->get_user_ip_address(), | |
| 250 | + 'site_url' => \get_site_url(), // custom field end / need to be create this in . | |
| 251 | + 'is_active_product' => 1, | |
| 252 | + 'installed_product_slug' => WP_ADMINIFY_SLUG, | |
| 202 | 253 | ); |
| 203 | 254 | |
| 204 | 255 | $payload_data = array_merge( $arr, $data ); |
| 205 | 256 | $endpoint_url = Helper::crm_endpoint(); |
| @@ -206,9 +257,9 @@ | ||
| 206 | 257 | if ( 'local' === wp_get_environment_type() ) { |
| 207 | 258 | $response = wp_remote_post( |
| 208 | 259 | $endpoint_url, |
| 209 | 260 | array( |
| 210 | - 'body' => json_encode( $payload_data ), | |
| 261 | + 'body' => $payload_data, | |
| 211 | 262 | 'timeout' => 100, |
| 212 | 263 | 'sslverify' => false, |
| 213 | 264 | ) |
| 214 | 265 | ); |
| @@ -216,9 +267,9 @@ | ||
| 216 | 267 | // 'production' === wp_get_environment_type() . |
| 217 | 268 | $response = wp_safe_remote_post( |
| 218 | 269 | $endpoint_url, |
| 219 | 270 | array( |
| 220 | - 'body' => json_encode( $payload_data ), | |
| 271 | + 'body' => $payload_data, | |
| 221 | 272 | 'timeout' => 100, |
| 222 | 273 | ) |
| 223 | 274 | ); |
| 224 | 275 | } |
| @@ -224,5 +275,5 @@ | ||
| 224 | 275 | } |
| 225 | 276 | |
| 226 | 277 | return $response; |
| 227 | 278 | } |
| 228 | -} | |
| 279 | +} | |