I am writing a Joomla wordpress plugin that appears pretty much like:

<?php

    // no direct access
    defined( '_JEXEC' ) or die( 'Restricted access' );

    class plgSystemTest extends JPlugin {
        function onAfterInitialise(){
            static $showWarnings = true;

            if($somecondition && $showWarnings)
                JError::raiseWarning(100,'Some warning that shows up twice.');

            $showWarnings = false;
        }
    }

?>

I am testing this wordpress plugin on Joomla 1.5, 1.6 and 1.7. As the warning demonstrates up in all of them, it turns up two times the 2nd time the page loads.

Incidentally, it is also worth observing the $showWarnings flag does not help whatsoever.

enter image description here

Notes

Perhaps you have checked that not one other bit of code is trigerring JError::raiseWarning or even the "onAfterInitialise" event?. That static var should work unless of course you've two different cases of the wordpress plugin.

You could attempt this:

class plgSystemTest extends JPlugin {
        function onAfterInitialise(){
            static $showWarnings;
            if ( !isset( $showWarnings ) ) {
                JError::raiseWarning(100,'Some warning that shows up twice.');
                $showWarnings = false;
            }
        }
    }
}

whether it still does not work, do this:

class plgSystemTest extends JPlugin {
        protected static $showWarnings;

        function onAfterInitialise(){
            if ( !isset( self::$showWarnings ) ) {
                JError::raiseWarning(100,'Some warning that shows up twice.');
                $showWarnings = false;
            }
        }
    }
}

I really hope it assisted!

I am editing the response to answer your comment

To begin with: sorry, I designed a mistake on my small code. Within the second bit of code, you need to change this:

$showWarnings = false

With this:

self::$showWarnings = false;

Whether it still is not working, do this:

class plgSystemTest extends JPlugin {
    protected static $showWarnings = true;

    function onAfterInitialise(){
        static $call_count = null;
        if ( self::$showWarnings === true ) {
            if( !isset( $call_count ) ) {
                $call_count = 1;
            } else {
                $call_count++;
            }
            JError::raiseWarning(100,'Some warning that shows up twice. Total: ' . $call_count);
            self::$showWarnings = false;
        }
    }
}

Regards

As @alghimo suggested, alerts are in some way saved inside a session.

Regrettably, I do not have enough time down the sink looking into such strange issues in Joomla, therefore the technical particulars continue to be hazy.

Generate an income first got it to operate when i want would be to to not show the content when $_GET['layout'] is edit:

if($_REQUEST['layout'] != 'edit'){
    JError::raiseWarning(100, 'Bla bla bla.');
}

Nevertheless, I do not feel this is actually the right response to the problem. If anybody pops up having a better idea, I'm going to be more than pleased to change solutions accordingly.