: 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!' );
public function __construct() {
add_shortcode( 'wws-qr', array( $this, 'qr_display' ) );
public function qr_display( $atts ) {
$a = shortcode_atts( array(
'text' => 'Scan QR to talk us via WhatsApp',
$upload_dir = wp_upload_dir();
$qr = $upload_dir['baseurl'] . '/wws-qr-images/' . $a['qr'];
require WWS_PLUGIN_PATH . 'templates/wws-qr-template.php';
public static function generate( $qr_link = '', $qr_size = '1000' ) {
$upload_dir = wp_upload_dir();
if ( ! file_exists( $upload_dir['basedir'] . '/wws-qr-images' ) ) {
mkdir( $upload_dir['basedir'] . '/wws-qr-images', 0777, true );
$url = 'http://api.qrserver.com/v1/create-qr-code/?data=' . esc_url( $qr_link ) . '&size=' . esc_html( $qr_size ) . 'x' . $qr_size ;
$dir = $upload_dir['basedir'] . '/wws-qr-images'; // Full Path
$name = rand(100000, 999999).'.jpg';
is_dir($dir) || @mkdir($dir) || die("Can't Create folder");
copy($url, $dir . DIRECTORY_SEPARATOR . $name);
} // end of WWS_QR_Generator
$wws_qr_generator = new WWS_QR_Generator;