I am creating my first wordpress plug, and am using the WPBP template which is a great timesaver.
In the main of the plugin (called myplugin.php), I added a simple command to write a line of text to a file. That works, however, when I refresh the page (one page of my website), I see approx 4 lines written to my file.
Does the myplugin.php get included / execute many times for each page? If so, why?
Next, what is the best way to enforce only running once per page. I plan to create a PHP object and don't want to create it 4 time. Obviously I could build my own detection if the class exists, but that seems wrong. Surely WP has devised some mechanism to ensure plugin global/main code only runs once.