WordPress core overload?
-
I am seeing add_action code being executed for plugins way more times than I would expect. I modified Hello Dolly below, to demonstrate by simply outputting some text after the basic Hello Dolly functionality is executed. I added only logging (no architectural or logic changes) to show how many executions WordPress core is doing within a plugin script for a single admin page refresh.
With the Twenty Ten theme and a single refresh of the Dashboard, Hello Dolly’s add_action for the admin_footer runs eight times, and therefore, hello_dolly_get_lyric() runs 8 times though you can see the result only once on the admin page in the upper right.
Even more surprisingly, both add_action and hello_dolly_get_lyric() run 15 times when displaying the home page – where admin-related actions should not be executing. No lyrics display, so unless you are watching the logging code I put in, one would never know that this is going on on a normal basis.
I bring this up because if this is all true and I haven’t configured something incorrectly, this is a huge, huge waste of resources.
I would really appreciate someone could take 2 minutes to test my version of Hello Dolly below and see if you get the same results in your error_log file. In my mind, I should see that code execute once in admin functions per plugin file and never on the blog home page.
[Large code excerpt removed by moderator per forum rules. Please use the pastebin for all large code excerpts. It works better anyway.]
- The topic ‘WordPress core overload?’ is closed to new replies.