: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( $this->is_multisite ) {
$this->custom_code_args['blog_id'] = get_current_blog_id();
foreach ( array( 'css', 'php', 'js' ) as $extension ) {
$file = 'bws-custom-code.' . $extension;
$real_file = $folder . '/' . $file;
if ( $wp_filesystem->exists( $real_file ) ) {
update_recently_edited( $real_file );
$this->custom_code_args[ "content_{$extension}" ] = $wp_filesystem->get_contents( $real_file );
if ( ( $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ) ) ||
( ! $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ) ) ) {
$this->custom_code_args[ "is_{$extension}_active" ] = true;
if ( is_writeable( $real_file ) ) {
$this->custom_code_args[ "{$extension}_writeable" ] = true;
$this->custom_code_args[ "{$extension}_writeable" ] = true;
if ( 'php' === $extension ) {
$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";
* Display 'custom_code' tab
private function tab_custom_code() {
global $bstwbsftwppdtplgns_options, $wp_version;
<h3 class="bws_tab_label"><?php esc_html_e( 'Custom Code', 'bestwebsoft' ); ?></h3>
$bws_hide_premium = bws_hide_premium_options_check( $bstwbsftwppdtplgns_options );
<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>
if ( ! $bws_hide_premium ) {
<div class="bws_pro_version_bloc pdfprnt-pro-feature">
<div class="bws_pro_version_table_bloc">
<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="Close"></button>
<div class="bws_table_bg"></div>
<div class="bws_pro_version">
if ( ! current_user_can( 'edit_plugins' ) ) {
echo '<p>' . esc_html__( 'You do not have sufficient permissions to edit plugins for this site.', 'bestwebsoft' ) . '</p>';
'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ),
'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started',
'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>' ),
'learn_more_link' => 'https://php.net/',
'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ),
'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript',
foreach ( $list as $extension => $extension_data ) {
$name = 'js' === $extension ? 'JavaScript' : strtoupper( $extension );
<strong><?php echo esc_html( $name ); ?></strong>
if ( ! $this->custom_code_args[ "{$extension}_writeable" ] ) {
echo '(' . esc_html__( 'Browsing', 'bestwebsoft' ) . ')';
<input type="checkbox" value="1"
if ( $this->custom_code_args[ "is_{$extension}_active" ] ) {
<?php printf( esc_html__( 'Activate custom %s code.', 'bestwebsoft' ), esc_html( $name ) ); ?>
<textarea cols="70" rows="25" id="bws_newcontent_<?php echo esc_attr( $extension ); ?>" disabled="disabled"><?php
if ( isset( $this->custom_code_args[ "content_{$extension}" ] ) ) {
echo esc_html( stripslashes_deep( $this->custom_code_args[ "content_{$extension}" ] ) ); }
<?php echo wp_kses_post( $extension_data['description'] ); ?>
<a href="<?php echo esc_url( $extension_data['learn_more_link'] ); ?>" target="_blank">
<?php printf( esc_html__( 'Learn more about %s', 'bestwebsoft' ), esc_html( $name ) ); ?>
<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'] ); ?>">Upgrade to Pro</a>
<div class="clear"></div>
<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'] ); ?>">Upgrade to Pro</a>
<div class="clear"></div>
private function tab_misc() {
global $bstwbsftwppdtplgns_options;
<h3 class="bws_tab_label"><?php esc_html_e( 'Miscellaneous Settings', 'bestwebsoft' ); ?></h3>
<?php $this->help_phrase(); ?>
* Action - Display custom options on the Import / Export' tab
do_action( __CLASS__ . '_additional_misc_options' );
if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) {
<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>
if ( $this->forbid_view ) {
<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>
<table class="form-table">
* Action - Display custom options on the 'misc' tab
do_action( __CLASS__ . '_additional_misc_options_affected' );
if ( ! empty( $this->pro_page ) && $this->bws_hide_pro_option_exist ) {
<th scope="row"><?php esc_html_e( 'Pro Options', 'bestwebsoft' ); ?></th>
<input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_hide_premium_options_submit" type="checkbox" value="1"
if ( ! $this->hide_pro_tabs ) {
echo 'checked="checked "';
<span class="bws_info"><?php esc_html_e( 'Enable to display plugin Pro options.', 'bestwebsoft' ); ?></span>
<th scope="row"><?php esc_html_e( 'Track Usage', 'bestwebsoft' ); ?></th>
<input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_track_usage" type="checkbox" value="1"
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) {
echo 'checked="checked "';
<span class="bws_info"><?php esc_html_e( 'Enable to allow tracking plugin usage anonymously in order to make it better.', 'bestwebsoft' ); ?></span>
<th scope="row"><?php esc_html_e( 'Default Settings', 'bestwebsoft' ); ?></th>
<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' ); ?>" />
<div class="bws_info"><?php esc_html_e( 'This will restore plugin settings to defaults.', 'bestwebsoft' ); ?></div>
* Display 'Import / Export' tab
public function tab_import_export() {
<h3 class="bws_tab_label"><?php esc_html_e( 'Import / Export', 'bestwebsoft' ); ?></h3>
<?php $this->help_phrase(); ?>
* Action - Display custom options on the Import / Export' tab
do_action( __CLASS__ . '_additional_import_export_options' );
if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) {
<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>
if ( $this->forbid_view ) {
<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>
<table class="form-table">
* Action - Display custom options on the Import / Export' tab
do_action( __CLASS__ . '_additional_import_export_options_affected' );
* Save plugin options to the database
private function save_options_misc() {
global $bstwbsftwppdtplgns_options, $wp_version;
/* hide premium options */
if ( ! empty( $this->pro_page ) ) {
if ( isset( $_POST['bws_hide_premium_options'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
$hide_result = bws_hide_premium_options( $this->options );
$this->hide_pro_tabs = true;
$this->options = $hide_result['options'];
if ( ! empty( $hide_result['message'] ) ) {
$notice = $hide_result['message'];
if ( $this->is_network_options ) {
update_site_option( $this->prefix . '_options', $this->options );
update_option( $this->prefix . '_options', $this->options );
} elseif ( isset( $_POST['bws_hide_premium_options_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
if ( ! empty( $this->options['hide_premium_options'] ) ) {
$key = array_search( get_current_user_id(), $this->options['hide_premium_options'] );
unset( $this->options['hide_premium_options'][ $key ] );
if ( $this->is_network_options ) {
update_site_option( $this->prefix . '_options', $this->options );
update_option( $this->prefix . '_options', $this->options );
$this->hide_pro_tabs = false;
if ( empty( $this->options['hide_premium_options'] ) ) {
$this->options['hide_premium_options'][] = get_current_user_id();
if ( $this->is_network_options ) {
update_site_option( $this->prefix . '_options', $this->options );
update_option( $this->prefix . '_options', $this->options );
$this->hide_pro_tabs = true;
/* Save 'Track Usage' option */
if ( isset( $_POST['bws_track_usage'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
if ( empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) {
$bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] = true;
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) {
unset( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] );
if ( isset( $track_usage ) ) {
$usage_id = ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ? $bstwbsftwppdtplgns_options['track_usage']['usage_id'] : false;
'url' => get_bloginfo( 'url' ),
'wp_version' => $wp_version,
'is_active' => $track_usage,
'product' => $this->plugin_basename,
'version' => $this->plugins_info['Version'],
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options );
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'] !== $usage_id ) {
$bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id'];
if ( $this->is_multisite ) {
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
return compact( 'notice' );
public function tab_license() {
global $wp_version, $bstwbsftwppdtplgns_options;
<h3 class="bws_tab_label"><?php esc_html_e( 'License Key', 'bestwebsoft' ); ?></h3>
<?php $this->help_phrase(); ?>
foreach ( $this->licenses as $single_license ) {
$pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' Pro';
if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) {
if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) {
$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';
<table class="form-table">
<th scope="row"><?php echo wp_kses_data( $pro_plugin_name ) . ' License'; ?></th>
<strong><?php esc_html_e( 'Your Pro plugin is ready', 'bestwebsoft' ); ?></strong>
<?php esc_html_e( 'Your plugin has been zipped, and now is ready to download.', 'bestwebsoft' ); ?>
<a class="button button-secondary" target="_parent" href="<?php echo esc_url( $url ); ?>"><?php esc_html_e( 'Download Now', 'bestwebsoft' ); ?></a>
<strong><?php esc_html_e( 'Need help installing the plugin?', 'bestwebsoft' ); ?></strong>
<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>
<strong><?php esc_html_e( 'Get Started', 'bestwebsoft' ); ?></strong>
<a target="_blank" href="https://bestwebsoft.com/documentation/"><?php esc_html_e( 'Documentation', 'bestwebsoft' ); ?></a>
<a target="_blank" href="https://www.youtube.com/user/bestwebsoft"><?php esc_html_e( 'Video Instructions', 'bestwebsoft' ); ?></a>
<a target="_blank" href="https://support.bestwebsoft.com"><?php esc_html_e( 'Knowledge Base', 'bestwebsoft' ); ?></a>
if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) &&
'5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] &&
$bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) {
$attr = 'disabled="disabled"';
if ( ! empty( $single_license['pro_basename'] ) ) {
$license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : '';
<table class="form-table">
<th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th>
<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 ); ?>" />
<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'] ); ?>" />
<input <?php echo wp_kses_data( $attr ); ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Activate', 'bestwebsoft' ); ?>" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'bws_license_key_nonce' ) ); ?>" />
<?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>' ); ?>
<?php if ( '' !== $attr ) { ?>
<p><?php esc_html_e( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' ); ?></p>
if ( false !== $this->trial_days ) {
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>';
global $bstwbsftwppdtplgns_options;
$license_key = ( isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) ) ? $bstwbsftwppdtplgns_options[ $single_license['basename'] ] : '';
<table class="form-table">
<th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th>
<input type="text" maxlength="100" name="bws_license_key_<?php echo esc_attr( $single_license['slug'] ); ?>" value="<?php echo esc_attr( $license_key ); ?>" />
<input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Check license key', 'bestwebsoft' ); ?>" />
<?php esc_html_e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?>
<table class="form-table">
<th scope="row"><?php esc_html_e( 'Manage License Settings', 'bestwebsoft' ); ?></th>
<a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php esc_html_e( 'Login to Client Area', 'bestwebsoft' ); ?></a>
<?php esc_html_e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?>
* Save plugin options to the database
* @return array The Action results
private function save_options_license_key() {
global $wp_version, $bstwbsftwppdtplgns_options, $wp_filesystem;
/*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bws_license_key_nonce' ) ) {
die( esc_html__( 'Security check', 'bestwebsoft' ) );
foreach ( $this->licenses as $single_license ) {
$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'] ] ) ) : '';
if ( '' !== $bws_license_key ) {
if ( strlen( $bws_license_key ) !== 18 ) {
$error = __( 'Wrong license key', 'bestwebsoft' );
if ( $this->is_pro && empty( $single_license['pro_basename'] ) ) {
delete_transient( 'bws_plugins_update' );
if ( ! $this->all_plugins ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$this->all_plugins = get_plugins();
$current = get_site_transient( 'update_plugins' );
if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) {
$to_send['plugins'][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ];