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