: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Preventing to direct access
defined( 'ABSPATH' ) OR die( 'Direct access not acceptable!' );
class WWS_Button_Generator {
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_fonts' ) );
add_shortcode( 'whatsappsupport', array($this, 'plugin_shortcode') );
* Custom google font in shortcode support button
public function shortcode_fonts() {
'wws-shortcode-font-lobster',
'https://fonts.googleapis.com/css?family=Lobster');
'wws-shortcode-font-bree',
'https://fonts.googleapis.com/css?family=Bree+Serif');
'wws-shortcode-font-satisfy',
'https://fonts.googleapis.com/css?family=Satisfy');
'wws-shortcode-font-oswald',
'https://fonts.googleapis.com/css?family=Oswald');
'wws-shortcode-font-ubuntu',
'https://fonts.googleapis.com/css?family=Ubuntu');
'wws-shortcode-font-dancing',
'https://fonts.googleapis.com/css?family=Dancing+Script');
* Plugin shortcode main function
* @param array $atts WordPress shortcode array
function plugin_shortcode($atts) {
$a = shortcode_atts( array(
'number' => '911234567890',
'group' => 'XYZ123456789',
'text-bold' => 'inherit',
wp_enqueue_style( 'wws-shortcode-font-lobster' );
$a['font'] = "'Lobster', cursive";
wp_enqueue_style( 'wws-shortcode-font-satisfy' );
$a['font'] = "'Satisfy', cursive";
wp_enqueue_style( 'wws-shortcode-font-bree' );
$a['font'] = "'Bree Serif', serif";
wp_enqueue_style( 'wws-shortcode-font-oswald' );
$a['font'] = "'Oswald', sans-serif";
wp_enqueue_style( 'wws-shortcode-font-ubuntu' );
$a['font'] = "'Ubuntu', sans-serif";
wp_enqueue_style( 'wws-shortcode-font-dancing' );
$a['font'] = "'Dancing Script', cursive";
if ( wp_is_mobile() != true ) { // desktop
$url = "https://web.whatsapp.com/send?phone={$a['number']}&text={$a['message']}";
if ( $a['on-desktop'] == 'no' ) {
$url = "https://api.whatsapp.com/send?phone={$a['number']}&text={$a['message']}";
if ( $a['on-mobile'] == 'no' ) {
if ( $a['group'] != 'XYZ123456789' ) {
$url = "https://chat.whatsapp.com/{$a['group']}";
<a href="<?php echo esc_url( $url ) ?>"
class="wws-shortcode-btn"
style="font-family: <?php echo esc_html( $a['font'] ) ?>; font-weight: <?php echo esc_html( $a['text-bold'] ) ?>; background-color: <?php echo esc_html( $a['bg-color'] ) ?>; <?php echo ( $a['full-width'] == 'yes' ) ? 'display: flex' : 'display: inline-flex'; ?>; color: <?php echo esc_html( $a['text-color'] ) ?>;"
data-wws-button-number="<?php echo esc_attr( $a['number'] ); ?>"
data-wws-button-message="<?php echo esc_attr( $a['message'] ); ?>">
<?php echo WWS_Icons::get( 'whatsapp' ); ?> <?php echo esc_html( $a['text'] ) ?>
} // end of WWS_Button_Generator
$wws_button_generator = new WWS_Button_Generator;