: 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!' );
* Add popup for frontend users
* @package WeCreativez/Public
public function __construct() {
add_action( 'wp_footer', array( $this, 'display_popup' ) );
* Displaying widget on frontend
public function display_popup() {
if ( true !== apply_filters( 'wws_display_widget_on_current_page', $this->disable_popup() ) ) {
$layout = apply_filters( 'wws_current_layout', get_option( 'wws_layout' ) );
$layout_path = WWS_PLUGIN_PATH . 'templates/wws-template-' . intval( $layout ) . '.php';
require_once apply_filters( 'wws_template_path', $layout_path );
public function display_on_page() {
// Not display on selected URL
$urls = get_option( 'wws_filter_by_url_exclude' );
$urls_array = explode( PHP_EOL, $urls );
if ( is_array( $urls_array ) ) {
foreach( $urls_array as $url_a ) {
if ( 1 === get_the_ID() ) {
if ( get_the_ID() === url_to_postid( trim( $url_a ) ) ) {
// Not display wws on selected page
$page_ids = get_option( 'wws_filter_by_page_id_exclude', array() );
if ( 0 !== count( $page_ids ) ) {
if ( in_array( $post_id, $page_ids) ) {
// display wws on selected page
$page_ids = get_option( 'wws_filter_by_page_id_include', array() );
if ( 0 !== count( $page_ids ) ) {
return in_array( $page_id, $page_ids );
// display wws on front page
if ( is_front_page() == true && 'yes' === get_option( 'wws_filter_by_front_page' ) ) {
// display wws on all pages and posts
if ( 'yes' === get_option( 'wws_filter_by_everywhere' ) ) {
public function disable_popup() {
if ( true === wp_is_mobile() && 'yes' !== get_option( 'wws_display_on_mobile' ) ) {
if ( ! wp_is_mobile() && 'yes' !== get_option( 'wws_display_on_desktop' ) ) {
if ( true !== $this->display_on_page() ) {
if ( true !== $this->is_schedule() ) {
public function format_time_for_compare( $time ) {
return intval( str_replace( ":", "", $time ) );
public function is_schedule() {
$current_day = strtolower( current_time( 'D' ) );
$current_time = (int)current_time( 'His' );
$schedules = get_option( 'wws_filter_by_schedule', array() );
foreach( $schedules as $day => $schedule ) {
if ( $current_day !== $day ) {
if ( 'yes' !== $schedule['status'] ) {
if ( ( $current_time > $this->format_time_for_compare( $schedule['start'] ) )
&& ( $current_time < $this->format_time_for_compare( $schedule['end'] ) ) ) {
$wss_widget = new WWS_Widget;