jQuery Cookies and WordPress - Need to Modify a Customization but Not Sure How

jQuery Cookies and WordPress - Need to Modify a Customization but Not Sure How

Hi all,

I'm using the Sliding Panel WordPress plugin on a site in development and I've had this plugin customized with jQuery cookies to force the sliding panel to open once after a successful login. That is working great. A usability issue has arisen when a user doesn't enter their login credentials correctly and they get the following standard WordPress message:

  1. ERROR: Invalid username. Lost your password?

That is great, but the message is hidden behind a closed panel. The cookie code is not set to keep the panel open upon an error, only when user is logged in. I would like the panel to stay open both when a user logs in AND when a login error occurs.

I have done some research and it looks like there is a function for this case in WP named is_wp_error so logic would suggest that I can check for that in the custom cookie handling code, but I'm not quite sure how to write that correctly. I wonder if anyone here can assist?

The custom cookie code is...

  1. /* Cookie Handling */

    // Check if logged in
    if ($j('body').is('.loggedin')) {
    // Logged in - set cookie if not set already, and display panel
    var show_panel = $j.cookie('show_panel');
    if (show_panel=='no') {} else {
    $j ( '#sliding-panel .panel' ).show();
    $j ( '#sliding-panel .tab' ).addClass( 'current' );
    $j ( '#sliding-panel .toggle a.open' ).hide();
    $j ( '#sliding-panel .toggle a.close' ).show();
    $j.cookie('show_panel', 'no', { domain: '.test.net' });
    }
    } else {
    // Not logged in
    $j.cookie('show_panel', null, { domain: '.test.net' });
    }

    /* End Cookie Handling */

















I thought I could do something like this, but it breaks the cookie handling and after further research it's my lack of understanding of jQuery that is the real problem;)

  1. } else if {
    if ( is_wp_error() ) {
    var show_panel = $j.cookie('show_panel');
    if (show_panel=='no') {} else {
    $j ( '#sliding-panel .panel' ).show();
    $j ( '#sliding-panel .tab' ).addClass( 'current' );
    $j ( '#sliding-panel .toggle a.open' ).hide();
    $j ( '#sliding-panel .toggle a.close' ).show();
    $j.cookie('show_panel', 'no', { domain: '.test.net' });
    }









If anyone here could assist me in editing this code to force the sliding panel open upon login error as well as successful login, I would be most appreciative.