/bws_menu/deprecated.php

  1. <?php 
  2. /** 
  3. * Deprecated functions for BestWebSoft plugins 
  4. */ 
  5.  
  6. /** 
  7. * Function check if plugin is compatible with current WP version - for old plugin version 
  8. * @deprecated 1.7.4 
  9. * @todo Remove function after 01.01.2018 
  10. */ 
  11. if ( ! function_exists( 'bws_wp_version_check' ) ) { 
  12. function bws_wp_version_check( $plugin_basename, $plugin_info, $require_wp ) { 
  13. global $bstwbsftwppdtplgns_options; 
  14. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  15. $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  16. if ( ! isset( $bstwbsftwppdtplgns_options['deprecated_function']['bws_wp_version_check'] ) ) { 
  17. $bstwbsftwppdtplgns_options['deprecated_function']['bws_wp_version_check'] = array( 
  18. 'product-name' => $plugin_info['Name'] 
  19. ); 
  20. if ( is_multisite() ) 
  21. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  22. else 
  23. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  24. /** 
  25. * Function add BWS Plugins page - for old plugin version 
  26. * @deprecated 1.7.9 
  27. * @todo Remove function after 01.01.2018 
  28. */ 
  29. if ( ! function_exists( 'bws_add_general_menu' ) ) { 
  30. function bws_add_general_menu() { 
  31. global $bstwbsftwppdtplgns_options; 
  32. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  33. $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  34. if ( ! isset( $bstwbsftwppdtplgns_options['deprecated_function']['bws_add_general_menu'] ) ) { 
  35. $get_debug_backtrace = debug_backtrace(); 
  36. $file = ( ! empty( $get_debug_backtrace[0]['file'] ) ) ? $get_debug_backtrace[0]['file'] : ''; 
  37. $bstwbsftwppdtplgns_options['deprecated_function']['bws_add_general_menu'] = array( 
  38. 'file' => $file 
  39. ); 
  40. if ( is_multisite() ) 
  41. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  42. else 
  43. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  44. /** 
  45. * Function display GO PRO tab - for old plugin version 
  46. * @deprecated 1.7.6 
  47. * @todo Remove function after 01.01.2018 
  48. */ 
  49. if ( ! function_exists( 'bws_go_pro_tab' ) ) { 
  50. function bws_go_pro_tab( $plugin_info, $plugin_basename, $page, $pro_page, $bws_license_plugin, $link_slug, $link_key, $link_pn, $pro_plugin_is_activated = false, $trial_days_number = false ) { 
  51. global $bstwbsftwppdtplgns_options; 
  52. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  53. $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  54. if ( ! isset( $bstwbsftwppdtplgns_options['deprecated_function']['bws_go_pro_tab'] ) ) { 
  55. $bstwbsftwppdtplgns_options['deprecated_function']['bws_go_pro_tab'] = array( 
  56. 'product-name' => $plugin_info['Name'] 
  57. ); 
  58. if ( is_multisite() ) 
  59. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  60. else 
  61. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  62. /** 
  63. * Function add BWS Plugins page 
  64. * @deprecated 1.9.8 (15.12.2016) 
  65. * @return void 
  66. */ 
  67. if ( ! function_exists ( 'bws_general_menu' ) ) { 
  68. function bws_general_menu() { 
  69. global $menu, $bws_general_menu_exist; 
  70.  
  71. if ( ! $bws_general_menu_exist ) { 
  72. /** we check also menu exist in global array as in old plugins $bws_general_menu_exist variable not exist */ 
  73. foreach ( $menu as $value_menu ) { 
  74. if ( 'bws_panel' == $value_menu[2] ) { 
  75. $bws_general_menu_exist = true; 
  76. return; 
  77.  
  78. add_menu_page( 'BWS Panel', 'BWS Panel', 'manage_options', 'bws_panel', 'bws_add_menu_render', 'none', '1001' ); 
  79.  
  80. add_submenu_page( 'bws_panel', __( 'Plugins', 'bestwebsoft' ), __( 'Plugins', 'bestwebsoft' ), 'manage_options', 'bws_panel', 'bws_add_menu_render' ); 
  81. add_submenu_page( 'bws_panel', __( 'Themes', 'bestwebsoft' ), __( 'Themes', 'bestwebsoft' ), 'manage_options', 'bws_themes', 'bws_add_menu_render' ); 
  82. add_submenu_page( 'bws_panel', __( 'System Status', 'bestwebsoft' ), __( 'System Status', 'bestwebsoft' ), 'manage_options', 'bws_system_status', 'bws_add_menu_render' ); 
  83.  
  84. $bws_general_menu_exist = true; 
  85. /** 
  86. * Function check license key for Pro plugins version 
  87. * @deprecated 1.9.8 (15.12.2016) 
  88. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  89. */ 
  90. if ( ! function_exists( 'bws_check_pro_license' ) ) { 
  91. function bws_check_pro_license( $plugin_basename, $trial_plugin = false ) { 
  92. global $wp_version, $bstwbsftwppdtplgns_options; 
  93. $result = array(); 
  94.  
  95. if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { 
  96. $license_key = isset( $_POST['bws_license_key'] ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ''; 
  97.  
  98. if ( '' != $license_key ) { 
  99.  
  100. delete_transient( 'bws_plugins_update' ); 
  101.  
  102. if ( ! function_exists( 'get_plugins' ) ) 
  103. require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  104. $plugins_all = get_plugins(); 
  105. $current = get_site_transient( 'update_plugins' ); 
  106.  
  107. if ( is_array( $plugins_all ) && !empty( $plugins_all ) && isset( $current ) && is_array( $current->response ) ) { 
  108. $to_send = array(); 
  109. $to_send["plugins"][ $plugin_basename ] = $plugins_all[ $plugin_basename ]; 
  110. $to_send["plugins"][ $plugin_basename ]["bws_license_key"] = $license_key; 
  111. $to_send["plugins"][ $plugin_basename ]["bws_illegal_client"] = true; 
  112. $options = array( 
  113. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),  
  114. 'body' => array( 'plugins' => serialize( $to_send ) ),  
  115. 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 
  116. ); 
  117. $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); 
  118. if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 
  119. $result['error'] = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ' <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); 
  120. } else { 
  121. $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); 
  122. if ( is_array( $response ) && !empty( $response ) ) { 
  123. foreach ( $response as $key => $value ) { 
  124. if ( "wrong_license_key" == $value->package ) { 
  125. $result['error'] = __( 'Wrong license key.', 'bestwebsoft' ); 
  126. } else if ( "wrong_domain" == $value->package ) { 
  127. $result['error'] = __( 'This license key is bound to another site.', 'bestwebsoft' ); 
  128. } else if ( "time_out" == $value->package ) { 
  129. $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' ); 
  130. } elseif ( "you_are_banned" == $value->package ) { 
  131. $result['error'] = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); 
  132. } elseif ( "duplicate_domen_for_trial" == $value->package ) { 
  133. $result['error'] = __( "Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); 
  134. if ( empty( $result['message'] ) && empty( $result['error'] ) ) { 
  135. if ( isset( $value->trial ) ) 
  136. $result['message'] = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); 
  137. else 
  138. $result['message'] = __( 'The license key is valid.', 'bestwebsoft' ); 
  139.  
  140. if ( ! empty( $value->time_out ) ) 
  141. $result['message'] .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $value->time_out . '.'; 
  142.  
  143. if ( isset( $value->trial ) && $trial_plugin != false ) 
  144. $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>' ); 
  145.  
  146. if ( isset( $value->trial ) ) { 
  147. $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] = 1; 
  148. } else { 
  149. unset( $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] ); 
  150. if ( empty( $result['error'] ) ) { 
  151. if ( isset( $value->nonprofit ) ) { 
  152. $bstwbsftwppdtplgns_options['nonprofit'][ $plugin_basename ] = 1; 
  153. } else { 
  154. unset( $bstwbsftwppdtplgns_options['nonprofit'][ $plugin_basename ] ); 
  155.  
  156. if ( $bstwbsftwppdtplgns_options[ $plugin_basename ] != $license_key ) { 
  157. $bstwbsftwppdtplgns_options[ $plugin_basename ] = $license_key; 
  158.  
  159. $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt" , "w+" ); 
  160. if ( $file ) { 
  161. @fwrite( $file, $license_key ); 
  162. @fclose( $file ); 
  163. $update_option = true; 
  164.  
  165. if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] ) || $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] != $value->time_out ) { 
  166. $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] = $value->time_out; 
  167. $update_option = true; 
  168.  
  169. if ( isset( $update_option ) ) { 
  170. if ( is_multisite() ) 
  171. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  172. else 
  173. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  174. } else { 
  175. $result['error'] = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ' <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); 
  176. } else { 
  177. $result['error'] = __( 'Please, enter your license key', 'bestwebsoft' ); 
  178. return $result; 
  179.  
  180.  
  181. /** 
  182. * Function display block for checking license key for Pro plugins version 
  183. * @deprecated 1.9.8 (15.12.2016) 
  184. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  185. */ 
  186. if ( ! function_exists ( 'bws_check_pro_license_form' ) ) { 
  187. function bws_check_pro_license_form( $plugin_basename ) { 
  188. global $bstwbsftwppdtplgns_options; 
  189. $license_key = ( isset( $bstwbsftwppdtplgns_options[ $plugin_basename ] ) ) ? $bstwbsftwppdtplgns_options[ $plugin_basename ] : ''; ?> 
  190. <div class="clear"></div> 
  191. <form method="post" action=""> 
  192. <p><?php echo _e( 'If necessary, you can check if the license key is correct or reenter it in the field below. You can find your license key on your personal page - Client Area - on our website', 'bestwebsoft' ) . ' <a href="https://bestwebsoft.com/client-area">https://bestwebsoft.com/client-area</a> ' . __( '(your username is the email address specified during the purchase). If necessary, please submit "Lost your password?" request.', 'bestwebsoft' ); ?></p> 
  193. <p> 
  194. <input type="text" maxlength="100" name="bws_license_key" value="<?php echo $license_key; ?>" /> 
  195. <input type="hidden" name="bws_license_submit" value="submit" /> 
  196. <input type="submit" class="button" value="<?php _e( 'Check license key', 'bestwebsoft' ) ?>" /> 
  197. <?php wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> 
  198. </p> 
  199. </form> 
  200. <?php } 
  201.  
  202. /** 
  203. * Function process submit on the `Go Pro` tab for TRIAL 
  204. * @deprecated 1.9.8 (15.12.2016) 
  205. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  206. */ 
  207. if ( ! function_exists( 'bws_go_pro_from_trial_tab' ) ) { 
  208. function bws_go_pro_from_trial_tab( $plugin_info, $plugin_basename, $page, $link_slug, $link_key, $link_pn, $trial_license_is_set = true ) { 
  209. global $wp_version, $bstwbsftwppdtplgns_options; 
  210. $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; 
  211. if ( $trial_license_is_set ) { ?> 
  212. <form method="post" action=""> 
  213. <p> 
  214. <?php echo 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/' . $link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info["Version"] . '&wp_v=' . $wp_version .'" target="_blank" title="' . $plugin_info["Name"] . '">Pro</a>' ) . ' '; 
  215. _e( 'After that, you can activate it by entering your license key.', 'bestwebsoft' ); ?><br /> 
  216. <span class="bws_info"> 
  217. <?php _e( 'License key can be found in the', 'bestwebsoft' ); ?> 
  218. <a href="https://bestwebsoft.com/wp-login.php">Client Area</a> 
  219. <?php _e( '(your username is the email address specified during the purchase).', 'bestwebsoft' ); ?> 
  220. </span> 
  221. </p> 
  222. <?php if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['count'] ) && 
  223. '5' < $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['count'] && 
  224. $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { ?> 
  225. <p> 
  226. <input disabled="disabled" type="text" name="bws_license_key" value="" /> 
  227. <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> 
  228. </p> 
  229. <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day.", 'bestwebsoft' ); ?></p> 
  230. <?php } else { ?> 
  231. <p> 
  232. <input type="text" maxlength="100" name="bws_license_key" value="" /> 
  233. <input type="hidden" name="bws_license_plugin" value="<?php echo $plugin_basename; ?>" /> 
  234. <input type="hidden" name="bws_license_submit" value="submit" /> 
  235. <input type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> 
  236. <?php wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> 
  237. </p> 
  238. <?php } ?> 
  239. </form> 
  240. <?php } else { ?> 
  241. <script type="text/javascript"> 
  242. window.setTimeout( function() { 
  243. window.location.href = 'admin.php?page=<?php echo $page; ?>'; 
  244. }, 5000 ); 
  245. </script> 
  246. <p><?php _e( "Congratulations! The Pro license of the plugin is activated successfully.", 'bestwebsoft' ); ?></p> 
  247. <p> 
  248. <?php _e( "Please, go to", 'bestwebsoft' ); ?> <a href="admin.php?page=<?php echo $page; ?>"><?php _e( 'the setting page', 'bestwebsoft' ); ?></a> 
  249. (<?php _e( "You will be redirected automatically in 5 seconds.", 'bestwebsoft' ); ?>) 
  250. </p> 
  251. <?php } 
  252.  
  253. /** 
  254. * Function process submit on the `Go Pro` tab 
  255. * @deprecated 1.9.8 (15.12.2016) 
  256. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  257. */ 
  258. if ( ! function_exists( 'bws_go_pro_tab_check' ) ) { 
  259. function bws_go_pro_tab_check( $plugin_basename, $plugin_options_name = false, $is_network_option = false ) { 
  260. global $wp_version, $bstwbsftwppdtplgns_options; 
  261. $result = array(); 
  262.  
  263. $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; 
  264.  
  265. if ( ! empty( $plugin_options_name ) && isset( $_POST['bws_hide_premium_options_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { 
  266.  
  267. $plugin_options = ( $is_network_option ) ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); 
  268.  
  269. if ( !empty( $plugin_options['hide_premium_options'] ) ) { 
  270.  
  271. $key = array_search( get_current_user_id(), $plugin_options['hide_premium_options'] ); 
  272. if ( false !== $key ) { 
  273. unset( $plugin_options['hide_premium_options'][ $key ] ); 
  274.  
  275. if ( $is_network_option ) 
  276. update_site_option( $plugin_options_name, $plugin_options ); 
  277. else 
  278. update_option( $plugin_options_name, $plugin_options ); 
  279.  
  280. $result['message'] = __( 'Check premium options on the plugin settings page!', 'bestwebsoft' ); 
  281.  
  282. if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { 
  283. if ( '' != $bws_license_key ) { 
  284. if ( strlen( $bws_license_key ) != 18 ) { 
  285. $result['error'] = __( "Wrong license key", 'bestwebsoft' ); 
  286. } else { 
  287. $bws_license_plugin = stripslashes( esc_html( $_POST['bws_license_plugin'] ) ); 
  288. if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - (24 * 60 * 60) ) ) { 
  289. $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; 
  290. } else { 
  291. $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; 
  292. $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); 
  293.  
  294. /** download Pro */ 
  295. if ( ! function_exists( 'get_plugins' ) ) 
  296. require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  297.  
  298. $all_plugins = get_plugins(); 
  299.  
  300. if ( ! array_key_exists( $bws_license_plugin, $all_plugins ) ) { 
  301. $current = get_site_transient( 'update_plugins' ); 
  302. if ( is_array( $all_plugins ) && !empty( $all_plugins ) && isset( $current ) && is_array( $current->response ) ) { 
  303. $to_send = array(); 
  304. $to_send["plugins"][ $bws_license_plugin ] = array(); 
  305. $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key; 
  306. $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true; 
  307. $options = array( 
  308. 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ),  
  309. 'body' => array( 'plugins' => serialize( $to_send ) ),  
  310. 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); 
  311. $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); 
  312.  
  313. if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { 
  314. $result['error'] = __( "Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft' ) . ' <a href="https://support.bestwebsoft.com">BestWebSoft</a>. ' . __( "We are sorry for inconvenience.", 'bestwebsoft' ); 
  315. } else { 
  316. $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); 
  317. if ( is_array( $response ) && !empty( $response ) ) { 
  318. foreach ( $response as $key => $value ) { 
  319. if ( "wrong_license_key" == $value->package ) { 
  320. $result['error'] = __( "Wrong license key.", 'bestwebsoft' ); 
  321. } elseif ( "wrong_domain" == $value->package ) { 
  322. $result['error'] = __( "This license key is bound to another site.", 'bestwebsoft' ); 
  323. } elseif ( "you_are_banned" == $value->package ) { 
  324. $result['error'] = __( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); 
  325. } elseif ( "time_out" == $value->package ) { 
  326. $result['error'] = sprintf( __( "Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates, you should extend it in your %s", 'bestwebsoft' ), ' <a href="https://bestwebsoft.com/client-area">Client Area</a>' ); 
  327. } elseif ( "duplicate_domen_for_trial" == $value->package ) { 
  328. $result['error'] = __( "Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); 
  329. if ( empty( $result['error'] ) ) { 
  330. $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; 
  331.  
  332. $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5'; 
  333. $uploadDir = wp_upload_dir(); 
  334. $zip_name = explode( '/', $bws_license_plugin ); 
  335.  
  336. if ( !function_exists( 'curl_init' ) ) { 
  337. $received_content = file_get_contents( $url ); 
  338. } else { 
  339. $ch = curl_init(); 
  340. curl_setopt( $ch, CURLOPT_URL, $url ); 
  341. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); 
  342. $received_content = curl_exec( $ch ); 
  343. curl_close( $ch ); 
  344.  
  345. if ( ! $received_content ) { 
  346. $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); 
  347. } else { 
  348. if ( is_writable( $uploadDir["path"] ) ) { 
  349. $file_put_contents = $uploadDir["path"] . "/" . $zip_name[0] . ".zip"; 
  350. if ( file_put_contents( $file_put_contents, $received_content ) ) { 
  351. @chmod( $file_put_contents, octdec( 755 ) ); 
  352. if ( class_exists( 'ZipArchive' ) ) { 
  353. $zip = new ZipArchive(); 
  354. if ( $zip->open( $file_put_contents ) === TRUE ) { 
  355. $zip->extractTo( WP_PLUGIN_DIR ); 
  356. $zip->close(); 
  357. } else { 
  358. $result['error'] = __( "Failed to open the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); 
  359. } elseif ( class_exists( 'Phar' ) ) { 
  360. $phar = new PharData( $file_put_contents ); 
  361. $phar->extractTo( WP_PLUGIN_DIR ); 
  362. } else { 
  363. $result['error'] = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'bestwebsoft' ); 
  364. @unlink( $file_put_contents ); 
  365. } else { 
  366. $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); 
  367. } else { 
  368. $result['error'] = __( "UploadDir is not writable. Please, upload the plugin manually", 'bestwebsoft' ); 
  369.  
  370. /** activate Pro */ 
  371. if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) { 
  372. if ( is_multisite() && is_plugin_active_for_network( $plugin_basename ) ) { 
  373. /** if multisite and free plugin is network activated */ 
  374. $active_plugins = get_site_option( 'active_sitewide_plugins' ); 
  375. $active_plugins[ $bws_license_plugin ] = time(); 
  376. update_site_option( 'active_sitewide_plugins', $active_plugins ); 
  377. } else { 
  378. /** activate on a single blog */ 
  379. $active_plugins = get_option( 'active_plugins' ); 
  380. array_push( $active_plugins, $bws_license_plugin ); 
  381. update_option( 'active_plugins', $active_plugins ); 
  382. $result['pro_plugin_is_activated'] = true; 
  383. } elseif ( empty( $result['error'] ) ) { 
  384. $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); 
  385. } else { 
  386. $result['error'] = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); 
  387. } else { 
  388. $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; 
  389. /** activate Pro */ 
  390. if ( ! is_plugin_active( $bws_license_plugin ) ) { 
  391. if ( is_multisite() && is_plugin_active_for_network( $plugin_basename ) ) { 
  392. /** if multisite and free plugin is network activated */ 
  393. $network_wide = true; 
  394. } else { 
  395. /** activate on a single blog */ 
  396. $network_wide = false; 
  397. activate_plugin( $bws_license_plugin, NULL, $network_wide ); 
  398. $result['pro_plugin_is_activated'] = true; 
  399. if ( is_multisite() ) 
  400. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  401. else 
  402. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  403.  
  404. if ( ! empty( $result['pro_plugin_is_activated'] ) ) 
  405. delete_transient( 'bws_plugins_update' ); 
  406. } else { 
  407. $result['error'] = __( "Please, enter Your license key", 'bestwebsoft' ); 
  408. return $result; 
  409.  
  410. /** 
  411. * Function display block for restoring default product settings 
  412. * @deprecated 1.9.8 (15.12.2016) 
  413. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  414. */ 
  415. if ( ! function_exists ( 'bws_form_restore_default_settings' ) ) { 
  416. function bws_form_restore_default_settings( $plugin_basename, $change_permission_attr = '' ) { ?> 
  417. <form method="post" action=""> 
  418. <p><?php _e( 'Restore all plugin settings to defaults', 'bestwebsoft' ); ?></p> 
  419. <p> 
  420. <input <?php echo $change_permission_attr; ?> type="submit" class="button" value="<?php _e( 'Restore settings', 'bestwebsoft' ); ?>" /> 
  421. </p> 
  422. <input type="hidden" name="bws_restore_default" value="submit" /> 
  423. <?php wp_nonce_field( $plugin_basename, 'bws_settings_nonce_name' ); ?> 
  424. </form> 
  425. <?php } 
  426.  
  427. /** 
  428. * Function display 'Custom code' tab 
  429. * 
  430. * @deprecated 1.9.8 (15.12.2016) 
  431. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  432. */ 
  433. if ( ! function_exists( 'bws_custom_code_tab' ) ) { 
  434. function bws_custom_code_tab() { 
  435. if ( ! current_user_can( 'edit_plugins' ) ) 
  436. wp_die( __( 'You do not have sufficient permissions to edit plugins for this site.', 'bestwebsoft' ) ); 
  437.  
  438. global $bstwbsftwppdtplgns_options; 
  439.  
  440. $message = $content = ''; 
  441. $is_css_active = $is_php_active = false; 
  442.  
  443. $upload_dir = wp_upload_dir(); 
  444. $folder = $upload_dir['basedir'] . '/bws-custom-code'; 
  445. if ( ! $upload_dir["error"] ) { 
  446. if ( ! is_dir( $folder ) ) 
  447. wp_mkdir_p( $folder, 0755 ); 
  448.  
  449. $index_file = $upload_dir['basedir'] . '/bws-custom-code/index.php'; 
  450. if ( ! file_exists( $index_file ) ) { 
  451. if ( $f = fopen( $index_file, 'w+' ) ) 
  452. fclose( $f ); 
  453.  
  454. $css_file = 'bws-custom-code.css'; 
  455. $real_css_file = $folder . '/' . $css_file; 
  456.  
  457. $php_file = 'bws-custom-code.php'; 
  458. $real_php_file = $folder . '/' . $php_file; 
  459.  
  460. $is_multisite = is_multisite(); 
  461. if ( $is_multisite ) 
  462. $blog_id = get_current_blog_id(); 
  463.  
  464. if ( isset( $_REQUEST['bws_update_custom_code'] ) && check_admin_referer( 'bws_update_' . $css_file ) ) { 
  465.  
  466. /** CSS */ 
  467. $newcontent_css = wp_unslash( $_POST['bws_newcontent_css'] ); 
  468. if ( ! empty( $newcontent_css ) && isset( $_REQUEST['bws_custom_css_active'] ) ) { 
  469. if ( $is_multisite ) 
  470. $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $css_file ] = $upload_dir['baseurl'] . '/bws-custom-code/' . $css_file; 
  471. else 
  472. $bstwbsftwppdtplgns_options['custom_code'][ $css_file ] = $upload_dir['baseurl'] . '/bws-custom-code/' . $css_file; 
  473. } else { 
  474. if ( $is_multisite ) { 
  475. if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $css_file ] ) ) 
  476. unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $css_file ] ); 
  477. } else { 
  478. if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $css_file ] ) ) 
  479. unset( $bstwbsftwppdtplgns_options['custom_code'][ $css_file ] ); 
  480. if ( $f = fopen( $real_css_file, 'w+' ) ) { 
  481. fwrite( $f, $newcontent_css ); 
  482. fclose( $f ); 
  483. $message .= sprintf( __( 'File %s edited successfully.', 'bestwebsoft' ), '<i>' . $css_file . '</i>' ) . ' '; 
  484. } else { 
  485. $error .= __( 'Not enough permissions to create or update the file', 'bestwebsoft' ) . ' ' . $real_css_file . '. '; 
  486.  
  487. /** PHP */ 
  488. $newcontent_php = wp_unslash( trim( $_POST['bws_newcontent_php'] ) ); 
  489. if ( file_exists( $index_file ) ) { 
  490. if ( ! empty( $newcontent_php ) && isset( $_REQUEST['bws_custom_php_active'] ) ) { 
  491. if ( $is_multisite ) 
  492. $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $php_file ] = $real_php_file; 
  493. else 
  494. $bstwbsftwppdtplgns_options['custom_code'][ $php_file ] = $real_php_file; 
  495. } else { 
  496. if ( $is_multisite ) { 
  497. if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $php_file ] ) ) 
  498. unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $php_file ] ); 
  499. } else { 
  500. if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $php_file ] ) ) 
  501. unset( $bstwbsftwppdtplgns_options['custom_code'][ $php_file ] ); 
  502.  
  503. if ( $f = fopen( $real_php_file, 'w+' ) ) { 
  504. $newcontent_php = $newcontent_php; 
  505. fwrite( $f, $newcontent_php ); 
  506. fclose( $f ); 
  507. $message .= sprintf( __( 'File %s edited successfully.', 'bestwebsoft' ), '<i>' . $php_file . '</i>' ); 
  508. } else { 
  509. $error .= __( 'Not enough permissions to create or update the file', 'bestwebsoft' ) . ' ' . $real_php_file . '. '; 
  510. } else { 
  511. $error .= __( 'Not enough permissions to create the file', 'bestwebsoft' ) . ' ' . $index_file . '. '; 
  512.  
  513. if ( ! empty( $error ) ) 
  514. $error .= ' <a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank">' . __( 'Learn more', 'bestwebsoft' ) . '</a>'; 
  515.  
  516. if ( $is_multisite ) 
  517. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  518. else 
  519. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  520.  
  521. if ( file_exists( $real_css_file ) ) { 
  522. update_recently_edited( $real_css_file ); 
  523. $content_css = esc_textarea( file_get_contents( $real_css_file ) ); 
  524. if ( ( $is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $css_file ] ) ) || 
  525. ( ! $is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $css_file ] ) ) ) { 
  526. $is_css_active = true; 
  527. if ( file_exists( $real_php_file ) ) { 
  528. update_recently_edited( $real_php_file ); 
  529. $content_php = esc_textarea( file_get_contents( $real_php_file ) ); 
  530. if ( ( $is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ][ $php_file ] ) ) || 
  531. ( ! $is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $php_file ] ) ) ) { 
  532. $is_php_active = true; 
  533. } else { 
  534. $content_php = "<?php" . "\n" . "if ( ! defined( 'ABSPATH' ) ) exit;" . "\n" . "if ( ! defined( 'BWS_GLOBAL' ) ) exit;" . "\n\n" . "/* Start your code here */" . "\n"; 
  535.  
  536. if ( ! empty( $message ) ) { ?> 
  537. <div id="message" class="below-h2 updated notice is-dismissible"><p><?php echo $message; ?></p></div> 
  538. <?php } ?> 
  539. <form action="" method="post"> 
  540. <?php foreach ( array( 'css', 'php' ) as $extension ) { ?> 
  541. <p> 
  542. <?php if ( 'css' == $extension ) 
  543. _e( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ); 
  544. else 
  545. printf( __( 'This PHP code will be hooked to the %s action and will be printed on front end only.', 'bestwebsoft' ), '<a href="http://codex.wordpress.org/Plugin_API/Action_Reference/init" target="_blank"><code>init</code></a>' ); ?> 
  546. </p> 
  547. <p><big> 
  548. <?php if ( ! file_exists( ${"real_{$extension}_file"} ) || ( is_writeable( ${"real_{$extension}_file"} ) ) ) { 
  549. echo __( 'Editing', 'bestwebsoft' ) . ' <strong>' . ${"{$extension}_file"} . '</strong>'; 
  550. } else { 
  551. echo __( 'Browsing', 'bestwebsoft' ) . ' <strong>' . ${"{$extension}_file"} . '</strong>'; 
  552. } ?> 
  553. </big></p> 
  554. <p><label><input type="checkbox" name="bws_custom_<?php echo $extension; ?>_active" value="1" <?php if ( ${"is_{$extension}_active"} ) echo "checked"; ?> /> <?php _e( 'Activate', 'bestwebsoft' ); ?></label></p> 
  555. <textarea cols="70" rows="25" name="bws_newcontent_<?php echo $extension; ?>" id="bws_newcontent_<?php echo $extension; ?>"><?php if ( isset( ${"content_{$extension}"} ) ) echo ${"content_{$extension}"}; ?></textarea> 
  556. <p class="description"> 
  557. <a href="<?php echo ( 'css' == $extension ) ? 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started' : 'http://php.net/' ?>" target="_blank"> 
  558. <?php printf( __( 'Learn more about %s', 'bestwebsoft' ), strtoupper( $extension ) ); ?> 
  559. </a> 
  560. </p> 
  561. <?php } 
  562. if ( ( ! file_exists( $real_css_file ) || is_writeable( $real_css_file ) ) && ( ! file_exists( $real_php_file ) || is_writeable( $real_php_file ) ) ) { ?> 
  563. <p class="submit"> 
  564. <input type="hidden" name="bws_update_custom_code" value="submit" /> 
  565. <?php submit_button( __( 'Save Changes', 'bestwebsoft' ), 'primary', 'submit', false ); 
  566. wp_nonce_field( 'bws_update_' . $css_file ); ?> 
  567. </p> 
  568. <?php } else { ?> 
  569. <p><em><?php printf( __( 'You need to make this files writable before you can save your changes. See %s the Codex %s for more information.', 'bestwebsoft' ),  
  570. '<a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank">',  
  571. '</a>' ); ?></em></p> 
  572. <?php } ?> 
  573. </form> 
  574. <?php } 
  575.  
  576. /** 
  577. * Function display GO PRO tab 
  578. * @deprecated 1.9.8 (15.12.2016) 
  579. * @todo add notice and remove functional after 01.01.2018. Remove function after 01.01.2019 
  580. */ 
  581. if ( ! function_exists( 'bws_go_pro_tab_show' ) ) { 
  582. function bws_go_pro_tab_show( $bws_hide_premium_options_check, $plugin_info, $plugin_basename, $page, $pro_page, $bws_license_plugin, $link_slug, $link_key, $link_pn, $pro_plugin_is_activated = false, $trial_days_number = false ) { 
  583. global $wp_version, $bstwbsftwppdtplgns_options; 
  584. $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; 
  585. if ( $pro_plugin_is_activated ) { ?> 
  586. <script type="text/javascript"> 
  587. window.setTimeout( function() { 
  588. window.location.href = 'admin.php?page=<?php echo $pro_page; ?>'; 
  589. }, 5000 ); 
  590. </script> 
  591. <p><?php _e( "Congratulations! Pro version of the plugin is installed and activated successfully.", 'bestwebsoft' ); ?></p> 
  592. <p> 
  593. <?php _e( "Please, go to", 'bestwebsoft' ); ?> <a href="admin.php?page=<?php echo $pro_page; ?>"><?php _e( 'the setting page', 'bestwebsoft' ); ?></a> 
  594. (<?php _e( "You will be redirected automatically in 5 seconds.", 'bestwebsoft' ); ?>) 
  595. </p> 
  596. <?php } else { 
  597. if ( $bws_hide_premium_options_check ) { ?> 
  598. <form method="post" action=""> 
  599. <p> 
  600. <input type="hidden" name="bws_hide_premium_options_submit" value="submit" /> 
  601. <input type="submit" class="button" value="<?php _e( 'Show Pro features', 'bestwebsoft' ); ?>" /> 
  602. <?php wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> 
  603. </p> 
  604. </form> 
  605. <?php } ?> 
  606. <form method="post" action=""> 
  607. <p> 
  608. <?php _e( 'Enter your license key to install and activate', 'bestwebsoft' ); ?> 
  609. <a href="https://bestwebsoft.com/products/wordpress/plugins/<?php echo $link_slug; ?>/?k=<?php echo $link_key; ?>&pn=<?php echo $link_pn; ?>&v=<?php echo $plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="<?php echo $plugin_info["Name"]; ?> Pro">Pro</a> 
  610. <?php _e( 'version of the plugin.', 'bestwebsoft' ); ?><br /> 
  611. <span class="bws_info"> 
  612. <?php _e( 'License key can be found in the', 'bestwebsoft' ); ?> 
  613. <a href="https://bestwebsoft.com/wp-login.php">Client Area</a> 
  614. <?php _e( '(your username is the email address specified during the purchase).', 'bestwebsoft' ); ?> 
  615. </span> 
  616. </p> 
  617. <?php if ( $trial_days_number !== false ) 
  618. $trial_days_number = __( 'or', 'bestwebsoft' ) . ' <a href="https://bestwebsoft.com/products/wordpress/plugins/' . $link_slug . '/trial/" target="_blank">' . sprintf( __( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), $trial_days_number ) . '</a>'; 
  619. if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && 
  620. '5' < $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] && 
  621. $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { ?> 
  622. <p> 
  623. <input disabled="disabled" type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" /> 
  624. <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> 
  625. <?php if ( $trial_days_number !== false ) echo $trial_days_number; ?> 
  626. </p> 
  627. <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> 
  628. <?php } else { ?> 
  629. <p> 
  630. <input type="text" maxlength="100" name="bws_license_key" value="<?php echo $bws_license_key; ?>" /> 
  631. <input type="hidden" name="bws_license_plugin" value="<?php echo $bws_license_plugin; ?>" /> 
  632. <input type="hidden" name="bws_license_submit" value="submit" /> 
  633. <input type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> 
  634. <?php if ( $trial_days_number !== false ) echo $trial_days_number; 
  635. wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> 
  636. </p> 
  637. <?php } ?> 
  638. </form> 
  639. <?php } 
.