• Hi there,
    after a user reported a conflict between Styles and Black Studio TinyMCE Widget (see here and here), I made some debug on this and I found that the reason is related to the way Styles attaches callbacks to the plugins_loaded hook.
    There’s a first callback Styles_Plugin::get_instance (with default priority 10) that indirectly adds a second callback Styles_Plugin::plugins_loaded (with priority 15), which indirectly adds a third callback Styles_Child::plugins_loaded (with priority 20).
    This works fine if there are not callbacks on the same hook added by other plugins with the same priority, but it’s not recommended to add actions to the same hook that is actually executing, as WordPress can not guarantee the order of execution in that (nor the execution itself).
    In particular Black Studio TinyMCE Widget was having a callback attached to plugins_loaded with priority 20, which was preventing the execution of the Styles_Child::plugins_loaded. The latest version of BSTW 2.1.3 changed the priority to allow for compatibility, but I would recommend to implement an alternative solution, as it could bring to conflicts to other plugins too.

    https://www.ads-software.com/plugins/styles/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Paul Clark

    (@pdclark)

    Thanks for the detailed notes and links, Marco. I’ll take a closer look at the changes you made and see what I can do to make similar changes in Styles.

    Based on the problems its causing, I believe you when you say that attaching hooks within a hook with a different priority is not reliable. While I think about a work-around, do you recall where I might be able to read more about that behavior?

    Thread Starter Marco Chiesi

    (@marcochiesi)

    Hi Paul,
    unfortunately I have not found any detailed documentation about this issue, but you may take a look at the source code of the do_action function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conflict on plugins_loaded hook’ is closed to new replies.