WordPress pop-up notification close button not working
<p>I am having a trouble with my website's pop-up widget. The problem is the pop-up appears when you enter or refresh the website but I can not close it. I click on the "X" button but nothing happens. The code:</p>

<pre><code>&lt;?php
/*
Plugin Name: WP Welcome Message
Plugin URI: http://www.a1netsolutions.com/Products/WP-Welcome-Message
Description: &lt;strong&gt;WP Welcome Message&lt;/strong&gt; is a wordpress plugin, which help your to make any announcement, special events, special offer, signup message or such kind of message, displayed upon your website's visitors when the page is load through a popup box.
Version: 3.0
Author: Ahsanul Kabir
Author URI: http://www.ahsanulkabir.com/
License: GPL2
License URI: license.txt
*/

$wpwm_conf = array(
    'VERSION' =&gt; get_bloginfo('version'),
    'VEWPATH' =&gt; plugins_url('lib/', __FILE__),
);

function wpwm_admin_styles()
{
    global $wpwm_conf;
    wp_enqueue_style('wpwm_admin_styles',($wpwm_conf["VEWPATH"].'css/admin.css'));
    if( $wpwm_conf["VERSION"] &gt; 3.7 )
    {
        wp_enqueue_style('wpwm_icon_styles',($wpwm_conf["VEWPATH"].'css/icon.css'));
    }
}
add_action('admin_print_styles', 'wpwm_admin_styles');

function wpwm_scripts_styles()
{
    global $wpwm_conf;
    $wpwmBoxSetly = get_option('wpwm_boxsetly');
    if(!$wpwmBoxSetly){$wpwmBoxSetly=="fadeOut";}
    wp_enqueue_script('wpwm_site_scripts',($wpwm_conf["VEWPATH"].'js/site_'.$wpwmBoxSetly.'.js'),array('jquery'),'',true);
    wp_enqueue_style('wpwm_site_style',($wpwm_conf["VEWPATH"].'css/site.css'));
}
add_action('wp_enqueue_scripts', 'wpwm_scripts_styles');

function wpwm_defaults()
{
    $wpwm_default = plugin_dir_path( __FILE__ ).'lib/default.php';
    if(is_file($wpwm_default))
    {
        require $wpwm_default;
        foreach($default as $k =&gt; $v)
        {
            $vold = get_option($k);
            if(!$vold)
            {
                update_option($k, $v);
            }
        }
        if(!is_multisite())
        {
            unlink($wpwm_default);
        }
    }
}

function wpwm_activate()
{
    $wpwm_postsid = get_option( 'wpwm_postsid' );
    if(!$wpwm_postsid)
    {
        $inputContent = 'Welcome to '.get_bloginfo('name').', '. get_bloginfo('description');
        $new_post_id = wpwm_printCreatePost($inputContent);
        update_option( 'wpwm_postsid', $new_post_id );
    }
    wpwm_defaults();
}

function wpwm_redirect()
{
    $wpwm_fv = get_option('wpwm_fv');
    if($wpwm_fv != 'fv')
    {
        echo '&lt;a href="',admin_url('admin.php?page=wpwm_admin_page'),'" id="wpwm_redirect"&gt;Please setup your &lt;strong&gt;WP Welcome Message 2.0&lt;/strong&gt; plugin. &lt;input type="submit" value="Setup" class="button" /&gt;&lt;/a&gt;';
    }
}
add_action( 'admin_footer', 'wpwm_redirect' );

function wpwm_admin_menu()
{
    global $wpwm_conf;
    if( $wpwm_conf["VERSION"] &lt; 3.8 )
    {
        add_menu_page('WP Welcome Message', 'Welcome Msg', 'manage_options', 'wpwm_admin_page', 'wpwm_admin_function', (plugins_url('lib/img/icon.png', __FILE__)));
    }
    else
    {
        add_menu_page('WP Welcome Message', 'Welcome Msg', 'manage_options', 'wpwm_admin_page', 'wpwm_admin_function');
    }
}
add_action('admin_menu', 'wpwm_admin_menu');

function wpwm_select( $iget, $iset, $itxt )
{
    if( $iget == $iset )
    {
        echo '&lt;option value="'.$iset.'" selected="selected"&gt;'.$itxt.'&lt;/option&gt;';
    }
    else
    {
        echo '&lt;option value="'.$iset.'"&gt;'.$itxt.'&lt;/option&gt;';
    }
}

function wpwm_update($key, $value)
{
    if(isset($value) &amp;&amp; !empty($value))
    {
        update_option($key, $value);
    }
}

function wpwm_admin_function()
{
    $wpwm_fv = get_option('wpwm_fv');
    if($wpwm_fv != 'fv')
    {
        update_option('wpwm_fv', 'fv');
    }

    wpwm_update('wpwm_loc', $_POST["wpwm_loc"]);
    wpwm_update('wpwm_log', $_POST["wpwm_log"]);
    wpwm_update('wpwm_boxsetly', $_POST["wpwm_boxsetly"]);
    wpwm_update('wpwm_bgstyle', $_POST["wpwm_bgstyle"]);
    wpwm_update('wpwmTemplate', $_POST["wpwmTemplate"]);
    wpwm_update('wpwm_onlyFirstVisit', $_POST["wpwm_onlyFirstVisit"]);
    wpwm_update('wpwm_ststs', $_POST["wpwm_ststs"]);
    $wpwmPID = get_option('wpwm_postsid');
    wpwm_updatePost($_POST["wpwmeditor"], $wpwmPID);

    if( isset($_POST["wpwmeditor"]) || isset($_POST["wpwmTemplate"]) )
    {
        echo '&lt;div id="message" class="updated wpwm_updated"&gt;&lt;p&gt;Your data has been successfully saved.&lt;/p&gt;&lt;/div&gt;';
    }

    global $wpwm_conf;
    echo '&lt;div id="wpwm_container"&gt;
    &lt;div id="wpwm_main"&gt;
    &lt;a href="https://www.youtube.com/watch?v=dz1wZSsRxXk" target="_blank"&gt;&lt;img src="',$wpwm_conf["VEWPATH"],'/img/uvg.png" id="wpwm_uvg" /&gt;&lt;/a&gt;
    &lt;h1 id="wpwm_page_title"&gt;WP Welcome Message&lt;/h1&gt;';
    ?&gt;
    &lt;div class="wpwm_box"&gt;
    &lt;div class="wpwm_box_title"&gt;Your Welcome Message
    &lt;form method="post" action="" id="wpwm_off_on"&gt;&lt;input type="hidden" name="wpwm_ststs" value="&lt;?php
    $wpwm_ststs = get_option('wpwm_ststs');
    if($wpwm_ststs == 'on')
    {
        echo 'off';
    }
    else
    {
        echo 'on';
    }
    ?&gt;" /&gt;&lt;input type="image" src="&lt;?php echo $wpwm_conf["VEWPATH"]; ?&gt;/img/&lt;?php
    $wpwm_ststs = get_option('wpwm_ststs');
    if($wpwm_ststs == 'on')
    {
        echo 'one-check_yes';
    }
    else
    {
        echo 'one-check_no';
    }
    ?&gt;.png" /&gt;&lt;/form&gt;
    &lt;/div&gt;

    &lt;div class="wpwm_box_con"&gt;
    &lt;form method="post" action="" id="wpwm_content_form"&gt;
    &lt;?php
    $wpwm_ststs = get_option('wpwm_ststs');
    if($wpwm_ststs == 'off')
    {
        echo '&lt;div id="wpwm_content_disable"&gt;&lt;/div&gt;';
    }

    $wpwmPID = get_option('wpwm_postsid');
    $wpwmContent = get_post($wpwmPID);
    $wpwmContent = $wpwmContent-&gt;post_content;
    $wpwmContent = apply_filters('the_content', $wpwmContent);
    $wpwmContent = str_replace(']]&gt;', ']]&amp;gt;', $wpwmContent);

    if( $wpwm_conf["VERSION"] &lt; 3.3 )
    {
        echo '&lt;textarea name="wpwmeditor" style="width:100%; height:300px;"&gt;&lt;/textarea&gt;';
    }
    else
    {
        wp_editor( $wpwmContent, 'wpwmeditor', array('textarea_rows' =&gt; 20, 'textarea_name' =&gt; 'wpwmeditor') );
    }
    ?&gt;
    &lt;input type="submit" value="save changes" /&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="wpwm_box"&gt;
    &lt;div class="wpwm_box_title"&gt;Settings&lt;/div&gt;
    &lt;div class="wpwm_box_con"&gt;
    &lt;form method="post" action=""&gt;
          &lt;div class="row"&gt;
            &lt;label&gt;On Which Page/Pages to Display : &lt;/label&gt;
            &lt;select name="wpwm_loc"&gt;
              &lt;?php
                $wpwmLoc = get_option( 'wpwm_loc' );
                wpwm_select( $wpwmLoc, 'home', 'Home Page Only' );
                wpwm_select( $wpwmLoc, 'all', 'All Pages' );
                ?&gt;
            &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
            &lt;label&gt;Logged-in / Not Logged-in user : &lt;/label&gt;
            &lt;select name="wpwm_log"&gt;
              &lt;?php
                $wpwm_log = get_option( 'wpwm_log' );
                wpwm_select( $wpwm_log, 'log', 'Logged-in Users Only' );
                wpwm_select( $wpwm_log, 'nlog', 'Not Logged-in Users Only' );
                wpwm_select( $wpwm_log, 'all', 'For All' );
                ?&gt;
            &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
            &lt;label&gt;Message Box Animation Style : &lt;/label&gt;
            &lt;select name="wpwm_boxsetly"&gt;
              &lt;?php
                $wpwmBoxSetly = get_option( 'wpwm_boxsetly' );
                wpwm_select( $wpwmBoxSetly, 'fadeOut', 'Fade Out' );
                wpwm_select( $wpwmBoxSetly, 'slideUp', 'Slide Up' );
                ?&gt;
            &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
            &lt;label&gt;Template : &lt;/label&gt;
            &lt;select name="wpwmTemplate"&gt;
              &lt;?php
                $wpwmTemplate = get_option( 'wpwmTemplate' );
                wpwm_select( $wpwmTemplate, 'black-color', 'Dark Color Only' );
                wpwm_select( $wpwmTemplate, 'black-white-color', 'White Color Only' );
                wpwm_select( $wpwmTemplate, 'white-color', 'Full White Color Only' );
                wpwm_select( $wpwmTemplate, 'black-striped', 'Dark Stripes' );
                wpwm_select( $wpwmTemplate, 'black-white-striped', 'White Stripes' );
                wpwm_select( $wpwmTemplate, 'white-striped', 'Full White Stripes' );
                wpwm_select( $wpwmTemplate, 'bootstrap', 'Bootstrap Style' );
                ?&gt;
            &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
            &lt;label&gt;Only For Fist Time Visit : &lt;/label&gt;
            &lt;select name="wpwm_onlyFirstVisit"&gt;
              &lt;?php
                $wpwm_onlyFirstVisit = get_option( 'wpwm_onlyFirstVisit' );
                wpwm_select( $wpwm_onlyFirstVisit, 'on', 'Enable' );
                wpwm_select( $wpwm_onlyFirstVisit, 'off', 'Disable' );
                ?&gt;
            &lt;/select&gt;
          &lt;/div&gt;
    &lt;input type="submit" value="save changes" /&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;/div&gt;

    &lt;?php
    echo '&lt;/div&gt;
    &lt;div id="wpwm_side"&gt;
    &lt;div class="wpwm_box"&gt;';
    echo '&lt;a href="http://www.a1netsolutions.com/Products/WordPress-Plugins" target="_blank" class="wpwm_advert"&gt;&lt;img src="',$wpwm_conf["VEWPATH"],'/img/wp-advert-1.png" /&gt;&lt;/a&gt;';
    echo '&lt;/div&gt;&lt;div class="wpwm_box"&gt;';
    echo '&lt;a href="http://www.ahsanulkabir.com/request-quote/" target="_blank" class="wpwm_advert"&gt;&lt;img src="',$wpwm_conf["VEWPATH"],'/img/wp-advert-2.png" /&gt;&lt;/a&gt;';
    echo '&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="wpwm_clr"&gt;&lt;/div&gt;
    &lt;/div&gt;';
}

function wpwm_content()
{
    $wpwm_ststs = get_option('wpwm_ststs');
    if($wpwm_ststs == 'on')
    {
        $wpwm_onlyFirstVisit = get_option( 'wpwm_onlyFirstVisit' );
        if( $wpwm_onlyFirstVisit == "on" )
        {
            if( (!isset($_SESSION["wpwm_session"])) || ($_SESSION["wpwm_session"] != 'off') )
            {
                wpwm_popupFirst();
            }
        }
        else
        {
            wpwm_popupFirst();
        }
    }
}

function wpwm_popupFirst()
{
    $wpwm_loc = get_option( 'wpwm_log' );
    if(get_option('wpwm_ststs') == 'on')
    {
        if( $wpwm_loc == 'log' )
        {
            if ( is_user_logged_in() )
            {
                wpwm_popupCheckPage();
            }
        }
        elseif( $wpwm_loc == 'nlog' )
        {
            if ( !is_user_logged_in() )
            {
                wpwm_popupCheckPage();
            }
        }
        else
        {
            wpwm_popupCheckPage();
        }
    }
}

function wpwm_popupTemp()
{
    $wpwmPID = get_option( 'wpwm_postsid' );
    $wpwmTemplate = get_option('wpwmTemplate');
    $content_post = get_post($wpwmPID);
    $wpwmContent = $content_post-&gt;post_content;
    $wpwmContent = apply_filters('the_content', $wpwmContent);
    $wpwmContent = str_replace(']]&gt;', ']]&amp;gt;', $wpwmContent);
    $session_id = session_id();
    echo '
    &lt;div id="wpwm_hideBody" class="'.$wpwmTemplate.'-body"&gt;
      &lt;div id="wpwm_popBoxOut"&gt;
        &lt;div class="wpwm-box"&gt;
          &lt;div id="wpwm_popBox"&gt;
            &lt;span id="wpwm_popClose"&gt;×&lt;/span&gt;
            '.$wpwmContent.'
            &lt;div class="cl_fix"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"&gt;
    jQuery(document).ready(function()
    {
        jQuery("html, body").css({"overflow": "hidden"});
    });
    &lt;/script&gt;
    ';
    echo '&lt;span&gt;',get_option('wpwm_dev1'),get_option('wpwm_dev2'),get_option('wpwm_dev3'),'&lt;/span&gt;';
}



function wpwm_popupCheckPage()
{
      if( ( get_option( 'wpwm_loc' ) ) == 'home' )
      {
          if( is_front_page() )
          {
              wpwm_popupTemp();
          }
      }
      else
      {
          wpwm_popupTemp();
      }
}

function wpwm_sessionID()
{
    if(!isset($_SESSION)){session_start();}
    if(isset($_SESSION["wpwm_session"]))
    {
        $_SESSION["wpwm_session"] = 'off';
    }
    else
    {
        $_SESSION["wpwm_session"] = 'on';
    }
}
add_action( 'wp_head', 'wpwm_sessionID' );

function wpwm_posts_init()
{
  $args = array
  (
    'public' =&gt; false,
    'publicly_queryable' =&gt; false,
    'show_ui' =&gt; false, 
    'show_in_menu' =&gt; false, 
    'rewrite' =&gt; array( 'slug' =&gt; 'wpwmposts' ),
    'capability_type' =&gt; 'post',
    'has_archive' =&gt; false, 
    'supports' =&gt; array( 'title', 'editor', 'excerpt' )
  ); 
  register_post_type( 'wpwmposts', $args );
}
add_action( 'init', 'wpwm_posts_init' );

function wpwm_getCurrentUser()
{
    if (function_exists('wp_get_current_user'))
    {
        return wp_get_current_user();
    }
    else if (function_exists('get_currentuserinfo'))
    {
        global $userdata;
        get_currentuserinfo();
        return $userdata;
    }
    else
    {
        $user_login = $_COOKIE["USER_COOKIE"];
        $current_user = $wpdb-&gt;get_results("SELECT * FROM `".$wpdb-&gt;users."` WHERE `user_login` = '".$user_login."' ;");
        return $current_user;
    }
}

function wpwm_printCreatePost($inputContent)
{
    $newPostAuthor = wpwm_getCurrentUser();
    $newPostArg = array
    (
        'post_author' =&gt; $newPostAuthor-&gt;ID,
        'post_content' =&gt; $inputContent,
        'post_status' =&gt; 'publish',
        'post_type' =&gt; 'wpwmposts'
    );
    $new_post_id = wp_insert_post($newPostArg);
    return $new_post_id;
}

function wpwm_updatePost($inputContent, $id)
{
    $newPostAuthor = wpwm_getCurrentUser();
    $newPostArg = array
    (
        'ID' =&gt; $id,
        'post_author' =&gt; $newPostAuthor-&gt;ID,
        'post_content' =&gt; $inputContent,
        'post_status' =&gt; 'publish',
        'post_type' =&gt; 'wpwmposts'
    );
    $new_post_id = wp_insert_post($newPostArg);
    return $new_post_id;
}


add_action('wp_footer', 'wpwm_content', 100);
register_activation_hook(__FILE__, 'wpwm_activate');

?&gt;
</code></pre>

<p>Finally, I managed to find where the problem is.</p>

<pre><code>echo '
    &lt;div id="wpwm_hideBody" class="'.$wpwmTemplate.'-body"&gt;
      &lt;div id="wpwm_popBoxOut"&gt;
        &lt;div class="wpwm-box"&gt;
          &lt;div id="wpwm_popBox"&gt;
            &lt;span id="wpwm_popClose"&gt;×&lt;/span&gt;
            '.$wpwmContent.'
            &lt;div class="cl_fix"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"&gt;
    jQuery(document).ready(function()
    {
        jQuery("html, body").css({"overflow": "hidden"});
    });
    &lt;/script&gt;
    ';
</code></pre>

<p>And find out there is no close function going on here:</p>

<pre><code>&lt;span id="wpwm_popClose"&gt;×&lt;/span&gt;
</code></pre>

<p>So changed it with this:</p>

<pre><code>&lt;span id="wpwm_popClose" onclick="document.getElementById('pwm_hideBody').style.display='none'"&gt;×&lt;/span&gt;
</code></pre>

<p>but when I edit this PHP code, WordPress gives me this error:</p>

<pre><code>Parse error: syntax error, unexpected 'pwm_hideBody' (T_STRING), expecting ',' or ';' in /var/www/vhosts/derinuzay.org/httpdocs/wp-content/plugins/wp-welcome-message/wp-welcome-message.php on line 337
</code></pre>

<p>Could you please help me out about this error?</p>