Changeset 3158630
- Timestamp:
- 09/27/2024 09:16:49 AM (18 months ago)
- File:
-
- 1 edited
-
wpscreens/trunk/admin/class-wp-screens-admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wpscreens/trunk/admin/class-wp-screens-admin.php
r3156150 r3158630 258 258 259 259 } 260 public function wpscrn_check_if_wpscreens_licence_addon_is_active() 261 { 262 260 public function wpscrn_check_if_wpscreens_licence_addon_is_active() { 261 // Get the license from options 263 262 $wpscreens_licence = get_option('wpscreen_addon_licence'); 264 263 264 // Extracting type from the license 265 265 $type = explode('-', esc_html($wpscreens_licence)); 266 266 267 267 if ('Ad' === $type[0] || 'AD' === $type[0]) { 268 //define('WPSCRN_AD_PRODUCT_ID', 'WPS-ADDON-20');269 268 $licence_val = 3; 270 } 271 272 273 274 269 } else { 270 // You might want to handle other types here 271 $licence_val = 0; // Default value if not 'Ad' 272 } 273 274 // Determine the protocol (http or https) 275 275 $protocol = ('off' !== !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] || 443 == $_SERVER['SERVER_PORT']) ? 'https://' : 'http://'; 276 276 define('WPSCRN_SL_INSTANCE', str_replace($protocol, '', get_bloginfo('wpurl'))); 277 278 // $args = array( 279 // 'woo_sl_action' => 'status-check', 280 // 'licence_key' => $wpscreens_licence, 281 // 'product_unique_id' => 'WPS-ADDON-20', 282 // 'domain' => WPSCRN_SL_INSTANCE, 283 // ); 284 $request_uri = "https://wpscreens.com/?woo_sl_action=activate&licence_key=" . $wpscreens_licence . "&product_unique_id=WPS-ADDON-20&domain=" . str_replace($protocol, '', get_bloginfo('wpurl'));; 277 278 // Prepare the request URI 279 $request_uri = "https://wpscreens.com/?woo_sl_action=activate&licence_key=" . $wpscreens_licence . "&product_unique_id=WPS-ADDON-20&domain=" . str_replace($protocol, '', get_bloginfo('wpurl')); 280 281 // Make the remote request 285 282 $data = wp_remote_get($request_uri); 286 283 284 // Check for errors in the request 285 if (is_wp_error($data)) { 286 // Log the error message 287 error_log('WP Remote Get Error: ' . $data->get_error_message()); 288 return; // Exit the function on error 289 } 290 291 // Decode the response body 287 292 $data_body = json_decode($data['body']); 288 293 294 // Check the response for status 289 295 if (isset($data_body[0]->status)) { 290 291 if (('success' == $data_body[0]->status)) {296 if ('success' == $data_body[0]->status) { 297 // License is valid 292 298 update_option('wpscreens_valid_licence_addon', $licence_val); 293 299 update_option('wpscreens_valid_licence_message_addon', $data_body[0]->message); 294 300 } else { 301 // License is not valid 295 302 update_option('wpscreens_valid_licence_addon', '0'); 296 303 update_option('wpscreens_valid_licence_message_addon', $data_body[0]->message); 297 304 } 298 305 } else { 299 } 300 } 306 // Handle cases where status is not set 307 error_log('Invalid response structure: ' . print_r($data_body, true)); 308 } 309 } 310 301 311 public function wpscrn_check_if_wpscreens_licence_is_active() 302 312 {
Note: See TracChangeset
for help on using the changeset viewer.