: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! defined( 'ABSPATH' ) ) {
* Displays the content on the plugin settings page
if ( ! class_exists( 'Bws_Settings_Tabs' ) ) {
class Bws_Settings_Tabs {
private $pro_plugin_is_activated = false;
private $custom_code_args = array();
private $bws_plugin_link = '';
public $is_network_options;
public $plugins_info = array();
public $hide_pro_tabs = false;
public $bws_license_plugin;
public $is_trial = false;
public $bws_hide_pro_option_exist = true;
public $forbid_view = false;
public $change_permission_attr = '';
* The child class should call this constructor from its own constructor to override
* @param array|string $args
public function __construct( $args = array() ) {
'plugins_info' => array(),
'default_options' => array(),
'is_network_options' => false,
/* if this is free version and pro exist */
$args['plugins_info']['Name'] = str_replace( ' by BestWebSoft', '', $args['plugins_info']['Name'] );
$this->plugin_basename = $args['plugin_basename'];
$this->prefix = $args['prefix'];
$this->plugins_info = $args['plugins_info'];
$this->options = $args['options'];
$this->default_options = $args['default_options'];
$this->wp_slug = $args['wp_slug'];
$this->demo_data = $args['demo_data'];
$this->tabs = $args['tabs'];
$this->is_network_options = $args['is_network_options'];
$this->doc_link = $args['doc_link'];
$this->doc_video_link = $args['doc_video_link'];
$this->link_key = $args['link_key'];
$this->link_pn = $args['link_pn'];
$this->trial_days = $args['trial_days'];
$this->licenses = $args['licenses'];
$this->bws_license_plugin = '';
require dirname( __FILE__ ) . '/product_list.php';
if ( isset( $bws_plugins[ $this->plugin_basename ] ) ) {
if ( isset( $bws_plugins[ $this->plugin_basename ]['pro_settings'] ) ) {
$this->pro_page = $bws_plugins[ $this->plugin_basename ]['pro_settings'];
$this->bws_license_plugin = $bws_plugins[ $this->plugin_basename ]['pro_version'];
$this->bws_plugin_link = substr( $bws_plugins[ $this->plugin_basename ]['link'], 0, strpos( $bws_plugins[ $this->plugin_basename ]['link'], '?' ) );
if ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ) {
$this->bws_plugin_link .= '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version;
$this->hide_pro_tabs = bws_hide_premium_options_check( $this->options );
$this->version = '1.0.0';
$this->is_multisite = is_multisite();
if ( empty( $this->pro_page ) && array_key_exists( 'license', $this->tabs ) ) {
$this->licenses[ $this->plugins_info['TextDomain'] ] = array(
'name' => $this->plugins_info['Name'],
'slug' => $this->plugins_info['TextDomain'],
'basename' => $this->plugin_basename,
$this->licenses[ $this->plugins_info['TextDomain'] ] = array(
'name' => $this->plugins_info['Name'],
'slug' => $this->plugins_info['TextDomain'],
'pro_slug' => substr( $this->bws_license_plugin, 0, stripos( $this->bws_license_plugin, '/' ) ),
'basename' => $this->plugin_basename,
'pro_basename' => $this->bws_license_plugin,
* Displays the content of the "Settings" on the plugin settings page
public function display_content() {
global $bstwbsftwppdtplgns_options;
if ( array_key_exists( 'custom_code', $this->tabs ) ) {
/* get args for `custom code` tab */
$this->get_custom_code();
$save_results = $this->save_all_tabs_options();
$this->display_messages( $save_results );
if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
bws_form_restore_default_confirm( $this->plugin_basename );
} elseif ( isset( $_POST['bws_handle_demo'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
$this->demo_data->bws_demo_confirm();
bws_show_settings_notice(); ?>
<form class="bws_form" method="post" action="" enctype="multipart/form-data">
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content" style="position: relative;">
<?php $this->display_tabs(); ?>
</div><!-- #post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<div class="meta-box-sortables ui-sortable">
<div id="submitdiv" class="postbox">
<h3 class="hndle"><?php esc_html_e( 'Information', 'bestwebsoft' ); ?></h3>
<div class="submitbox" id="submitpost">
<div id="minor-publishing">
<div id="misc-publishing-actions">
* Action - Display additional content for #misc-publishing-actions
do_action( __CLASS__ . '_information_postbox_top' );
if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) || empty( $bstwbsftwppdtplgns_options['time_out'] ) || ! array_key_exists( $this->plugin_basename, $bstwbsftwppdtplgns_options['time_out'] ) ) {
$license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>';
$finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] );
$today = strtotime( gmdate( 'm/d/Y' ) );
if ( isset( $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] ) ) {
$license_type = 'Trial Pro';
if ( $finish < $today ) {
$license_status = __( 'Expired', 'bestwebsoft' );
$daysleft = floor( ( $finish - $today ) / ( 60 * 60 * 24 ) );
$license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft );
$license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>';
$license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro';
if ( ! empty( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) && $finish < $today ) {
$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>';
$license_status = __( 'Active', 'bestwebsoft' );
<div class="misc-pub-section">
<strong><?php esc_html_e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $license_type ); ?>
<div class="misc-pub-section">
<strong><?php esc_html_e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo wp_kses_post( $license_status ); ?>
</div><!-- .misc-pub-section -->
<div class="misc-pub-section">
<strong><?php esc_html_e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $this->plugins_info['Version'] ); ?>
</div><!-- .misc-pub-section -->
* Action - Display additional content for #misc-publishing-actions
do_action( __CLASS__ . '_information_postbox_bottom' );
<div class="clear"></div>
<div id="major-publishing-actions">
<div id="publishing-action">
<input type="hidden" name="<?php echo esc_attr( $this->prefix ); ?>_form_submit" value="submit" />
<input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" />
<?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?>
<div class="clear"></div>
* Action - Display custom metabox
do_action( __CLASS__ . '_display_metabox' );
if ( function_exists( 'bws_affiliate_postbox' ) ) {
<div id="postbox-container-2" class="postbox-container">
* Action - Display additional content for #postbox-container-2
do_action( __CLASS__ . '_display_second_postbox' );
<input type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" />
<?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?>
if ( ! empty( $this->wp_slug ) ) {
bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug );
public function display_tabs() {
<div id="bws_settings_tabs_wrapper">
<ul id="bws_settings_tabs">
<?php $this->display_tabs_list(); ?>
<?php $this->display_tabs_content(); ?>
<div class="clear"></div>
<input type="hidden" name="bws_active_tab" value="<?php
if ( isset( $_REQUEST['bws_active_tab'] ) ) {
echo esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['bws_active_tab'] ) ) );
* Displays the list of tabs
private function display_tabs_list() {
foreach ( $this->tabs as $tab_slug => $data ) {
if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) {
$tab_class = 'bws-tab-' . $tab_slug;
if ( ! empty( $data['is_pro'] ) ) {
$tab_class .= ' bws_pro_tab';
if ( ! empty( $data['class'] ) ) {
$tab_class .= ' ' . $data['class'];
<li class="<?php echo esc_attr( $tab_class ); ?>" data-slug="<?php echo esc_attr( $tab_slug ); ?>">
<a href="#<?php echo esc_attr( $this->prefix ); ?>_<?php echo esc_attr( $tab_slug ); ?>_tab">
<span><?php echo esc_html( $data['label'] ); ?></span>
* Displays the content of tabs
public function display_tabs_content() {
foreach ( $this->tabs as $tab_slug => $data ) {
if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) {
<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;">
$tab_slug = str_replace( '-', '_', $tab_slug );
if ( method_exists( $this, 'tab_' . $tab_slug ) ) {
call_user_func( array( $this, 'tab_' . $tab_slug ) );
do_action_ref_array( __CLASS__ . '_after_tab_' . $tab_slug, array( &$this ) );
* Save all options from all tabs and display errors\messages
public function save_all_tabs_options() {
/* Restore default settings */
if ( isset( $_POST['bws_restore_confirm'] ) && check_admin_referer( $this->plugin_basename, 'bws_settings_nonce_name' ) ) {
$this->restore_options();
$message = __( 'All plugin settings were restored.', 'bestwebsoft' );
/* Go Pro - check license key */
} elseif ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) {
$result = $this->save_options_license_key();
if ( ! empty( $result['empty_field_error'] ) ) {
$error = $result['empty_field_error'];
if ( ! empty( $result['error'] ) ) {
$error = $result['error'];
if ( ! empty( $result['message'] ) ) {
$message = $result['message'];
if ( ! empty( $result['notice'] ) ) {
$notice = $result['notice'];
$demo_result = ! empty( $this->demo_data ) ? $this->demo_data->bws_handle_demo_data() : false;
if ( false !== $demo_result ) {
if ( ! empty( $demo_result ) && is_array( $demo_result ) ) {
$error = $demo_result['error'];
$message = $demo_result['done'];
if ( ! empty( $demo_result['done'] ) && ! empty( $demo_result['options'] ) ) {
$this->options = $demo_result['options'];
} 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' ) ) {
$result = $this->save_options();
if ( ! empty( $result['error'] ) ) {
$error = $result['error'];
if ( ! empty( $result['message'] ) ) {
$message = $result['message'];
if ( ! empty( $result['notice'] ) ) {
$notice = $result['notice'];
if ( '' === $this->change_permission_attr ) {
$result = $this->save_options_misc();
if ( ! empty( $result['notice'] ) ) {
$notice .= $result['notice'];
return compact( 'message', 'notice', 'error' );
* Display error\message\notice
* @param $save_results - array with error\message\notice
public function display_messages( $save_results ) {
* Action - Display custom error\message\notice
do_action( __CLASS__ . '_display_custom_messages', $save_results );
<div class="updated fade inline"
if ( empty( $save_results['message'] ) ) {
echo 'style="display:none"';
><p><strong><?php echo ! empty( $save_results['message'] ) ? wp_kses_post( $save_results['message'] ) : ''; ?></strong></p></div>
<div class="updated bws-notice inline"
if ( empty( $save_results['notice'] ) ) {
echo 'style="display:none"';
><p><strong><?php echo ! empty( $save_results['notice'] ) ? wp_kses_post( $save_results['notice'] ) : ''; ?></strong></p></div>
<div class="error inline"
if ( empty( $save_results['error'] ) ) {
echo 'style="display:none"';
><p><strong><?php echo ! empty( $save_results['error'] ) ? wp_kses_post( $save_results['error'] ) : ''; ?></strong></p></div>
* Save plugin options to the database
public function save_options() {
die( 'function Bws_Settings_Tabs::save_options() must be over-ridden in a sub-class.' );
* Get 'custom_code' status and content
private function get_custom_code() {
global $bstwbsftwppdtplgns_options, $wp_filesystem;
$this->custom_code_args = array(
'is_css_active' => false,
'css_writeable' => false,
'is_php_active' => false,
'php_writeable' => false,
if ( ! $this->upload_dir ) {
$this->upload_dir = wp_upload_dir();
$folder = $this->upload_dir['basedir'] . '/bws-custom-code';