WordPress.org

Ideas

A way to control order of plug-in output

  1. inspiredmind
    Inactive

    When a number of plug-ins all inject their output into the same page region, there's currently no way — none that I can find — to control the order of the output.
    For instance, I have three plug-ins installed that all output to the area below the page content, above the metadata. In my case, they are:
    - A post series organizer, that outputs a list of other posts in the series the current article belongs to
    - A related posts plug-in, that displays thumbnails of related posts
    - A references and footnotes plug-in, that displays a list of the references I've short-coded into the post.

    In this situation I want the Footnotes to be the FIRST thing to get injected under the post body, the Series list to come next, and the Related posts following that. But there is no way to control this, and in my case the footnotes come last (so far below the actual post as to be somewhat disconnected from its content). I've asked the developer of the Footnotes plug-in for a way to change the position, and he said it's complicated due to the "interesting" way WP handles these things.

    So my feature suggestion is for a way to control the order of the output of plug-ins. If not a GUI interface method, at least a way this can be controlled at a code level by plug-in developers.

    Posted: 3 years ago #
  2. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    If they all hook into the same area, the best you can do is change the hook priority.

    http://codex.wordpress.org/Plugin_API#Hook_to_WordPress

    "Interesting" is a good way to put it though.

    Posted: 3 years ago #
  3. crstauf
    Inactive

    here's a plugin i wrote real quick that allows you to adjust the load order of the active plugins, which might solve your issue.

    https://github.com/crstauf/plugin-load-order

    Posted: 3 years ago #
  4. dhaupin
    Inactive

    Agreed, priority for actions is not enough....especially if youre making a whole class or mitigating a spoof for another class. Also, if plugins share the same action priority then parse order is still based on folder/script name. It all comes down to how you name your files. If its at the top of the list, itll render first (until told otherwise with priority).

    Basically, it needs to have sort order for the whole plugin itself, not a priority option for 1 tiny part of the plugin. This is what the idea is.

    Posted: 3 years ago #
  5. inspiredmind
    Inactive

    Thank you for info and input.
    "crstauf", I'll take a look at this plug-in.

    I get the impression (correct me if I am wrong) that hook priority is only relative to the various actions within the given plug-in, as opposed to across a set of plug-ins. If that's the case, then it does not provide a means to control the priority of a range of plug-ins that are all hooking into the same area.
    Perhaps that is what "dhaupin" is also saying.

    Posted: 3 years ago #
  6. dhaupin
    Inactive

    @inspiredmind - Yes that is what im trying to say. Lets use an example with is_ssl() function. Its very outdated and pretty much useless for most modern servers. In order to make it work, it must be spoofed with extra SSL headers and port logic. Since there is no hook there, and action really wont work well, it must be created raw as a $_SERVER array-spoof plugin.

    So it must run first in the list in order to get it to run before other plugins that may use is_ssl(). Even if somehow you could use an action fluidly, it would still be required to run first...especially if another action exists in the same priority level.

    So in an ideal world, there would be sort order ability on the plugin list. This seems to be what the suggested mod above does, but there is a paradox: its still a plugin and is a victim of "circular" logic. The sorting needs to happen at a deeper level either before or after all the plugins are spooled up...and def before parse chain.

    WordPress isnt the only platform with this dilemma, and most of the time sort order doesnt matter that much....but in cases where you are preparing globals, classes, or routing triggers for other plugins, it becomes essential.

    Posted: 3 years ago #
  7. crstauf
    Inactive

    @dhaupin: from what i can tell, WordPress loads the plugins in the order that they are saved in the active_plugins option, so all the plugin does is save the order you determine over that option. the priority of which the plugin itself is loaded is irrelevant, as there's no "active" reordering to do.

    Posted: 3 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    1 Vote
  • Status

    This idea is under consideration