• Resolved nlpro

    (@nlpro)


    Hi,

    I noticed this plugin relies heavily on the plugins_loaded action hook. It hooks several callbacks, all with a different priority: -1, 0, 1, 2, 5 and 10. So for a PHP code snippet that is allowed to run everywhere, it looks like it is executed at priority 5 as part of the plugins_loaded action hook.

    However some plugins (like Solid Security) initialize on the plugins_loaded action hook with an even higher priority than -1 (eg -90, -100 and -150). A custom PHP code snippet specifically for the Solid Security plugin and implemented with your plugin as is, will thus get executed too late. To fix this, the PHP code snippet needs to be implemented using a MU-plugin (so exit WPCode plugin).

    I like your plugin. Don’t like MU-plugins ?? So would it be possible to add a plugin setting named eg plugins_loaded_max_priority (default value -1) which allows to customize the highest priority used by the WPCode plugin on the plugins_loaded action hook ? This would also require an algorithm to calculate the proper priority relative to the new plugins_loaded_max_priority value. As an example, let’s say plugins_loaded_max_priority = -200. The other hooked callbacks then need to be hooked with priority: -199, -198, -197, -194 and -189.

    If this enhancement is not feasible, how could such a priority issue be solved (other than using a MU-plugin) ?

    Interested to hear your opinion on this matter.

    • This topic was modified 1 month, 1 week ago by nlpro.
    • This topic was modified 1 month, 1 week ago by nlpro.
Viewing 1 replies (of 1 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @nlpro,

    Thank you for the suggestion. When we set the priority for the “plugins_loaded” hook, we looked for the best way to ensure compatibility with common snippets.

    We will look into what options we have to make the priority a setting as you suggested. Other components are dependent on the wpcode_loaded hook, and changing the priority with a setting may not be ideal for some scenarios.

    You can try changing the priority of our hooks from an MU plugin. You can access the main WPCode instance through the wpcode() function and use that to remove the action and add it back with a different priority.

    Next, in the auto_insert instance you can change the types loaded and override the “everywhere” type with a custom one that executes the snippets earlier than 5.

    Once you put this in place as a mu-plugin you can use snippets that get executed earlier.

    If you need further assistance, let us know.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.