WordPress init / plugins_loaded hooks fired multiple times

  macos, php, wordpress

Newly installed WordPress 5.5.1 with default theme 2020.
Add very short plugin (there is no other code in it):

add_action('plugins_loaded', function () {
    error_log('plugins_loaded fired!');
    error_log('here do something after plugins_loaded...');
});

add_action('init', function () {
    error_log('init fired!');
    error_log('here do something after init...');
});

What I’ve seen in debug.log:

[18-Oct-2020 16:20:01 UTC] plugins_loaded fired!
[18-Oct-2020 16:20:01 UTC] here do something after plugins_loaded...
[18-Oct-2020 16:20:03 UTC] plugins_loaded fired!
[18-Oct-2020 16:20:03 UTC] here do something after plugins_loaded...
[18-Oct-2020 16:20:04 UTC] init fired!
[18-Oct-2020 16:20:04 UTC] here do something after init...
[18-Oct-2020 16:20:07 UTC] plugins_loaded fired!
[18-Oct-2020 16:20:07 UTC] here do something after plugins_loaded...
[18-Oct-2020 16:20:07 UTC] init fired!
[18-Oct-2020 16:20:07 UTC] here do something after init...
[18-Oct-2020 16:20:09 UTC] init fired!
[18-Oct-2020 16:20:09 UTC] here do something after init...

What??
Please bear in mind – there is no other code, there is no other pages except exist in 2020 theme, just one plugin activated (this one). So, I could not force such abnormal behavior.

Source: Ask PHP

LEAVE A COMMENT