bws_check_pro_license

The Google Captcha (reCAPTCHA) by BestWebSoft bws check pro license function.

Description

bws_check_pro_license( (string) $plugin_basename, (bool) $trial_plugin = false ); 

Parameters (2)

0. $plugin_basename (string)
The plugin basename.
1. $trial_plugin — Optional. (bool) => false
The trial plugin.

Usage

  1. if ( !function_exists( 'bws_check_pro_license' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-captcha-recaptcha-by-bestwebsoft/bws_menu/deprecated.php'; 
  3.  
  4. // The plugin basename. 
  5. $plugin_basename = ''; 
  6.  
  7. // The trial plugin. 
  8. $trial_plugin = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bws_check_pro_license($plugin_basename, $trial_plugin); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bws_menu/deprecated.php  
  1. function bws_check_pro_license( $plugin_basename, $trial_plugin = false ) { 
  2. global $wp_version, $bstwbsftwppdtplgns_options; 
  3. $result = array(); 
  4.  
  5. if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { 
  6. $license_key = isset( $_POST['bws_license_key'] ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ''; 
  7.  
  8. if ( '' != $license_key ) { 
  9.  
  10. delete_transient( 'bws_plugins_update' ); 
  11.  
  12. if ( ! function_exists( 'get_plugins' ) ) 
  13. require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  14. $plugins_all = get_plugins(); 
  15. $current = get_site_transient( 'update_plugins' ); 
  16.  
  17. if ( is_array( $plugins_all ) && !empty( $plugins_all ) && isset( $current ) && is_array( $current->response ) ) { 
  18. $to_send = array(); 
  19. $to_send["plugins"][ $plugin_basename ] = $plugins_all[ $plugin_basename ]; 
  20. $to_send["plugins"][ $plugin_basename ]["bws_license_key"] = $license_key; 
  21. $to_send["plugins"][ $plugin_basename ]["bws_illegal_client"] = true; 
  22. $options = array( 
  23. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),  
  24. 'body' => array( 'plugins' => serialize( $to_send ) ),  
  25. 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 
  26. ); 
  27. $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); 
  28. if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 
  29. $result[error] = __( 'Something went wrong. Please try again later. If theerrorappears again, please contact us', 'bestwebsoft' ) . ' <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); 
  30. } else { 
  31. $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); 
  32. if ( is_array( $response ) && !empty( $response ) ) { 
  33. foreach ( $response as $key => $value ) { 
  34. if ( "wrong_license_key" == $value->package ) { 
  35. $result[error] = __( 'Wrong license key.', 'bestwebsoft' ); 
  36. } else if ( "wrong_domain" == $value->package ) { 
  37. $result[error] = __( 'This license key is bound to another site.', 'bestwebsoft' ); 
  38. } else if ( "time_out" == $value->package ) { 
  39. $result['message'] = __( 'This license key is valid, but Your license has expired. If you want to update our plugin in future, you should extend the license.', 'bestwebsoft' ); 
  40. } elseif ( "you_are_banned" == $value->package ) { 
  41. $result[error] = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); 
  42. } elseif ( "duplicate_domen_for_trial" == $value->package ) { 
  43. $result[error] = __( "Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); 
  44. if ( empty( $result['message'] ) && empty( $result[error] ) ) { 
  45. if ( isset( $value->trial ) ) 
  46. $result['message'] = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); 
  47. else 
  48. $result['message'] = __( 'The license key is valid.', 'bestwebsoft' ); 
  49.  
  50. if ( ! empty( $value->time_out ) ) 
  51. $result['message'] .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $value->time_out . '.'; 
  52.  
  53. if ( isset( $value->trial ) && $trial_plugin != false ) 
  54. $result['message'] .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="https://bestwebsoft.com/products/wordpress/plugins/' . $trial_plugin['link_slug'] . '/?k=' . $trial_plugin['link_key'] . '&pn=' . $trial_plugin['link_pn'] . '&v=' . $trial_plugin['plugin_info']['Version'] . '&wp_v=' . $wp_version . '" target="_blank" title="' . $trial_plugin['plugin_info']['Name'] . '">Pro</a>' ); 
  55.  
  56. if ( isset( $value->trial ) ) { 
  57. $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] = 1; 
  58. } else { 
  59. unset( $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] ); 
  60. if ( empty( $result[error] ) ) { 
  61. if ( isset( $value->nonprofit ) ) { 
  62. $bstwbsftwppdtplgns_options['nonprofit'][ $plugin_basename ] = 1; 
  63. } else { 
  64. unset( $bstwbsftwppdtplgns_options['nonprofit'][ $plugin_basename ] ); 
  65.  
  66. if ( $bstwbsftwppdtplgns_options[ $plugin_basename ] != $license_key ) { 
  67. $bstwbsftwppdtplgns_options[ $plugin_basename ] = $license_key; 
  68.  
  69. $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt" , "w+" ); 
  70. if ( $file ) { 
  71. @fwrite( $file, $license_key ); 
  72. @fclose( $file ); 
  73. $update_option = true; 
  74.  
  75. if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] ) || $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] != $value->time_out ) { 
  76. $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] = $value->time_out; 
  77. $update_option = true; 
  78.  
  79. if ( isset( $update_option ) ) { 
  80. if ( is_multisite() ) 
  81. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  82. else 
  83. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  84. } else { 
  85. $result[error] = __( 'Something went wrong. Please try again later. If theerrorappears again, please contact us', 'bestwebsoft' ) . ' <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); 
  86. } else { 
  87. $result[error] = __( 'Please, enter your license key', 'bestwebsoft' ); 
  88. return $result;