: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$to_send['plugins'][ $single_license['basename'] ]['bws_license_key'] = $bws_license_key;
$to_send['plugins'][ $single_license['basename'] ]['bws_illegal_client'] = true;
'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ),
'body' => array( 'plugins' => serialize( $to_send ) ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options );
if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) {
$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' );
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
if ( is_array( $response ) && ! empty( $response ) ) {
foreach ( $response as $single_response ) {
if ( 'wrong_license_key' === $single_response->package ) {
$error = __( 'Wrong license key.', 'bestwebsoft' );
} elseif ( 'wrong_domain' === $single_response->package ) {
$error = __( 'This license key is bound to another site.', 'bestwebsoft' );
} elseif ( 'time_out' === $single_response->package ) {
$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' );
} elseif ( 'you_are_banned' === $single_response->package ) {
$error = __( 'Unfortunately, you have exceeded the number of available tries.', 'bestwebsoft' );
} elseif ( 'duplicate_domen_for_trial' === $single_response->package ) {
$error = __( 'Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' );
if ( empty( $message ) ) {
if ( isset( $single_response->trial ) ) {
$message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' );
$message = __( 'The license key is valid.', 'bestwebsoft' );
if ( ! empty( $single_response->time_out ) ) {
$message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.';
$single_response->time_out = null;
if ( isset( $single_response->trial ) && $this->is_trial ) {
$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>' );
if ( isset( $single_response->trial ) ) {
$bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1;
unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] );
if ( isset( $single_response->nonprofit ) ) {
$bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1;
unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] );
if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] !== $bws_license_key ) {
$bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key;
if ( $wp_filesystem->put_contents( dirname( dirname( __FILE__ ) ) . '/license_key.txt', $bws_license_key, 0755 ) ) {
if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) {
unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] );
if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] !== $single_response->time_out ) {
$bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out;
if ( isset( $update_option ) ) {
if ( $this->is_multisite ) {
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
$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' );
$slug = ! empty( $single_license['pro_slug'] ) ? 'bws_license_plugin_' . $single_license['pro_slug'] : 'bws_license_plugin_' . $single_license['slug'];
$bws_license_plugin = isset( $_POST[ $slug ] ) ? sanitize_text_field( wp_unslash( $_POST[ $slug ] ) ) : '';
if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) {
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1;
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1;
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time();
if ( ! $this->all_plugins ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$this->all_plugins = get_plugins();
if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) {
$current = get_site_transient( 'update_plugins' );
if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) {
$to_send['plugins'][ $bws_license_plugin ] = array();
$to_send['plugins'][ $bws_license_plugin ]['bws_license_key'] = $bws_license_key;
$to_send['plugins'][ $bws_license_plugin ]['bws_illegal_client'] = true;
'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ),
'body' => array( 'plugins' => serialize( $to_send ) ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options );
if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) {
$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' );
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
if ( is_array( $response ) && ! empty( $response ) ) {
foreach ( $response as $single_response ) {
if ( 'wrong_license_key' === $single_response->package ) {
$error = __( 'Wrong license key.', 'bestwebsoft' );
} elseif ( 'wrong_domain' === $single_response->package ) {
$error = __( 'This license key is bound to another site.', 'bestwebsoft' );
} elseif ( 'you_are_banned' === $single_response->package ) {
$error = __( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' );
} elseif ( 'time_out' === $single_response->package ) {
$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>' );
} elseif ( 'duplicate_domen_for_trial' === $single_response->package ) {
$error = __( 'Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' );
$bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'];
$bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key;
$this->pro_plugin_is_activated = true;
$error = __( 'Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.', 'bestwebsoft' );
$bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key;
if ( ! is_plugin_active( $bws_license_plugin ) ) {
if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) {
/* if multisite and free plugin is network activated */
/* activate on a single blog */
activate_plugin( $bws_license_plugin, null, $network_wide );
$this->pro_plugin_is_activated = true;
/* add 'track_usage' for Pro version */
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) &&
empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) {
$bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ];
if ( $this->is_multisite ) {
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
if ( $this->pro_plugin_is_activated ) {
delete_transient( 'bws_plugins_update' );
$empty_field_error = __( 'Please, enter Your license key', 'bestwebsoft' );
return compact( 'error', 'message', 'empty_field_error' );
* @echo html The Action results
public function help_phrase() {
echo '<div class="bws_tab_description">' . esc_html__( 'Need Help?', 'bestwebsoft' ) . ' ';
if ( '' !== $this->doc_link ) {
echo '<a href="' . esc_url( $this->doc_link ) . '" target="_blank">' . esc_html__( 'Read the Instruction', 'bestwebsoft' );
echo '<a href="https://support.bestwebsoft.com/hc/en-us/" target="_blank">' . esc_html__( 'Visit Help Center', 'bestwebsoft' );
if ( '' !== $this->doc_video_link ) {
echo '</a> ' . esc_html__( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->doc_video_link ) . '" target="_blank">' . esc_html__( 'Watch the Video', 'bestwebsoft' );
public function bws_pro_block_links() {
<div class="bws_pro_version_tooltip">
<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>
<?php if ( false !== $this->trial_days ) { ?>
<span class="bws_trial_info">
<?php esc_html_e( 'or', 'bestwebsoft' ); ?>
<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>
<div class="clear"></div>
* Restore plugin options to defaults
public function restore_options() {
$this->default_options['first_install'],
$this->default_options['suggest_feature_banner'],
$this->default_options['display_settings_notice']
* Filter - Change default_options array OR process custom functions
$this->options = apply_filters( __CLASS__ . '_additional_restore_options', $this->default_options );
if ( $this->is_network_options ) {
$this->options['network_apply'] = 'default';
$this->options['network_view'] = '1';
$this->options['network_change'] = '1';
update_site_option( $this->prefix . '_options', $this->options );
update_option( $this->prefix . '_options', $this->options );
public function add_request_feature() {
<div id="bws_request_feature" class="widget-access-link">
<button type="button" class="button" ><?php esc_html_e( 'Request a Feature', 'bestwebsoft' ); ?></button>
$modal_html = '<div class="bws-modal bws-modal-deactivation-feedback bws-modal-request-feature">
<div class="bws-modal-dialog">
<div class="bws-modal-body">
<h2>' . sprintf( esc_html__( 'How can we improve %s?', 'bestwebsoft' ), $this->plugins_info['Name'] ) . '</h2>
<div class="bws-modal-panel active">
<p>' . esc_html__( 'We look forward to hear your ideas.', 'bestwebsoft' ) . '</p>
<textarea placeholder="' . esc_html__( 'Describe your idea', 'bestwebsoft' ) . '..."></textarea>
<label class="bws-modal-anonymous-label">
<input type="checkbox" /> ' . esc_html__( 'Send website data and allow to contact me back', 'bestwebsoft' ) . '
<div class="bws-modal-footer">
<a href="#" class="button disabled bws-modal-button button-primary">' . esc_html__( 'Submit', 'bestwebsoft' ) . '</a>
<span class="bws-modal-processing hidden">' . esc_html__( 'Processing', 'bestwebsoft' ) . '...</span>
<span class="bws-modal-thank-you hidden">' . esc_html__( 'Thank you!', 'bestwebsoft' ) . '</span>
<div class="clear"></div>
$script = '(function($) {
var modalHtml = ' . wp_json_encode( $modal_html ) . ",
\$modal = $( modalHtml );
\$modal.appendTo( $( 'body' ) );
$( '#bws_request_feature .button' ).on( 'click', function() {
/* Display the dialog box.*/
\$modal.addClass( 'active' );
$( 'body' ).addClass( 'has-bws-modal' );
\$modal.on( 'keypress', 'textarea', function( evt ) {
\$modal.on( 'click', '.bws-modal-footer .button', function( evt ) {
if ( $( this ).hasClass( 'disabled' ) ) {
var info = \$modal.find( 'textarea' ).val();
if ( info.length == 0 ) {
var _parent = $( this ).parents( '.bws-modal:first' ),
var is_anonymous = ( \$modal.find( '.bws-modal-anonymous-label' ).find( 'input' ).is( ':checked' ) ) ? 0 : 1;
'Action' : 'bws_submit_request_feature_action',
'plugin' : '" . $this->plugin_basename . "',
'is_anonymous' : is_anonymous,
'bws_ajax_nonce' : '" . wp_create_nonce( 'bws_ajax_nonce' ) . "'
_parent.find( '.bws-modal-footer .bws-modal-button' ).hide();
_parent.find( '.bws-modal-footer .bws-modal-processing' ).show();
_parent.find( 'textarea, input' ).attr( 'disabled', 'disabled' );
complete : function( message ) {
_parent.find( '.bws-modal-footer .bws-modal-processing' ).hide();
_parent.find( '.bws-modal-footer .bws-modal-thank-you' ).show();
/* If the user has clicked outside the window, cancel it. */
\$modal.on( 'click', function( evt ) {
var \$target = $( evt.target );
/* If the user has clicked anywhere in the modal dialog, just return. */
if ( \$target.hasClass( 'bws-modal-body' ) || \$target.hasClass( 'bws-modal-footer' ) ) {
/* If the user has not clicked the close button and the clicked element is inside the modal dialog, just return. */
if ( ! \$target.hasClass( 'bws-modal-button-close' ) && ( \$target.parents( '.bws-modal-body' ).length > 0 || \$target.parents( '.bws-modal-footer' ).length > 0 ) ) {
/* Close the modal dialog */
\$modal.removeClass( 'active' );
$( 'body' ).removeClass( 'has-bws-modal' );
function BwsModalEnableButton() {
\$modal.find( '.bws-modal-button' ).removeClass( 'disabled' ).show();
\$modal.find( '.bws-modal-processing' ).hide();
function BwsModalDisableButton() {
\$modal.find( '.bws-modal-button' ).addClass( 'disabled' );
function BwsModalShowPanel() {
\$modal.find( '.bws-modal-panel' ).addClass( 'active' );
/* add script in FOOTER */
wp_register_script( 'bws-request-feature-dialog', '', array( 'jquery' ), '2.4.2', true );
wp_enqueue_script( 'bws-request-feature-dialog' );
wp_add_inline_script( 'bws-request-feature-dialog', sprintf( $script ) );
if ( ! function_exists( 'bws_submit_request_feature_action' ) ) {
* Called after the user has submitted his reason for deactivating the plugin.
function bws_submit_request_feature_action() {
global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user;
if ( isset( $_REQUEST['bws_ajax_nonce'] ) ) {
check_ajax_referer( 'bws_ajax_nonce', sanitize_text_field( wp_unslash( $_REQUEST['bws_ajax_nonce'] ) ) );
$basename = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : '';
$info = isset( $_REQUEST['info'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['info'] ) ) : '';
if ( empty( $info ) || empty( $basename ) ) {
$info = substr( $info, 0, 255 );
$is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 === intval( $_REQUEST['is_anonymous'] );
if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
$bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) {
$options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id'];
$options['usage_id'] = false;
$options['url'] = get_bloginfo( 'url' );
$options['wp_version'] = $wp_version;
$options['is_active'] = false;
$options['version'] = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version'];
$options['email'] = $current_user->data->user_email;
$raw_response = wp_remote_post(
'https://bestwebsoft.com/wp-content/plugins/products-statistics/request-feature/',
if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) {
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] !== $options['usage_id'] ) {
$bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id'];
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
echo wp_kses_data( $response->get_error_code() ) . ': ' . wp_kses_data( $response->get_error_message() );
add_action( 'wp_ajax_bws_submit_request_feature_action', 'bws_submit_request_feature_action' );