192 $license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. <a target="_blank" href="https://support.bestwebsoft.com/entries/53487136">' . __( 'Renew Now', 'bestwebsoft' ) . '</a>'; |
206 $license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. <a target="_blank" href="https://support.bestwebsoft.com/entries/53487136">' . __( 'Renew Now', 'bestwebsoft' ) . '</a>'; |
193 } else { |
207 } else { |
194 $license_status = __( 'Active', 'bestwebsoft' ); |
208 $license_status = __( 'Active', 'bestwebsoft' ); |
195 } |
209 } |
196 } |
210 } |
197 } ?> |
211 } |
198 <div class="misc-pub-section"> |
212 ?> |
199 <strong><?php _e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo $license_type; ?> |
213 <div class="misc-pub-section"> |
200 </div> |
214 <strong><?php esc_html_e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $license_type ); ?> |
201 <div class="misc-pub-section"> |
215 </div> |
202 <strong><?php _e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo $license_status; ?> |
216 <div class="misc-pub-section"> |
203 </div><!-- .misc-pub-section --> |
217 <strong><?php esc_html_e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo wp_kses_post( $license_status ); ?> |
|
218 </div><!-- .misc-pub-section --> |
204 <?php } ?> |
219 <?php } ?> |
205 <div class="misc-pub-section"> |
220 <div class="misc-pub-section"> |
206 <strong><?php _e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo $this->plugins_info['Version']; ?> |
221 <strong><?php esc_html_e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $this->plugins_info['Version'] ); ?> |
207 </div><!-- .misc-pub-section --> |
222 </div><!-- .misc-pub-section --> |
208 </div> |
223 <?php |
209 <div class="clear"></div> |
224 /** |
210 </div> |
225 * Action - Display additional content for #misc-publishing-Actions |
211 <div id="major-publishing-actions"> |
226 */ |
212 <div id="publishing-action"> |
227 do_action( __CLASS__ . '_information_postbox_bottom' ); |
213 <input type="hidden" name="<?php echo $this->prefix; ?>_form_submit" value="submit" /> |
228 ?> |
214 <input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
229 </div> |
|
230 <div class="clear"></div> |
|
231 </div> |
|
232 <div id="major-publishing-Actions"> |
|
233 <div id="publishing-Action"> |
|
234 <input type="hidden" name="<?php echo esc_attr( $this->prefix ); ?>_form_submit" value="submit" /> |
|
235 <input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
215 <?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
236 <?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
216 </div> |
237 </div> |
217 <div class="clear"></div> |
238 <div class="clear"></div> |
218 </div> |
239 </div> |
219 </div> |
240 </div> |
220 </div> |
241 </div> |
221 </div> |
242 </div> |
222 <?php /** |
243 <?php |
223 * action - Display custom metabox |
244 /** |
|
245 * Action - Display custom metabox |
224 */ |
246 */ |
225 do_action( __CLASS__ . '_display_metabox' ); ?> |
247 do_action( __CLASS__ . '_display_metabox' ); |
226 </div> |
248 |
227 </div> |
249 if ( function_exists( 'bws_affiliate_postbox' ) ) { |
228 <div id="postbox-container-2" class="postbox-container"> |
250 bws_affiliate_postbox(); |
229 <?php /** |
251 } |
230 * action - Display additional content for #postbox-container-2 |
252 ?> |
|
253 </div> |
|
254 </div> |
|
255 <div id="postbox-container-2" class="postbox-container"> |
|
256 <?php |
|
257 /** |
|
258 * Action - Display additional content for #postbox-container-2 |
231 */ |
259 */ |
232 do_action( __CLASS__ . '_display_second_postbox' ); ?> |
260 do_action( __CLASS__ . '_display_second_postbox' ); |
233 <div class="submit"> |
261 ?> |
234 <input type="submit" class="button button-primary button-large" value="<?php _e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
262 <div class="submit"> |
235 </div> |
263 <input type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
236 <?php if ( ! empty( $this->wp_slug ) ) |
264 <?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
237 bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug ); ?> |
265 </div> |
238 </div> |
266 <?php |
239 </div> |
267 if ( ! empty( $this->wp_slug ) ) { |
240 </form> |
268 bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug );} |
241 </div> |
269 ?> |
242 <?php } |
270 </div> |
|
271 </div> |
|
272 </form> |
|
273 </div> |
|
274 <?php |
|
275 } |
243 } |
276 } |
244 |
277 |
245 /** |
278 /** |
246 * Displays the Tabs |
279 * Displays the Tabs |
|
280 * |
247 * @access public |
281 * @access public |
248 * @param void |
282 * @param void |
249 * @return void |
283 * @return void |
250 */ |
284 */ |
251 public function display_tabs() { ?> |
285 public function display_tabs() { |
252 <div id="bws_settings_tabs_wrapper"> |
286 ?> |
253 <ul id="bws_settings_tabs"> |
287 <div id="bws_settings_tabs_wrapper"> |
|
288 <ul id="bws_settings_tabs"> |
254 <?php $this->display_tabs_list(); ?> |
289 <?php $this->display_tabs_list(); ?> |
255 </ul> |
290 </ul> |
256 <?php $this->display_tabs_content(); ?> |
291 <?php $this->display_tabs_content(); ?> |
257 <div class="clear"></div> |
292 <div class="clear"></div> |
258 <input type="hidden" name="bws_active_tab" value="<?php if ( isset( $_REQUEST['bws_active_tab'] ) ) echo esc_attr( $_REQUEST['bws_active_tab'] ); ?>" /> |
293 <input type="hidden" name="bws_active_tab" value="<?php |
259 </div> |
294 if ( isset( $_REQUEST['bws_active_tab'] ) ) { |
260 <?php } |
295 echo esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['bws_active_tab'] ) ) ); |
|
296 } |
|
297 ?>" /> |
|
298 </div> |
|
299 <?php |
|
300 } |
261 |
301 |
262 /** |
302 /** |
263 * Displays the list of tabs |
303 * Displays the list of tabs |
|
304 * |
264 * @access private |
305 * @access private |
265 * @return void |
306 * @return void |
266 */ |
307 */ |
267 private function display_tabs_list() { |
308 private function display_tabs_list() { |
268 foreach ( $this->tabs as $tab_slug => $data ) { |
309 foreach ( $this->tabs as $tab_slug => $data ) { |
269 if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) |
310 if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) { |
270 continue; |
311 continue; |
|
312 } |
271 $tab_class = 'bws-tab-' . $tab_slug; |
313 $tab_class = 'bws-tab-' . $tab_slug; |
272 if ( ! empty( $data['is_pro'] ) ) |
314 if ( ! empty( $data['is_pro'] ) ) { |
273 $tab_class .= ' bws_pro_tab'; |
315 $tab_class .= ' bws_pro_tab'; |
274 if ( ! empty( $data['class'] ) ) |
316 } |
275 $tab_class .= ' ' . $data['class']; ?> |
317 if ( ! empty( $data['class'] ) ) { |
276 <li class="<?php echo $tab_class; ?>" data-slug="<?php echo $tab_slug; ?>"> |
318 $tab_class .= ' ' . $data['class']; |
277 <a href="#<?php echo $this->prefix; ?>_<?php echo $tab_slug; ?>_tab"> |
319 } |
278 <span><?php echo esc_html( $data['label'] ); ?></span> |
320 ?> |
279 </a> |
321 <li class="<?php echo esc_attr( $tab_class ); ?>" data-slug="<?php echo esc_attr( $tab_slug ); ?>"> |
280 </li> |
322 <a href="#<?php echo esc_attr( $this->prefix ); ?>_<?php echo esc_attr( $tab_slug ); ?>_tab"> |
281 <?php } |
323 <span><?php echo esc_html( $data['label'] ); ?></span> |
|
324 </a> |
|
325 </li> |
|
326 <?php |
|
327 } |
282 } |
328 } |
283 |
329 |
284 /** |
330 /** |
285 * Displays the content of tabs |
331 * Displays the content of tabs |
|
332 * |
286 * @access private |
333 * @access private |
287 * @param string $tab_slug |
334 * @param string $tab_slug |
288 * @return void |
335 * @return void |
289 */ |
336 */ |
290 public function display_tabs_content() { |
337 public function display_tabs_content() { |
291 foreach ( $this->tabs as $tab_slug => $data ) { |
338 foreach ( $this->tabs as $tab_slug => $data ) { |
292 if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) |
339 if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) { |
293 continue; ?> |
340 continue; |
294 <div class="bws_tab ui-tabs-panel ui-widget-content ui-corner-bottom" id="<?php echo esc_attr( $this->prefix . '_' . $tab_slug . '_tab' ); ?>" aria-labelledby="ui-id-2" role="tabpanel" aria-hidden="false" style="display: block;"> |
341 } |
295 <?php $tab_slug = str_replace( '-', '_', $tab_slug ); |
342 ?> |
|
343 <div class="bws_tab ui-tabs-panel ui-widget-content ui-corner-bottom" id="<?php echo esc_attr( $this->prefix . '_' . $tab_slug . '_tab' ); ?>" aria-labelledby="ui-id-2" role="tabpanel" aria-hidden="false" style="display: block;"> |
|
344 <?php |
|
345 $tab_slug = str_replace( '-', '_', $tab_slug ); |
296 if ( method_exists( $this, 'tab_' . $tab_slug ) ) { |
346 if ( method_exists( $this, 'tab_' . $tab_slug ) ) { |
297 call_user_func( array( $this, 'tab_' . $tab_slug ) ); |
347 call_user_func( array( $this, 'tab_' . $tab_slug ) ); |
298 do_action_ref_array( __CLASS__ . '_after_tab_' . $tab_slug, array( &$this ) ); |
348 do_action_ref_array( __CLASS__ . '_after_tab_' . $tab_slug, array( &$this ) ); |
299 } ?> |
349 } |
300 </div> |
350 ?> |
301 <?php } |
351 </div> |
|
352 <?php |
|
353 } |
302 } |
354 } |
303 |
355 |
304 /** |
356 /** |
305 * Save all options from all tabs and display errors\messages |
357 * Save all options from all tabs and display errors\messages |
|
358 * |
306 * @access public |
359 * @access public |
307 * @param void |
360 * @param void |
308 * @return void |
361 * @return array |
309 */ |
362 */ |
310 public function save_all_tabs_options() { |
363 public function save_all_tabs_options() { |
311 $message = $notice = $error = ''; |
364 $message = $notice = $error = ''; |
312 /* Restore default settings */ |
365 /* Restore default settings */ |
313 if ( isset( $_POST['bws_restore_confirm'] ) && check_admin_referer( $this->plugin_basename, 'bws_settings_nonce_name' ) ) { |
366 if ( isset( $_POST['bws_restore_confirm'] ) && check_admin_referer( $this->plugin_basename, 'bws_settings_nonce_name' ) ) { |
314 $this->restore_options(); |
367 $this->restore_options(); |
315 $message = __( 'All plugin settings were restored.', 'bestwebsoft' ); |
368 $message = __( 'All plugin settings were restored.', 'bestwebsoft' ); |
316 /* Go Pro - check license key */ |
369 /* Go Pro - check license key */ |
317 } elseif ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
370 } elseif ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
318 $result = $this->save_options_license_key(); |
371 $result = $this->save_options_license_key(); |
319 if ( ! empty( $result['empty_field_error'] ) ) |
372 if ( ! empty( $result['empty_field_error'] ) ) { |
320 $error = $result['empty_field_error']; |
373 $error = $result['empty_field_error']; |
321 if ( ! empty( $result['error'] ) ) |
374 } |
|
375 if ( ! empty( $result['error'] ) ) { |
322 $error = $result['error']; |
376 $error = $result['error']; |
323 if ( ! empty( $result['message'] ) ) |
377 } |
|
378 if ( ! empty( $result['message'] ) ) { |
324 $message = $result['message']; |
379 $message = $result['message']; |
325 if ( ! empty( $result['notice'] ) ) |
380 } |
|
381 if ( ! empty( $result['notice'] ) ) { |
326 $notice = $result['notice']; |
382 $notice = $result['notice']; |
|
383 } |
327 /* check demo data */ |
384 /* check demo data */ |
328 } else { |
385 } else { |
329 $demo_result = ! empty( $this->demo_data ) ? $this->demo_data->bws_handle_demo_data() : false; |
386 $demo_result = ! empty( $this->demo_data ) ? $this->demo_data->bws_handle_demo_data() : false; |
330 if ( false !== $demo_result ) { |
387 if ( false !== $demo_result ) { |
331 if ( ! empty( $demo_result ) && is_array( $demo_result ) ) { |
388 if ( ! empty( $demo_result ) && is_array( $demo_result ) ) { |
332 $error = $demo_result['error']; |
389 $error = $demo_result['error']; |
333 $message = $demo_result['done']; |
390 $message = $demo_result['done']; |
334 if ( ! empty( $demo_result['done'] ) && ! empty( $demo_result['options'] ) ) |
391 if ( ! empty( $demo_result['done'] ) && ! empty( $demo_result['options'] ) ) { |
335 $this->options = $demo_result['options']; |
392 $this->options = $demo_result['options']; |
|
393 } |
336 } |
394 } |
337 /* Save options */ |
395 /* Save options */ |
338 } elseif ( ! isset( $_REQUEST['bws_restore_default'] ) && ! isset( $_POST['bws_handle_demo'] ) && isset( $_REQUEST[ $this->prefix . '_form_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
396 } elseif ( ! isset( $_REQUEST['bws_restore_default'] ) && ! isset( $_POST['bws_handle_demo'] ) && isset( $_REQUEST[ $this->prefix . '_form_submit' ] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
339 /* save tabs */ |
397 /* save tabs */ |
340 $result = $this->save_options(); |
398 $result = $this->save_options(); |
341 if ( ! empty( $result['error'] ) ) |
399 if ( ! empty( $result['error'] ) ) { |
342 $error = $result['error']; |
400 $error = $result['error']; |
343 if ( ! empty( $result['message'] ) ) |
401 } |
|
402 if ( ! empty( $result['message'] ) ) { |
344 $message = $result['message']; |
403 $message = $result['message']; |
345 if ( ! empty( $result['notice'] ) ) |
404 } |
|
405 if ( ! empty( $result['notice'] ) ) { |
346 $notice = $result['notice']; |
406 $notice = $result['notice']; |
347 |
407 } |
348 if ( '' == $this->change_permission_attr ) { |
408 |
|
409 if ( '' === $this->change_permission_attr ) { |
349 /* save `misc` tab */ |
410 /* save `misc` tab */ |
350 $result = $this->save_options_misc(); |
411 $result = $this->save_options_misc(); |
351 if ( ! empty( $result['notice'] ) ) |
412 if ( ! empty( $result['notice'] ) ) { |
352 $notice .= $result['notice']; |
413 $notice .= $result['notice']; |
353 } |
414 } |
354 |
|
355 if ( array_key_exists( 'custom_code', $this->tabs ) ) { |
|
356 /* save `custom code` tab */ |
|
357 $this->save_options_custom_code(); |
|
358 } |
415 } |
359 } |
416 } |
360 } |
417 } |
361 |
418 |
362 return compact( 'message', 'notice', 'error' ); |
419 return compact( 'message', 'notice', 'error' ); |
363 } |
420 } |
364 |
421 |
365 /** |
422 /** |
366 * Display error\message\notice |
423 * Display error\message\notice |
|
424 * |
367 * @access public |
425 * @access public |
368 * @param $save_results - array with error\message\notice |
426 * @param $save_results - array with error\message\notice |
369 * @return void |
427 * @return void |
370 */ |
428 */ |
371 public function display_messages( $save_results ) { |
429 public function display_messages( $save_results ) { |
372 /** |
430 /** |
373 * action - Display custom error\message\notice |
431 * Action - Display custom error\message\notice |
374 */ |
432 */ |
375 do_action( __CLASS__ . '_display_custom_messages', $save_results ); ?> |
433 do_action( __CLASS__ . '_display_custom_messages', $save_results ); |
376 <div class="updated fade inline" <?php if ( empty( $save_results['message'] ) ) echo "style=\"display:none\""; ?>><p><strong><?php echo $save_results['message']; ?></strong></p></div> |
434 ?> |
377 <div class="updated bws-notice inline" <?php if ( empty( $save_results['notice'] ) ) echo "style=\"display:none\""; ?>><p><strong><?php echo $save_results['notice']; ?></strong></p></div> |
435 <div class="updated fade inline" |
378 <div class="error inline" <?php if ( empty( $save_results['error'] ) ) echo "style=\"display:none\""; ?>><p><strong><?php echo $save_results['error']; ?></strong></p></div> |
436 <?php |
379 <?php } |
437 if ( empty( $save_results['message'] ) ) { |
|
438 echo 'style="display:none"';} |
|
439 ?> |
|
440 ><p><strong><?php echo esc_html( $save_results['message'] ); ?></strong></p></div> |
|
441 <div class="updated bws-notice inline" |
|
442 <?php |
|
443 if ( empty( $save_results['notice'] ) ) { |
|
444 echo 'style="display:none"';} |
|
445 ?> |
|
446 ><p><strong><?php echo esc_html( $save_results['notice'] ); ?></strong></p></div> |
|
447 <div class="error inline" |
|
448 <?php |
|
449 if ( empty( $save_results['error'] ) ) { |
|
450 echo 'style="display:none"';} |
|
451 ?> |
|
452 ><p><strong><?php echo esc_html( $save_results['error'] ); ?></strong></p></div> |
|
453 <?php |
|
454 } |
380 |
455 |
381 /** |
456 /** |
382 * Save plugin options to the database |
457 * Save plugin options to the database |
|
458 * |
383 * @access public |
459 * @access public |
384 * @param ab |
460 * @param ab |
385 * @return array The action results |
461 * @return array The Action results |
386 * @abstract |
462 * @abstract |
387 */ |
463 */ |
388 public function save_options() { |
464 public function save_options() { |
389 die( 'function Bws_Settings_Tabs::save_options() must be over-ridden in a sub-class.' ); |
465 die( 'function Bws_Settings_Tabs::save_options() must be over-ridden in a sub-class.' ); |
390 } |
466 } |
391 |
467 |
392 /** |
468 /** |
393 * Get 'custom_code' status and content |
469 * Get 'custom_code' status and content |
|
470 * |
394 * @access private |
471 * @access private |
395 */ |
472 */ |
396 private function get_custom_code() { |
473 private function get_custom_code() { |
397 global $bstwbsftwppdtplgns_options; |
474 global $bstwbsftwppdtplgns_options, $wp_filesystem; |
398 |
475 |
399 $this->custom_code_args = array( |
476 $this->custom_code_args = array( |
400 'is_css_active' => false, |
477 'is_css_active' => false, |
401 'content_css' => '', |
478 'content_css' => '', |
402 'css_writeable' => false, |
479 'css_writeable' => false, |
403 'is_php_active' => false, |
480 'is_php_active' => false, |
404 'content_php' => '', |
481 'content_php' => '', |
405 'php_writeable' => false, |
482 'php_writeable' => false, |
406 'is_js_active' => false, |
483 'is_js_active' => false, |
407 'content_js' => '', |
484 'content_js' => '', |
408 'js_writeable' => false, |
485 'js_writeable' => false, |
409 ); |
486 ); |
410 |
487 |
411 if ( ! $this->upload_dir ) |
488 if ( ! $this->upload_dir ) { |
412 $this->upload_dir = wp_upload_dir(); |
489 $this->upload_dir = wp_upload_dir(); |
|
490 } |
413 |
491 |
414 $folder = $this->upload_dir['basedir'] . '/bws-custom-code'; |
492 $folder = $this->upload_dir['basedir'] . '/bws-custom-code'; |
415 if ( ! $this->upload_dir["error"] ) { |
493 |
416 if ( ! is_dir( $folder ) ) |
494 if ( $this->is_multisite ) { |
417 wp_mkdir_p( $folder, 0755 ); |
|
418 |
|
419 $index_file = $this->upload_dir['basedir'] . '/bws-custom-code/index.php'; |
|
420 if ( ! file_exists( $index_file ) ) { |
|
421 if ( $f = fopen( $index_file, 'w+' ) ) |
|
422 fclose( $f ); |
|
423 } |
|
424 } |
|
425 |
|
426 if ( $this->is_multisite ) |
|
427 $this->custom_code_args['blog_id'] = get_current_blog_id(); |
495 $this->custom_code_args['blog_id'] = get_current_blog_id(); |
|
496 } |
|
497 |
|
498 WP_Filesystem(); |
428 |
499 |
429 foreach ( array( 'css', 'php', 'js' ) as $extension ) { |
500 foreach ( array( 'css', 'php', 'js' ) as $extension ) { |
430 $file = 'bws-custom-code.' . $extension; |
501 $file = 'bws-custom-code.' . $extension; |
431 $real_file = $folder . '/' . $file; |
502 $real_file = $folder . '/' . $file; |
432 |
503 |
433 if ( file_exists( $real_file ) ) { |
504 if ( $wp_filesystem->exists( $real_file ) ) { |
434 update_recently_edited( $real_file ); |
505 update_recently_edited( $real_file ); |
435 $this->custom_code_args["content_{$extension}"] = file_get_contents( $real_file ); |
506 $this->custom_code_args[ "content_{$extension}" ] = $wp_filesystem->get_contents( $real_file );//file_get_contents( $real_file ); |
436 if ( ( $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ) ) || |
507 if ( ( $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ) ) || |
437 ( ! $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ) ) ) { |
508 ( ! $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ) ) ) { |
438 $this->custom_code_args["is_{$extension}_active"] = true; |
509 $this->custom_code_args[ "is_{$extension}_active" ] = true; |
439 } |
510 } |
440 if ( is_writeable( $real_file ) ) |
511 if ( is_writeable( $real_file ) ) { |
441 $this->custom_code_args["{$extension}_writeable"] = true; |
512 $this->custom_code_args[ "{$extension}_writeable" ] = true; |
|
513 } |
442 } else { |
514 } else { |
443 $this->custom_code_args["{$extension}_writeable"] = true; |
515 $this->custom_code_args[ "{$extension}_writeable" ] = true; |
444 if ( 'php' == $extension ) |
516 if ( 'php' === $extension ) { |
445 $this->custom_code_args["content_{$extension}"] = "<?php" . "\n" . "if ( ! defined( 'ABSPATH' ) ) exit;" . "\n" . "if ( ! defined( 'BWS_GLOBAL' ) ) exit;" . "\n\n" . "/* Start your code here */" . "\n"; |
517 $this->custom_code_args[ "content_{$extension}" ] = '<?php' . "\n" . "if ( ! defined( 'ABSPATH' ) ) exit;" . "\n" . "if ( ! defined( 'BWS_GLOBAL' ) ) exit;" . "\n\n" . '/* Start your code here */' . "\n"; |
|
518 } |
446 } |
519 } |
447 } |
520 } |
448 } |
521 } |
449 |
522 |
450 /** |
523 /** |
451 * Display 'custom_code' tab |
524 * Display 'custom_code' tab |
|
525 * |
452 * @access private |
526 * @access private |
453 */ |
527 */ |
454 private function tab_custom_code() { ?> |
528 private function tab_custom_code() { |
455 <h3 class="bws_tab_label"><?php _e( 'Custom Code', 'bestwebsoft' ); ?></h3> |
529 global $bstwbsftwppdtplgns_options, $wp_version; |
|
530 ?> |
|
531 <h3 class="bws_tab_label"><?php esc_html_e( 'Custom Code', 'bestwebsoft' ); ?></h3> |
|
532 <?php |
|
533 $this->help_phrase(); |
|
534 $bws_hide_premium = bws_hide_premium_options_check( $bstwbsftwppdtplgns_options ); |
|
535 ?> |
|
536 <hr> |
|
537 <h4><?php esc_html_e( 'The ability to add custom code is available in the Pro version. If the Pro version is not available please contact us via Help Center', 'bestwebsoft' ); ?> (<a href="<?php echo esc_url( 'https://support.bestwebsoft.com/hc/en-us/requests/new' ); ?>"><?php echo esc_url( 'https://support.bestwebsoft.com/hc/en-us/requests/new' ); ?></a>)</h4> |
|
538 <?php |
|
539 if ( ! $bws_hide_premium ) { |
|
540 ?> |
|
541 <div class="bws_pro_version_bloc pdfprnt-pro-feature"> |
|
542 <div class="bws_pro_version_table_bloc"> |
|
543 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="Close"></button> |
|
544 <div class="bws_table_bg"></div> |
|
545 <div class="bws_pro_version"> |
|
546 <?php |
|
547 if ( ! current_user_can( 'edit_plugins' ) ) { |
|
548 echo '<p>' . esc_html__( 'You do not have sufficient permissions to edit plugins for this site.', 'bestwebsoft' ) . '</p>'; |
|
549 return; |
|
550 } |
|
551 |
|
552 $list = array( |
|
553 'css' => array( |
|
554 'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
555 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started', |
|
556 ), |
|
557 'php' => array( |
|
558 'description' => sprintf( __( '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>' ), |
|
559 'learn_more_link' => 'https://php.net/', |
|
560 ), |
|
561 'js' => array( |
|
562 'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
563 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript', |
|
564 ), |
|
565 ); |
|
566 |
|
567 foreach ( $list as $extension => $extension_data ) { |
|
568 $name = 'js' === $extension ? 'JavaScript' : strtoupper( $extension ); |
|
569 ?> |
|
570 <p><big> |
|
571 <strong><?php echo esc_html( $name ); ?></strong> |
|
572 <?php |
|
573 if ( ! $this->custom_code_args[ "{$extension}_writeable" ] ) { |
|
574 echo '(' . esc_html__( 'Browsing', 'bestwebsoft' ) . ')';} |
|
575 ?> |
|
576 </big> |
|
577 </p> |
|
578 <p class="bws_info"> |
|
579 <label> |
|
580 <input type="checkbox" value="1" |
|
581 <?php |
|
582 if ( $this->custom_code_args[ "is_{$extension}_active" ] ) { |
|
583 echo 'checked';} |
|
584 ?> |
|
585 /> |
|
586 <?php printf( esc_html__( 'Activate custom %s code.', 'bestwebsoft' ), esc_html( $name ) ); ?> |
|
587 </label> |
|
588 </p> |
|
589 <textarea cols="70" rows="25" id="bws_newcontent_<?php echo esc_attr( $extension ); ?>" disabled="disabled"><?php |
|
590 if ( isset( $this->custom_code_args[ "content_{$extension}" ] ) ) { |
|
591 echo esc_html( stripslashes_deep( $this->custom_code_args[ "content_{$extension}" ] ) ); } |
|
592 ?></textarea> |
|
593 <p class="bws_info"> |
|
594 <?php echo esc_html( $extension_data['description'] ); ?> |
|
595 <br> |
|
596 <a href="<?php echo esc_url( $extension_data['learn_more_link'] ); ?>" target="_blank"> |
|
597 <?php printf( esc_html__( 'Learn more about %s', 'bestwebsoft' ), esc_html__( $name ) ); ?> |
|
598 </a> |
|
599 </p> |
|
600 <?php |
|
601 } |
|
602 ?> |
|
603 </div> |
|
604 </div> |
|
605 <div class="bws_pro_version_tooltip"> |
|
606 <a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo $this->plugins_info["Name"]; ?>">Upgrade to Pro</a> |
|
607 <div class="clear"></div> |
|
608 </div> |
|
609 </div> |
|
610 <?php |
|
611 } else { |
|
612 ?> |
|
613 <div class="bws_pro_version_tooltip"> |
|
614 <a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo $this->plugins_info["Name"]; ?>">Upgrade to Pro</a> |
|
615 <div class="clear"></div> |
|
616 </div> |
|
617 <?php |
|
618 } |
|
619 } |
|
620 |
|
621 /** |
|
622 * Display 'misc' tab |
|
623 * |
|
624 * @access private |
|
625 */ |
|
626 private function tab_misc() { |
|
627 global $bstwbsftwppdtplgns_options; |
|
628 ?> |
|
629 <h3 class="bws_tab_label"><?php esc_html_e( 'Miscellaneous Settings', 'bestwebsoft' ); ?></h3> |
456 <?php $this->help_phrase(); ?> |
630 <?php $this->help_phrase(); ?> |
457 <hr> |
631 <hr> |
458 <?php if ( ! current_user_can( 'edit_plugins' ) ) { |
632 <?php |
459 echo '<p>' . __( 'You do not have sufficient permissions to edit plugins for this site.', 'bestwebsoft' ) . '</p>'; |
633 /** |
460 return; |
634 * Action - Display custom options on the Import / Export' tab |
461 } |
|
462 |
|
463 $list = array( |
|
464 'css' => array( 'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
465 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started' |
|
466 ), |
|
467 'php' => array( 'description' => sprintf( __( '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>' ), |
|
468 'learn_more_link' => 'https://php.net/' |
|
469 ), |
|
470 'js' => array( 'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
471 'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript' |
|
472 ), |
|
473 ); |
|
474 |
|
475 if ( ! $this->custom_code_args['css_writeable'] || |
|
476 ! $this->custom_code_args['php_writeable'] || |
|
477 ! $this->custom_code_args['js_writeable'] ) { ?> |
|
478 <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' ), |
|
479 '<a href="https://codex.wordpress.org/Changing_File_Permissions" target="_blank">', |
|
480 '</a>' ); ?></em></p> |
|
481 <?php } |
|
482 |
|
483 foreach ( $list as $extension => $extension_data ) { |
|
484 $name = 'js' == $extension ? 'JavaScript' : strtoupper( $extension ); ?> |
|
485 <p><big> |
|
486 <strong><?php echo $name; ?></strong> |
|
487 <?php if ( ! $this->custom_code_args["{$extension}_writeable"] ) |
|
488 echo '(' . __( 'Browsing', 'bestwebsoft' ) . ')'; ?> |
|
489 </big></p> |
|
490 <p class="bws_info"> |
|
491 <label> |
|
492 <input type="checkbox" name="bws_custom_<?php echo $extension; ?>_active" value="1" <?php if ( $this->custom_code_args["is_{$extension}_active"] ) echo "checked"; ?> /> |
|
493 <?php printf( __( 'Activate custom %s code.', 'bestwebsoft' ), $name ); ?> |
|
494 </label> |
|
495 </p> |
|
496 <textarea cols="70" rows="25" name="bws_newcontent_<?php echo $extension; ?>" id="bws_newcontent_<?php echo $extension; ?>"><?php if ( isset( $this->custom_code_args["content_{$extension}"] ) ) echo esc_textarea( $this->custom_code_args["content_{$extension}"] ); ?></textarea> |
|
497 <p class="bws_info"> |
|
498 <?php echo $extension_data['description']; ?> |
|
499 <br> |
|
500 <a href="<?php echo esc_url( $extension_data['learn_more_link'] ); ?>" target="_blank"> |
|
501 <?php printf( __( 'Learn more about %s', 'bestwebsoft' ), $name ); ?> |
|
502 </a> |
|
503 </p> |
|
504 <?php } |
|
505 } |
|
506 |
|
507 /** |
|
508 * Save plugin options to the database |
|
509 * @access private |
|
510 * @return array The action results |
|
511 */ |
|
512 private function save_options_custom_code() { |
|
513 global $bstwbsftwppdtplgns_options; |
|
514 $folder = $this->upload_dir['basedir'] . '/bws-custom-code'; |
|
515 |
|
516 foreach ( array( 'css', 'php', 'js' ) as $extension ) { |
|
517 $file = 'bws-custom-code.' . $extension; |
|
518 $real_file = $folder . '/' . $file; |
|
519 |
|
520 if ( isset( $_POST["bws_newcontent_{$extension}"] ) && |
|
521 $this->custom_code_args["{$extension}_writeable"] ) { |
|
522 $newcontent = trim( wp_unslash( $_POST["bws_newcontent_{$extension}"] ) ); |
|
523 if ( 'css' == $extension ) |
|
524 $newcontent = wp_kses( $newcontent, array( '\'', '\"' ) ); |
|
525 |
|
526 if ( ! empty( $newcontent ) && isset( $_POST["bws_custom_{$extension}_active"] ) ) { |
|
527 $this->custom_code_args["is_{$extension}_active"] = true; |
|
528 if ( $this->is_multisite ) { |
|
529 $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] = ( 'php' == $extension ) ? $real_file : $this->upload_dir['baseurl'] . '/bws-custom-code/' . $file; |
|
530 } else { |
|
531 $bstwbsftwppdtplgns_options['custom_code'][ $file ] = ( 'php' == $extension ) ? $real_file : $this->upload_dir['baseurl'] . '/bws-custom-code/' . $file; |
|
532 } |
|
533 } else { |
|
534 $this->custom_code_args["is_{$extension}_active"] = false; |
|
535 if ( $this->is_multisite ) { |
|
536 if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ) ) |
|
537 unset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ); |
|
538 } else { |
|
539 if ( isset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ) ) |
|
540 unset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ); |
|
541 } |
|
542 } |
|
543 if ( $f = fopen( $real_file, 'w+' ) ) { |
|
544 fwrite( $f, $newcontent ); |
|
545 fclose( $f ); |
|
546 $this->custom_code_args["content_{$extension}"] = $newcontent; |
|
547 } |
|
548 } |
|
549 } |
|
550 |
|
551 if ( $this->is_multisite ) |
|
552 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
553 else |
|
554 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
555 } |
|
556 |
|
557 /** |
|
558 * Display 'misc' tab |
|
559 * @access private |
|
560 */ |
|
561 private function tab_misc() { |
|
562 global $bstwbsftwppdtplgns_options; ?> |
|
563 <h3 class="bws_tab_label"><?php _e( 'Miscellaneous Settings', 'bestwebsoft' ); ?></h3> |
|
564 <?php $this->help_phrase(); ?> |
|
565 <hr> |
|
566 <?php /** |
|
567 * action - Display custom options on the Import / Export' tab |
|
568 */ |
635 */ |
569 do_action( __CLASS__ . '_additional_misc_options' ); |
636 do_action( __CLASS__ . '_additional_misc_options' ); |
570 |
637 |
571 if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { ?> |
638 if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { |
572 <div class="error inline bws_visible"><p><strong><?php _e( "Notice", 'bestwebsoft' ); ?>:</strong> <strong><?php printf( __( "It is prohibited to change %s settings on this site in the %s network settings.", 'bestwebsoft' ), $this->plugins_info["Name"], $this->plugins_info["Name"] ); ?></strong></p></div> |
639 ?> |
573 <?php } |
640 <div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to change %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
574 if ( $this->forbid_view ) { ?> |
641 <?php |
575 <div class="error inline bws_visible"><p><strong><?php _e( "Notice", 'bestwebsoft' ); ?>:</strong> <strong><?php printf( __( "It is prohibited to view %s settings on this site in the %s network settings.", 'bestwebsoft' ), $this->plugins_info["Name"], $this->plugins_info["Name"] ); ?></strong></p></div> |
642 } |
|
643 if ( $this->forbid_view ) { |
|
644 ?> |
|
645 <div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to view %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
576 <?php } else { ?> |
646 <?php } else { ?> |
577 <table class="form-table"> |
647 <table class="form-table"> |
578 <?php /** |
648 <?php |
579 * action - Display custom options on the 'misc' tab |
649 /** |
|
650 * Action - Display custom options on the 'misc' tab |
580 */ |
651 */ |
581 do_action( __CLASS__ . '_additional_misc_options_affected' ); |
652 do_action( __CLASS__ . '_additional_misc_options_affected' ); |
582 if ( ! empty( $this->pro_page ) && $this->bws_hide_pro_option_exist ) { ?> |
653 if ( ! empty( $this->pro_page ) && $this->bws_hide_pro_option_exist ) { |
583 <tr> |
654 ?> |
584 <th scope="row"><?php _e( 'Pro Options', 'bestwebsoft' ); ?></th> |
655 <tr> |
585 <td> |
656 <th scope="row"><?php esc_html_e( 'Pro Options', 'bestwebsoft' ); ?></th> |
586 <label> |
657 <td> |
587 <input <?php echo $this->change_permission_attr; ?> name="bws_hide_premium_options_submit" type="checkbox" value="1" <?php if ( ! $this->hide_pro_tabs ) echo 'checked="checked "'; ?> /> |
658 <label> |
588 <span class="bws_info"><?php _e( 'Enable to display plugin Pro options.', 'bestwebsoft' ); ?></span> |
659 <input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_hide_premium_options_submit" type="checkbox" value="1" |
589 </label> |
660 <?php |
590 </td> |
661 if ( ! $this->hide_pro_tabs ) { |
591 </tr> |
662 echo 'checked="checked "';} |
|
663 ?> |
|
664 /> |
|
665 <span class="bws_info"><?php esc_html_e( 'Enable to display plugin Pro options.', 'bestwebsoft' ); ?></span> |
|
666 </label> |
|
667 </td> |
|
668 </tr> |
592 <?php } ?> |
669 <?php } ?> |
593 <tr> |
670 <tr> |
594 <th scope="row"><?php _e( 'Track Usage', 'bestwebsoft' ); ?></th> |
671 <th scope="row"><?php esc_html_e( 'Track Usage', 'bestwebsoft' ); ?></th> |
595 <td> |
672 <td> |
596 <label> |
673 <label> |
597 <input <?php echo $this->change_permission_attr; ?> name="bws_track_usage" type="checkbox" value="1" <?php if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) echo 'checked="checked "'; ?>/> |
674 <input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_track_usage" type="checkbox" value="1" |
598 <span class="bws_info"><?php _e( 'Enable to allow tracking plugin usage anonymously in order to make it better.', 'bestwebsoft' ); ?></span> |
675 <?php |
599 </label> |
676 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
600 </td> |
677 echo 'checked="checked "';} |
601 </tr> |
678 ?> |
602 <tr> |
679 /> |
603 <th scope="row"><?php _e( 'Default Settings', 'bestwebsoft' ); ?></th> |
680 <span class="bws_info"><?php esc_html_e( 'Enable to allow tracking plugin usage anonymously in order to make it better.', 'bestwebsoft' ); ?></span> |
604 <td> |
681 </label> |
605 <input<?php echo $this->change_permission_attr; ?> name="bws_restore_default" type="submit" class="button" value="<?php _e( 'Restore Settings', 'bestwebsoft' ); ?>" /> |
682 </td> |
606 <div class="bws_info"><?php _e( 'This will restore plugin settings to defaults.', 'bestwebsoft' ); ?></div> |
683 </tr> |
607 </td> |
684 <tr> |
608 </tr> |
685 <th scope="row"><?php esc_html_e( 'Default Settings', 'bestwebsoft' ); ?></th> |
609 </table> |
686 <td> |
610 <?php } |
687 <input<?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_restore_default" type="submit" class="button" value="<?php esc_html_e( 'Restore Settings', 'bestwebsoft' ); ?>" /> |
|
688 <div class="bws_info"><?php esc_html_e( 'This will restore plugin settings to defaults.', 'bestwebsoft' ); ?></div> |
|
689 </td> |
|
690 </tr> |
|
691 </table> |
|
692 <?php |
|
693 } |
611 } |
694 } |
612 |
695 |
613 /** |
696 /** |
614 * Display 'Import / Export' tab |
697 * Display 'Import / Export' tab |
|
698 * |
615 * @access private |
699 * @access private |
616 */ |
700 */ |
617 public function tab_import_export() { ?> |
701 public function tab_import_export() { |
618 <h3 class="bws_tab_label"><?php _e( 'Import / Export', 'bestwebsoft' ); ?></h3> |
702 ?> |
|
703 <h3 class="bws_tab_label"><?php esc_html_e( 'Import / Export', 'bestwebsoft' ); ?></h3> |
619 <?php $this->help_phrase(); ?> |
704 <?php $this->help_phrase(); ?> |
620 <hr> |
705 <hr> |
621 <?php /** |
706 <?php |
622 * action - Display custom options on the Import / Export' tab |
707 /** |
|
708 * Action - Display custom options on the Import / Export' tab |
623 */ |
709 */ |
624 do_action( __CLASS__ . '_additional_import_export_options' ); |
710 do_action( __CLASS__ . '_additional_import_export_options' ); |
625 |
711 |
626 if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { ?> |
712 if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { |
627 <div class="error inline bws_visible"><p><strong><?php _e( "Notice", 'bestwebsoft' ); ?>:</strong> <strong><?php printf( __( "It is prohibited to change %s settings on this site in the %s network settings.", 'bestwebsoft' ), $this->plugins_info["Name"], $this->plugins_info["Name"] ); ?></strong></p></div> |
713 ?> |
628 <?php } |
714 <div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to change %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
629 if ( $this->forbid_view ) { ?> |
715 <?php |
630 <div class="error inline bws_visible"><p><strong><?php _e( "Notice", 'bestwebsoft' ); ?>:</strong> <strong><?php printf( __( "It is prohibited to view %s settings on this site in the %s network settings.", 'bestwebsoft' ), $this->plugins_info["Name"], $this->plugins_info["Name"] ); ?></strong></p></div> |
716 } |
|
717 if ( $this->forbid_view ) { |
|
718 ?> |
|
719 <div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to view %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
631 <?php } else { ?> |
720 <?php } else { ?> |
632 <table class="form-table"> |
721 <table class="form-table"> |
633 <?php /** |
722 <?php |
634 * action - Display custom options on the Import / Export' tab |
723 /** |
|
724 * Action - Display custom options on the Import / Export' tab |
635 */ |
725 */ |
636 do_action( __CLASS__ . '_additional_import_export_options_affected' ); ?> |
726 do_action( __CLASS__ . '_additional_import_export_options_affected' ); |
637 </table> |
727 ?> |
638 <?php } |
728 </table> |
|
729 <?php |
|
730 } |
639 } |
731 } |
640 |
732 |
641 /** |
733 /** |
642 * Save plugin options to the database |
734 * Save plugin options to the database |
|
735 * |
643 * @access private |
736 * @access private |
644 */ |
737 */ |
645 private function save_options_misc() { |
738 private function save_options_misc() { |
646 global $bstwbsftwppdtplgns_options, $wp_version; |
739 global $bstwbsftwppdtplgns_options, $wp_version; |
647 $notice = ''; |
740 $notice = ''; |
648 |
741 |
649 /* hide premium options */ |
742 /* hide premium options */ |
650 if ( ! empty( $this->pro_page ) ) { |
743 if ( ! empty( $this->pro_page ) ) { |
651 if ( isset( $_POST['bws_hide_premium_options'] ) ) { |
744 if ( isset( $_POST['bws_hide_premium_options'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
652 $hide_result = bws_hide_premium_options( $this->options ); |
745 $hide_result = bws_hide_premium_options( $this->options ); |
653 $this->hide_pro_tabs = true; |
746 $this->hide_pro_tabs = true; |
654 $this->options = $hide_result['options']; |
747 $this->options = $hide_result['options']; |
655 if ( ! empty( $hide_result['message'] ) ) |
748 if ( ! empty( $hide_result['message'] ) ) { |
656 $notice = $hide_result['message']; |
749 $notice = $hide_result['message']; |
657 if ( $this->is_network_options ) |
750 } |
|
751 if ( $this->is_network_options ) { |
658 update_site_option( $this->prefix . '_options', $this->options ); |
752 update_site_option( $this->prefix . '_options', $this->options ); |
659 else |
753 } else { |
660 update_option( $this->prefix . '_options', $this->options ); |
754 update_option( $this->prefix . '_options', $this->options ); |
661 } else if ( isset( $_POST['bws_hide_premium_options_submit'] ) ) { |
755 } |
|
756 } elseif ( isset( $_POST['bws_hide_premium_options_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
662 if ( ! empty( $this->options['hide_premium_options'] ) ) { |
757 if ( ! empty( $this->options['hide_premium_options'] ) ) { |
663 $key = array_search( get_current_user_id(), $this->options['hide_premium_options'] ); |
758 $key = array_search( get_current_user_id(), $this->options['hide_premium_options'] ); |
664 if ( false !== $key ) |
759 if ( false !== $key ) { |
665 unset( $this->options['hide_premium_options'][ $key ] ); |
760 unset( $this->options['hide_premium_options'][ $key ] ); |
666 if ( $this->is_network_options ) |
761 } |
|
762 if ( $this->is_network_options ) { |
667 update_site_option( $this->prefix . '_options', $this->options ); |
763 update_site_option( $this->prefix . '_options', $this->options ); |
668 else |
764 } else { |
669 update_option( $this->prefix . '_options', $this->options ); |
765 update_option( $this->prefix . '_options', $this->options ); |
|
766 } |
670 } |
767 } |
671 $this->hide_pro_tabs = false; |
768 $this->hide_pro_tabs = false; |
672 } else { |
769 } else { |
673 if ( empty( $this->options['hide_premium_options'] ) ) { |
770 if ( empty( $this->options['hide_premium_options'] ) ) { |
674 $this->options['hide_premium_options'][] = get_current_user_id(); |
771 $this->options['hide_premium_options'][] = get_current_user_id(); |
675 if ( $this->is_network_options ) |
772 if ( $this->is_network_options ) { |
676 update_site_option( $this->prefix . '_options', $this->options ); |
773 update_site_option( $this->prefix . '_options', $this->options ); |
677 else |
774 } else { |
678 update_option( $this->prefix . '_options', $this->options ); |
775 update_option( $this->prefix . '_options', $this->options ); |
|
776 } |
679 } |
777 } |
680 $this->hide_pro_tabs = true; |
778 $this->hide_pro_tabs = true; |
681 } |
779 } |
682 } |
780 } |
683 /* Save 'Track Usage' option */ |
781 /* Save 'Track Usage' option */ |
684 if ( isset( $_POST['bws_track_usage'] ) ) { |
782 if ( isset( $_POST['bws_track_usage'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
685 if ( empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
783 if ( empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
686 $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] = true; |
784 $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] = true; |
687 $track_usage = true; |
785 $track_usage = true; |
688 } |
786 } |
689 } else { |
787 } else { |
690 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
788 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
691 unset( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ); false; |
789 unset( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ); |
|
790 false; |
692 $track_usage = false; |
791 $track_usage = false; |
693 } |
792 } |
694 } |
793 } |
695 if ( isset( $track_usage ) ) { |
794 if ( isset( $track_usage ) ) { |
696 $usage_id = ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ? $bstwbsftwppdtplgns_options['track_usage']['usage_id'] : false; |
795 $usage_id = ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ? $bstwbsftwppdtplgns_options['track_usage']['usage_id'] : false; |
697 /* send data */ |
796 /* send data */ |
698 $options = array( |
797 $options = array( |
699 'timeout' => 3, |
798 'timeout' => 3, |
700 'body' => array( |
799 'body' => array( |
701 'url' => get_bloginfo( 'url' ), |
800 'url' => get_bloginfo( 'url' ), |
702 'wp_version' => $wp_version, |
801 'wp_version' => $wp_version, |
703 'is_active' => $track_usage, |
802 'is_active' => $track_usage, |
704 'product' => $this->plugin_basename, |
803 'product' => $this->plugin_basename, |
705 'version' => $this->plugins_info['Version'], |
804 'version' => $this->plugins_info['Version'], |
706 'usage_id' => $usage_id, |
805 'usage_id' => $usage_id, |
707 ), |
806 ), |
708 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
807 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
709 ); |
808 ); |
710 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options ); |
809 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options ); |
711 |
810 |
712 if ( ! is_wp_error( $raw_response ) && 200 == wp_remote_retrieve_response_code( $raw_response ) ) { |
811 if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
713 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
812 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
714 |
813 |
715 if ( is_array( $response ) && |
814 if ( is_array( $response ) && |
716 ! empty( $response['usage_id'] ) && |
815 ! empty( $response['usage_id'] ) && |
717 $response['usage_id'] != $usage_id ) { |
816 $response['usage_id'] !== $usage_id ) { |
718 $bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
817 $bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
719 } |
818 } |
720 } |
819 } |
721 |
820 |
722 if ( $this->is_multisite ) |
821 if ( $this->is_multisite ) { |
723 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
822 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
724 else |
823 } else { |
725 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
824 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
825 } |
726 } |
826 } |
727 |
827 |
728 return compact( 'notice' ); |
828 return compact( 'notice' ); |
729 } |
829 } |
730 |
830 |
731 /** |
831 /** |
732 * |
832 * |
733 */ |
833 */ |
734 public function tab_license() { |
834 public function tab_license() { |
735 global $wp_version, $bstwbsftwppdtplgns_options; ?> |
835 global $wp_version, $bstwbsftwppdtplgns_options; |
736 <h3 class="bws_tab_label"><?php _e( 'License Key', 'bestwebsoft' ); ?></h3> |
836 ?> |
|
837 <h3 class="bws_tab_label"><?php esc_html_e( 'License Key', 'bestwebsoft' ); ?></h3> |
737 <?php $this->help_phrase(); ?> |
838 <?php $this->help_phrase(); ?> |
738 <hr> |
839 <hr> |
739 <?php |
840 <?php |
740 foreach ( $this->licenses as $single_license ) { |
841 foreach ( $this->licenses as $single_license ) { |
741 $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' ' . 'Pro'; |
842 $pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' Pro'; |
742 if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
843 if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
743 |
844 |
744 if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
845 if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
745 $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $this->bws_license_plugin . '&bws_license_key=' . $bstwbsftwppdtplgns_options[ $this->bws_license_plugin ] . '&download_from=5'; ?> |
846 $url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $this->bws_license_plugin . '&bws_license_key=' . $bstwbsftwppdtplgns_options[ $this->bws_license_plugin ] . '&download_from=5'; |
|
847 ?> |
746 <table class="form-table"> |
848 <table class="form-table"> |
747 <tr> |
849 <tr> |
748 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
850 <th scope="row"><?php echo wp_kses_data( $pro_plugin_name ) . ' License'; ?></th> |
749 <td> |
851 <td> |
750 <p> |
852 <p> |
751 <strong><?php _e( 'Your Pro plugin is ready', 'bestwebsoft' ); ?></strong> |
853 <strong><?php esc_html_e( 'Your Pro plugin is ready', 'bestwebsoft' ); ?></strong> |
752 <br> |
854 <br> |
753 <?php _e( 'Your plugin has been zipped, and now is ready to download.', 'bestwebsoft' ); ?> |
855 <?php esc_html_e( 'Your plugin has been zipped, and now is ready to download.', 'bestwebsoft' ); ?> |
754 </p> |
856 </p> |
755 <p> |
857 <p> |
756 <a class="button button-secondary" target="_parent" href="<?php echo esc_url( $url ); ?>"><?php _e( 'Download Now', 'bestwebsoft' ); ?></a> |
858 <a class="button button-secondary" target="_parent" href="<?php echo esc_url( $url ); ?>"><?php esc_html_e( 'Download Now', 'bestwebsoft' ); ?></a> |
757 </p> |
859 </p> |
758 <br> |
860 <br> |
759 <p> |
861 <p> |
760 <strong><?php _e( 'Need help installing the plugin?', 'bestwebsoft' ); ?></strong> |
862 <strong><?php esc_html_e( 'Need help installing the plugin?', 'bestwebsoft' ); ?></strong> |
761 <br> |
863 <br> |
762 <a target="_blank" href="https://docs.google.com/document/d/1-hvn6WRvWnOqj5v5pLUk7Awyu87lq5B_dO-Tv-MC9JQ/"><?php _e( 'How to install WordPress plugin from your admin Dashboard (ZIP archive)', 'bestwebsoft' ); ?></a> |
864 <a target="_blank" href="https://bestwebsoft.com/documentation/how-to-install-a-wordpress-product/how-to-install-a-wordpress-plugin/"><?php esc_html_e( 'How to install WordPress plugin from your admin Dashboard (ZIP archive)', 'bestwebsoft' ); ?></a> |
763 </p> |
865 </p> |
764 <br> |
866 <br> |
765 <p> |
867 <p> |
766 <strong><?php _e( 'Get Started', 'bestwebsoft' ); ?></strong> |
868 <strong><?php esc_html_e( 'Get Started', 'bestwebsoft' ); ?></strong> |
767 <br> |
869 <br> |
768 <a target="_blank" href="https://drive.google.com/drive/u/0/folders/0B5l8lO-CaKt9VGh0a09vUjNFNjA"><?php _e( 'Documentation', 'bestwebsoft' ); ?></a> |
870 <a target="_blank" href="https://bestwebsoft.com/documentation/"><?php esc_html_e( 'Documentation', 'bestwebsoft' ); ?></a> |
769 <br> |
871 <br> |
770 <a target="_blank" href="https://www.youtube.com/user/bestwebsoft"><?php _e( 'Video Instructions', 'bestwebsoft' ); ?></a> |
872 <a target="_blank" href="https://www.youtube.com/user/bestwebsoft"><?php esc_html_e( 'Video Instructions', 'bestwebsoft' ); ?></a> |
771 <br> |
873 <br> |
772 <a target="_blank" href="https://support.bestwebsoft.com"><?php _e( 'Knowledge Base', 'bestwebsoft' ); ?></a> |
874 <a target="_blank" href="https://support.bestwebsoft.com"><?php esc_html_e( 'Knowledge Base', 'bestwebsoft' ); ?></a> |
773 </p> |
875 </p> |
774 </td> |
876 </td> |
775 </tr> |
877 </tr> |
776 </table> |
878 </table> |
777 <?php } else { |
879 <?php |
|
880 } else { |
778 $attr = $license_key = ''; |
881 $attr = $license_key = ''; |
779 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
882 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
780 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
883 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
781 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) |
884 $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
782 $attr = 'disabled="disabled"'; |
885 $attr = 'disabled="disabled"'; |
|
886 } |
783 |
887 |
784 if ( ! empty( $single_license['pro_basename'] ) ) { |
888 if ( ! empty( $single_license['pro_basename'] ) ) { |
785 $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
889 $license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
786 } ?> |
890 } |
787 <table class="form-table"> |
891 ?> |
788 <tr> |
892 <table class="form-table"> |
789 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
893 <tr> |
790 <td> |
894 <th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th> |
791 <input <?php echo $attr; ?> type="text" name="bws_license_key_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
895 <td> |
792 <input <?php echo $attr; ?> type="hidden" name="bws_license_plugin_<?php echo ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug']; ?>" value="<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" /> |
896 <input <?php echo wp_kses_data( $attr ); ?> type="text" name="bws_license_key_<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
793 <input <?php echo $attr; ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
897 <input <?php echo wp_kses_data( $attr ); ?> type="hidden" name="bws_license_plugin_<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" value="<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" /> |
794 <div class="bws_info"> |
898 <input <?php echo wp_kses_data( $attr ); ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Activate', 'bestwebsoft' ); ?>" /> |
795 <?php printf( __( 'Enter your license key to activate %s and get premium plugin features.', 'bestwebsoft' ), '<a href="' . $this->bws_plugin_link . '" target="_blank" title="' . $pro_plugin_name . '">' . $pro_plugin_name . '</a>' ); ?> |
899 <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'bws_license_key_nonce' ); ?>" /> |
796 </div> |
900 <div class="bws_info"> |
797 <?php if ( '' != $attr ) { ?> |
901 <?php printf( esc_html__( 'Enter your license key to activate %s and get premium plugin features.', 'bestwebsoft' ), '<a href="' . esc_url( $this->bws_plugin_link ) . '" target="_blank" title="' . esc_html( $pro_plugin_name ) . '">' . esc_html( $pro_plugin_name ) . '</a>' ); ?> |
798 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> |
902 </div> |
799 <?php } |
903 <?php if ( '' !== $attr ) { ?> |
800 if ( $this->trial_days !== false ) |
904 <p><?php esc_html_e( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' ); ?></p> |
801 echo '<p>' . __( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->plugins_info['PluginURI'] . 'trial/?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank">' . sprintf( __( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), $this->trial_days ) . '</a></p>'; ?> |
905 <?php |
802 </td> |
906 } |
803 </tr> |
907 if ( false !== $this->trial_days ) { |
804 </table> |
908 echo '<p>' . esc_html__( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->plugins_info['PluginURI'] . 'trial/?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ) . '" target="_blank">' . sprintf( esc_html__( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), esc_attr( $this->trial_days ) ) . '</a></p>'; |
805 <?php } |
909 } |
|
910 ?> |
|
911 </td> |
|
912 </tr> |
|
913 </table> |
|
914 <?php |
|
915 } |
806 } else { |
916 } else { |
807 global $bstwbsftwppdtplgns_options; |
917 global $bstwbsftwppdtplgns_options; |
808 $license_key = ( isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) ) ? $bstwbsftwppdtplgns_options[ $single_license['basename'] ] : ''; ?> |
918 $license_key = ( isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) ) ? $bstwbsftwppdtplgns_options[ $single_license['basename'] ] : ''; |
809 <table class="form-table"> |
919 ?> |
810 <tr> |
920 <table class="form-table"> |
811 <th scope="row"><?php echo $pro_plugin_name . ' License'; ?></th> |
921 <tr> |
812 <td> |
922 <th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th> |
813 <input type="text" maxlength="100" name="bws_license_key_<?php echo $single_license['slug']; ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
923 <td> |
814 <input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php _e( 'Check license key', 'bestwebsoft' ); ?>" /> |
924 <input type="text" maxlength="100" name="bws_license_key_<?php echo esc_attr( $single_license['slug'] ); ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
815 <div class="bws_info"> |
925 <input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Check license key', 'bestwebsoft' ); ?>" /> |
816 <?php _e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?> |
926 <div class="bws_info"> |
817 </div> |
927 <?php esc_html_e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?> |
818 </td> |
928 </div> |
819 </tr> |
929 </td> |
820 </table> |
930 </tr> |
821 <?php } |
931 </table> |
822 } ?> |
932 <?php |
823 <table class="form-table"> |
933 } |
824 <tr> |
934 } |
825 <th scope="row"><?php _e( 'Manage License Settings', 'bestwebsoft' ); ?></th> |
935 ?> |
826 <td> |
936 <table class="form-table"> |
827 <a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php _e( 'Login to Client Area', 'bestwebsoft' ); ?></a> |
937 <tr> |
828 <div class="bws_info"> |
938 <th scope="row"><?php esc_html_e( 'Manage License Settings', 'bestwebsoft' ); ?></th> |
829 <?php _e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?> |
939 <td> |
830 </div> |
940 <a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php esc_html_e( 'Login to Client Area', 'bestwebsoft' ); ?></a> |
831 </td> |
941 <div class="bws_info"> |
832 </tr> |
942 <?php esc_html_e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?> |
833 </table> |
943 </div> |
834 <?php } |
944 </td> |
|
945 </tr> |
|
946 </table> |
|
947 <?php |
|
948 } |
835 |
949 |
836 /** |
950 /** |
837 * Save plugin options to the database |
951 * Save plugin options to the database |
|
952 * |
838 * @access private |
953 * @access private |
839 * @param ab |
954 * @param ab |
840 * @return array The action results |
955 * @return array The Action results |
841 */ |
956 */ |
842 private function save_options_license_key() { |
957 private function save_options_license_key() { |
843 global $wp_version, $bstwbsftwppdtplgns_options; |
958 global $wp_version, $bstwbsftwppdtplgns_options, $wp_filesystem; |
844 /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
959 /*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
845 |
960 |
846 $error = $message = $empty_field_error = ''; |
961 $error = $message = $empty_field_error = ''; |
847 |
962 |
848 foreach ( $this->licenses as $single_license) { |
963 if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bws_license_key_nonce' ) ) { |
849 $bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; |
964 die( __( 'Security check', 'bestwebsoft' ) ); |
850 if ( '' != $bws_license_key ) { |
965 } else { |
851 if ( strlen( $bws_license_key ) != 18 ) { |
966 |
852 $error = __( 'Wrong license key', 'bestwebsoft' ); |
967 foreach ( $this->licenses as $single_license ) { |
853 } else { |
968 $bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; |
854 |
969 if ( '' !== $bws_license_key ) { |
855 /* CHECK license key */ |
970 if ( strlen( $bws_license_key ) !== 18 ) { |
856 if ( $this->is_pro && empty( $single_license['pro_basename'] ) ) { |
971 $error = __( 'Wrong license key', 'bestwebsoft' ); |
857 delete_transient( 'bws_plugins_update' ); |
972 } else { |
858 if ( ! $this->all_plugins ) { |
973 /* CHECK license key */ |
859 if ( ! function_exists( 'get_plugins' ) ) { |
974 if ( $this->is_pro && empty( $single_license['pro_basename'] ) ) { |
860 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
975 delete_transient( 'bws_plugins_update' ); |
|
976 if ( ! $this->all_plugins ) { |
|
977 if ( ! function_exists( 'get_plugins' ) ) { |
|
978 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
979 } |
|
980 $this->all_plugins = get_plugins(); |
861 } |
981 } |
862 $this->all_plugins = get_plugins(); |
|
863 } |
|
864 $current = get_site_transient( 'update_plugins' ); |
|
865 |
|
866 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
|
867 $to_send = array(); |
|
868 $to_send["plugins"][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ]; |
|
869 $to_send["plugins"][ $single_license['basename'] ]["bws_license_key"] = $bws_license_key; |
|
870 $to_send["plugins"][ $single_license['basename'] ]["bws_illegal_client"] = true; |
|
871 $options = array( |
|
872 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
|
873 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
874 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
875 ); |
|
876 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
|
877 |
|
878 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
879 $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' ); |
|
880 } else { |
|
881 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
882 if ( is_array( $response ) && ! empty( $response ) ) { |
|
883 foreach ( $response as $single_response ) { |
|
884 if ( "wrong_license_key" == $single_response->package ) { |
|
885 $error = __( 'Wrong license key.', 'bestwebsoft' ); |
|
886 } else if ( "wrong_domain" == $single_response->package ) { |
|
887 $error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
888 } else if ( "time_out" == $single_response->package ) { |
|
889 $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' ); |
|
890 } elseif ( "you_are_banned" == $single_response->package ) { |
|
891 $error = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); |
|
892 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
|
893 $error = __( "Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
|
894 } |
|
895 if ( empty( $error ) ) { |
|
896 if ( empty( $message ) ) { |
|
897 if ( isset( $single_response->trial ) ) { |
|
898 $message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); |
|
899 } else { |
|
900 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
|
901 } |
|
902 |
|
903 if ( ! empty( $single_response->time_out ) ) { |
|
904 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
905 } else { |
|
906 /* lifetime */ |
|
907 $single_response->time_out = NULL; |
|
908 } |
|
909 |
|
910 if ( isset( $single_response->trial ) && $this->is_trial ) { |
|
911 $message .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="' . esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ) . '" target="_blank" title="' . $this->plugins_info["Name"] . '">Pro</a>' ); |
|
912 } |
|
913 } |
|
914 |
|
915 if ( isset( $single_response->trial ) ) { |
|
916 $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1; |
|
917 } else { |
|
918 unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] ); |
|
919 } |
|
920 |
|
921 if ( isset( $single_response->nonprofit ) ) { |
|
922 $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1; |
|
923 } else { |
|
924 unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] ); |
|
925 } |
|
926 |
|
927 if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] != $bws_license_key ) { |
|
928 $bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key; |
|
929 |
|
930 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt", "w+" ); |
|
931 if ( $file ) { |
|
932 @fwrite( $file, $bws_license_key ); |
|
933 @fclose( $file ); |
|
934 } |
|
935 $update_option = true; |
|
936 } |
|
937 |
|
938 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) { |
|
939 unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ); |
|
940 $update_option = true; |
|
941 } |
|
942 |
|
943 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] != $single_response->time_out ) { |
|
944 $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out; |
|
945 $update_option = true; |
|
946 } |
|
947 |
|
948 if ( isset( $update_option ) ) { |
|
949 if ( $this->is_multisite ) { |
|
950 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
951 } else { |
|
952 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
953 } |
|
954 } |
|
955 } |
|
956 } |
|
957 } else { |
|
958 $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' ); |
|
959 } |
|
960 } |
|
961 } |
|
962 /* Go Pro */ |
|
963 } else { |
|
964 |
|
965 $bws_license_plugin = stripslashes( sanitize_text_field( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_plugin_' . $single_license['pro_slug'] : 'bws_license_plugin_' . $single_license['slug'] ] ) ); |
|
966 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
|
967 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
|
968 } else { |
|
969 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
|
970 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
|
971 } |
|
972 |
|
973 /* download Pro */ |
|
974 if ( ! $this->all_plugins ) { |
|
975 if ( ! function_exists( 'get_plugins' ) ) { |
|
976 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
977 } |
|
978 $this->all_plugins = get_plugins(); |
|
979 } |
|
980 |
|
981 if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) { |
|
982 $current = get_site_transient( 'update_plugins' ); |
982 $current = get_site_transient( 'update_plugins' ); |
983 if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
983 |
984 $to_send = array(); |
984 if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
985 $to_send["plugins"][ $bws_license_plugin ] = array(); |
985 $to_send = array(); |
986 $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key; |
986 $to_send['plugins'][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ]; |
987 $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true; |
987 $to_send['plugins'][ $single_license['basename'] ]['bws_license_key'] = $bws_license_key; |
988 $options = array( |
988 $to_send['plugins'][ $single_license['basename'] ]['bws_illegal_client'] = true; |
|
989 $options = array( |
989 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
990 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
990 'body' => array( 'plugins' => serialize( $to_send ) ), |
991 'body' => array( 'plugins' => serialize( $to_send ) ), |
991 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
992 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
992 ); |
993 ); |
993 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
994 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
994 |
995 |
995 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
996 if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
996 $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' ); |
997 $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' ); |
997 } else { |
998 } else { |
998 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
999 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
999 if ( is_array( $response ) && ! empty( $response ) ) { |
1000 if ( is_array( $response ) && ! empty( $response ) ) { |
1000 foreach ( $response as $single_response ) { |
1001 foreach ( $response as $single_response ) { |
1001 if ( "wrong_license_key" == $single_response->package ) { |
1002 if ( 'wrong_license_key' === $single_response->package ) { |
1002 $error = __( "Wrong license key.", 'bestwebsoft' ); |
1003 $error = __( 'Wrong license key.', 'bestwebsoft' ); |
1003 } elseif ( "wrong_domain" == $single_response->package ) { |
1004 } elseif ( 'wrong_domain' === $single_response->package ) { |
1004 $error = __( "This license key is bound to another site.", 'bestwebsoft' ); |
1005 $error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
1005 } elseif ( "you_are_banned" == $single_response->package ) { |
1006 } elseif ( 'time_out' === $single_response->package ) { |
1006 $error = __( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); |
1007 $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' ); |
1007 } elseif ( "time_out" == $single_response->package ) { |
1008 } elseif ( 'you_are_banned' === $single_response->package ) { |
1008 $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>' ); |
1009 $error = __( 'Unfortunately, you have exceeded the number of available tries.', 'bestwebsoft' ); |
1009 } elseif ( "duplicate_domen_for_trial" == $single_response->package ) { |
1010 } elseif ( 'duplicate_domen_for_trial' === $single_response->package ) { |
1010 $error = __( "Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.", 'bestwebsoft' ); |
1011 $error = __( 'Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' ); |
|
1012 } |
|
1013 if ( empty( $error ) ) { |
|
1014 if ( empty( $message ) ) { |
|
1015 if ( isset( $single_response->trial ) ) { |
|
1016 $message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); |
|
1017 } else { |
|
1018 $message = __( 'The license key is valid.', 'bestwebsoft' ); |
|
1019 } |
|
1020 |
|
1021 if ( ! empty( $single_response->time_out ) ) { |
|
1022 $message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
1023 } else { |
|
1024 /* lifetime */ |
|
1025 $single_response->time_out = null; |
|
1026 } |
|
1027 |
|
1028 if ( isset( $single_response->trial ) && $this->is_trial ) { |
|
1029 $message .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="' . esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ) . '" target="_blank" title="' . $this->plugins_info['Name'] . '">Pro</a>' ); |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 if ( isset( $single_response->trial ) ) { |
|
1034 $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1; |
|
1035 } else { |
|
1036 unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] ); |
|
1037 } |
|
1038 |
|
1039 if ( isset( $single_response->nonprofit ) ) { |
|
1040 $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1; |
|
1041 } else { |
|
1042 unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] ); |
|
1043 } |
|
1044 |
|
1045 if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] !== $bws_license_key ) { |
|
1046 $bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key; |
|
1047 |
|
1048 WP_Filesystem(); |
|
1049 if ( $wp_filesystem->put_contents( dirname( dirname( __FILE__ ) ) . '/license_key.txt', $bws_license_key, 0755 ) ) { |
|
1050 $update_option = true; |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) { |
|
1055 unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ); |
|
1056 $update_option = true; |
|
1057 } |
|
1058 |
|
1059 if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] !== $single_response->time_out ) { |
|
1060 $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out; |
|
1061 $update_option = true; |
|
1062 } |
|
1063 |
|
1064 if ( isset( $update_option ) ) { |
|
1065 if ( $this->is_multisite ) { |
|
1066 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1067 } else { |
|
1068 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1069 } |
|
1070 } |
1011 } |
1071 } |
1012 } |
1072 } |
1013 if ( empty( $error ) ) { |
|
1014 $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
|
1015 |
|
1016 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1017 $this->pro_plugin_is_activated = true; |
|
1018 } |
|
1019 } else { |
1073 } else { |
1020 $error = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
1074 $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' ); |
1021 } |
1075 } |
1022 } |
1076 } |
1023 } |
1077 } |
|
1078 /* Go Pro */ |
1024 } else { |
1079 } else { |
1025 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
1080 $slug = ! empty( $single_license['pro_slug'] ) ? 'bws_license_plugin_' . $single_license['pro_slug'] : 'bws_license_plugin_' . $single_license['slug']; |
1026 /* activate Pro */ |
1081 $bws_license_plugin = isset( $_POST[ $slug ] ) ? sanitize_text_field( wp_unslash( $_POST[ $slug ] ) ) : ''; |
1027 if ( ! is_plugin_active( $bws_license_plugin ) ) { |
1082 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
1028 if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { |
1083 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
1029 /* if multisite and free plugin is network activated */ |
1084 } else { |
1030 $network_wide = true; |
1085 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
1031 } else { |
1086 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
1032 /* activate on a single blog */ |
1087 } |
1033 $network_wide = false; |
1088 |
|
1089 /* download Pro */ |
|
1090 if ( ! $this->all_plugins ) { |
|
1091 if ( ! function_exists( 'get_plugins' ) ) { |
|
1092 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
1034 } |
1093 } |
1035 activate_plugin( $bws_license_plugin, null, $network_wide ); |
1094 $this->all_plugins = get_plugins(); |
1036 $this->pro_plugin_is_activated = true; |
1095 } |
|
1096 |
|
1097 if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) { |
|
1098 $current = get_site_transient( 'update_plugins' ); |
|
1099 if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
|
1100 $to_send = array(); |
|
1101 $to_send['plugins'][ $bws_license_plugin ] = array(); |
|
1102 $to_send['plugins'][ $bws_license_plugin ]['bws_license_key'] = $bws_license_key; |
|
1103 $to_send['plugins'][ $bws_license_plugin ]['bws_illegal_client'] = true; |
|
1104 $options = array( |
|
1105 'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
|
1106 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
1107 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
|
1108 ); |
|
1109 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
|
1110 |
|
1111 if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
|
1112 $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' ); |
|
1113 } else { |
|
1114 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
1115 if ( is_array( $response ) && ! empty( $response ) ) { |
|
1116 foreach ( $response as $single_response ) { |
|
1117 if ( 'wrong_license_key' === $single_response->package ) { |
|
1118 $error = __( 'Wrong license key.', 'bestwebsoft' ); |
|
1119 } elseif ( 'wrong_domain' === $single_response->package ) { |
|
1120 $error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
1121 } elseif ( 'you_are_banned' === $single_response->package ) { |
|
1122 $error = __( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' ); |
|
1123 } elseif ( 'time_out' === $single_response->package ) { |
|
1124 $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>' ); |
|
1125 } elseif ( 'duplicate_domen_for_trial' === $single_response->package ) { |
|
1126 $error = __( 'Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' ); |
|
1127 } |
|
1128 } |
|
1129 if ( empty( $error ) ) { |
|
1130 $bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
|
1131 |
|
1132 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1133 $this->pro_plugin_is_activated = true; |
|
1134 } |
|
1135 } else { |
|
1136 $error = __( 'Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.', 'bestwebsoft' ); |
|
1137 } |
|
1138 } |
|
1139 } |
|
1140 } else { |
|
1141 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1142 /* activate Pro */ |
|
1143 if ( ! is_plugin_active( $bws_license_plugin ) ) { |
|
1144 if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { |
|
1145 /* if multisite and free plugin is network activated */ |
|
1146 $network_wide = true; |
|
1147 } else { |
|
1148 /* activate on a single blog */ |
|
1149 $network_wide = false; |
|
1150 } |
|
1151 activate_plugin( $bws_license_plugin, null, $network_wide ); |
|
1152 $this->pro_plugin_is_activated = true; |
|
1153 } |
|
1154 } |
|
1155 /* add 'track_usage' for Pro version */ |
|
1156 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) && |
|
1157 empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) { |
|
1158 $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; |
|
1159 } |
|
1160 |
|
1161 if ( $this->is_multisite ) { |
|
1162 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1163 } else { |
|
1164 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1165 } |
|
1166 |
|
1167 if ( $this->pro_plugin_is_activated ) { |
|
1168 delete_transient( 'bws_plugins_update' ); |
1037 } |
1169 } |
1038 } |
1170 } |
1039 /* add 'track_usage' for Pro version */ |
|
1040 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) && |
|
1041 empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) { |
|
1042 $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; |
|
1043 } |
|
1044 |
|
1045 if ( $this->is_multisite ) { |
|
1046 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1047 } else { |
|
1048 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1049 } |
|
1050 |
|
1051 if ( $this->pro_plugin_is_activated ) { |
|
1052 delete_transient( 'bws_plugins_update' ); |
|
1053 } |
|
1054 } |
1171 } |
1055 } |
1172 } else { |
1056 } else { |
1173 $empty_field_error = __( 'Please, enter Your license key', 'bestwebsoft' ); |
1057 $empty_field_error = __( "Please, enter Your license key", 'bestwebsoft' ); |
1174 } |
1058 } |
1175 } |
1059 } |
1176 } |
1060 return compact( 'error', 'message', 'empty_field_error' ); |
1177 return compact( 'error', 'message', 'empty_field_error' ); |
1061 } |
1178 } |
1062 |
1179 |
1063 /** |
1180 /** |
1064 * Display help phrase |
1181 * Display help phrase |
|
1182 * |
1065 * @access public |
1183 * @access public |
1066 * @param void |
1184 * @param void |
1067 * @return array The action results |
1185 * @return html The Action results |
1068 */ |
1186 */ |
1069 public function help_phrase() { |
1187 public function help_phrase() { |
1070 echo '<div class="bws_tab_description">' . __( 'Need Help?', 'bestwebsoft' ) . ' '; |
1188 /*pls */ |
1071 if ( '' != $this->doc_link ) |
1189 echo '<div class="bws_tab_description">' . esc_html__( 'Need Help?', 'bestwebsoft' ) . ' '; |
1072 echo '<a href="' . esc_url( $this->doc_link ) . '" target="_blank">' . __( 'Read the Instruction', 'bestwebsoft' ); |
1190 if ( '' !== $this->doc_link ) { |
1073 else |
1191 echo '<a href="' . esc_url( $this->doc_link ) . '" target="_blank">' . esc_html__( 'Read the Instruction', 'bestwebsoft' ); |
1074 echo '<a href="https://support.bestwebsoft.com/hc/en-us/" target="_blank">' . __( 'Visit Help Center', 'bestwebsoft' ); |
1192 } else { |
1075 if ( '' != $this->doc_video_link ) |
1193 echo '<a href="https://support.bestwebsoft.com/hc/en-us/" target="_blank">' . esc_html__( 'Visit Help Center', 'bestwebsoft' ); |
1076 echo '</a>' . ' ' . __( 'or', 'bestwebsoft' ) . ' ' . '<a href="' . esc_url( $this->doc_video_link ) . '" target="_blank">' . __( 'Watch the Video', 'bestwebsoft' ); |
1194 } |
|
1195 if ( '' !== $this->doc_video_link ) { |
|
1196 echo '</a> ' . esc_html__( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->doc_video_link ) . '" target="_blank">' . esc_html__( 'Watch the Video', 'bestwebsoft' ); |
|
1197 } |
1077 echo '</a></div>'; |
1198 echo '</a></div>'; |
|
1199 /* pls*/ |
1078 } |
1200 } |
1079 |
1201 |
1080 public function bws_pro_block_links() { |
1202 public function bws_pro_block_links() { |
1081 global $wp_version; ?> |
1203 global $wp_version; |
1082 <div class="bws_pro_version_tooltip"> |
1204 ?> |
1083 <a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo $this->link_key; ?>&pn=<?php echo $this->link_pn; ?>&v=<?php echo $this->plugins_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="<?php echo $this->plugins_info["Name"]; ?>"><?php _e( 'Upgrade to Pro', 'bestwebsoft' ); ?></a> |
1205 <div class="bws_pro_version_tooltip"> |
1084 <?php if ( $this->trial_days !== false ) { ?> |
1206 <a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>"><?php esc_html_e( 'Upgrade to Pro', 'bestwebsoft' ); ?></a> |
1085 <span class="bws_trial_info"> |
1207 <?php if ( false !== $this->trial_days ) { ?> |
1086 <?php _e( 'or', 'bestwebsoft' ); ?> |
1208 <span class="bws_trial_info"> |
1087 <a href="<?php echo esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info["Version"] . '&wp_v=' . $wp_version ); ?>" target="_blank" title="<?php echo $this->plugins_info["Name"]; ?>"><?php _e( 'Start Your Free Trial', 'bestwebsoft' ); ?></a> |
1209 <?php esc_html_e( 'or', 'bestwebsoft' ); ?> |
|
1210 <a href="<?php echo esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>"><?php esc_html_e( 'Start Your Free Trial', 'bestwebsoft' ); ?></a> |
1088 </span> |
1211 </span> |
1089 <?php } ?> |
1212 <?php } ?> |
1090 <div class="clear"></div> |
1213 <div class="clear"></div> |
1091 </div> |
1214 </div> |
1092 <?php } |
1215 <?php |
|
1216 } |
1093 |
1217 |
1094 /** |
1218 /** |
1095 * Restore plugin options to defaults |
1219 * Restore plugin options to defaults |
|
1220 * |
1096 * @access public |
1221 * @access public |
1097 * @param void |
1222 * @param void |
1098 * @return void |
1223 * @return void |
1099 */ |
1224 */ |
1100 public function restore_options() { |
1225 public function restore_options() { |