: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
defined( 'ABSPATH' ) || exit;
class WWS_Compatibility_Dokan {
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_init', array( $this, 'register_setting' ) );
if ( 'yes' === $this->get_setting( 'status' ) ) {
add_action( 'dokan_product_edit_after_options', array( $this, 'edit_product_fields' ), 80, 1 );
add_action( 'dokan_product_updated', array( $this, 'save_product_fields' ), 50, 2 );
add_action( 'wws_admin_post_metabox_notice', array( $this, 'admin_post_metabox_notice' ) );
public function admin_menu() {
esc_html__( 'Dokan Multivendor', 'wc-wws' ),
esc_html__( 'Dokan Multivendor', 'wc-wws' ),
'wc-whatsapp-support_dokan',
array( $this, 'admin_dokan_page' )
* Register plugin options.
public function register_setting() {
register_setting( 'wws_dokan_multivendor_option_group', 'wws_dokan_multivendor_settings', array( $this, 'sanitize_settings' ) );
* Sanitize admin settings.
public function sanitize_settings( $input ) {
$input['status'] = isset( $input['status'] ) ? 'yes' : 'no';
public function admin_dokan_page() {
<h1><?php esc_html_e( 'WordPress WhatsApp Support For Dokan Multivendor', 'wc-wws' ); ?></h1>
<?php settings_errors(); ?>
<form action="options.php" method="post">
<?php settings_fields( 'wws_dokan_multivendor_option_group' ); ?>
<table class="form-table">
<label for=""><?php esc_html_e( 'WhatsApp Support For Dokan', 'wc-wws' ); ?></label>
name="wws_dokan_multivendor_settings[status]"
<?php checked( 'yes', $this->get_setting( 'status' ) ); ?> > <?php esc_html_e( 'Enable/ Disable', 'wc-wws' ); ?>
<p class="description"><?php esc_html_e( 'You can enable or disable WordPress WhatsApp Support for Dokan vendors.', 'wc-wws' ); ?></p>
<p class="description"><?php esc_html_e( "This feature allow vendors to add WhatsApp Number for customer support from their Dokan's edit product page.", 'wc-wws' ); ?></p>
<?php submit_button(); ?>
* Display settings on Dokan edit product page for vendors.
public function edit_product_fields( $post_id ) {
<div class="dokan-other-options dokan-edit-row dokan-clearfix ">
<div class="dokan-section-heading" data-togglehandler="dokan_other_options">
<h2><i class="fa fa-whatsapp" aria-hidden="true"></i> <?php esc_html_e( 'WhatsApp Support', 'wc-wws' ); ?></h2>
<p><?php esc_html_e( 'You can add your WhatsApp number on your product page.', 'wc-wws' ); ?></p>
<a href="#" class="dokan-section-toggle">
<i class="fa fa-sort-desc fa-flip-vertical" aria-hidden="true" style="margin-top: 9px;"></i>
<div class="dokan-clearfix"></div>
<div class="dokan-section-content">
<div class="dokan-form-group">
<label for="_wws_support_contact_number" class="form-label"><?php esc_html_e( 'Your WhatsApp Number', 'wc-wws' ); ?></label>
name="_wws_support_contact_number"
id="_wws_support_contact_number"
class="dokan-form-control"
value="<?php echo esc_attr( get_post_meta( $post_id, '_wws_support_contact_number', true ) ); ?>">
<p class="help-block"><?php esc_html_e( 'Enter mobile phone number with the international country code, without + character. Example: 911234567890 for (+91) 1234567890', 'wc-wws' ); ?></p>
* Display admin metabox notice.
public function admin_post_metabox_notice() {
<?php esc_html_e( 'WordPress WhatsApp Support for Dokan is enabled. These settings are managing by the vendors. Admin can also override and change settings for vendors.', 'wc-wws' ); ?><br/>
* Save settings by vendors.
public function save_product_fields( $post_id, $postdata ) {
if ( ! empty( $postdata['_wws_support_contact_number'] ) ) {
update_post_meta( $post_id, '_wws_support_contact_number', sanitize_textarea_field( $postdata['_wws_support_contact_number'] ) );
delete_post_meta( $post_id, '_wws_support_contact_number' );
* Get Dokan settings for WordPress WhatsApp Support.
private function get_setting( $data ) {
if ( ! isset( $data ) ) {
$setting = get_option( 'wws_dokan_multivendor_settings' );
if ( ! isset( $setting[ $data ] ) ) {
return $setting[ $data ];
new WWS_Compatibility_Dokan;