WordPress.org

Ready to get started?Download WordPress

Forums

Last function that WP runs (6 posts)

  1. MHalukK
    Member
    Posted 3 years ago #

    Hello,

    What's the last single file/procedure/or function that runs the last for WP? The answer must hold true for all cases, themes. userroles etc.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 3 years ago #

    The shutdown_action_hook function is called last, which calls the "shutdown" action. If you want to hook something in to the shutdown, the "shutdown" action hook is the place to do it.

    The very, very last function called is wp_cache_close(), which is in fact a do nothing function, but remains there in case a plugin implements a different kind of object cache.

  3. MHalukK
    Member
    Posted 3 years ago #

    Thank you for your reply. That's an excellent reply. Do you also know of an internal procedure that runs for all cases/themes which will give me the option to output a oneliner which will output <iframe><iframe> code somewhere right before </body> or right after <body>

    I can do this in wp-config.php but then that <iframe></iframe> code goes out there before the <doc type>. And that is no good as far as creating a valid xhtml.

    I think the best way to handle what I want is to write a plug-in but I do now know how to write one.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 3 years ago #

    Because the theme controls output of the web page, there is no absolutely certain way to output code in the footer area.

    However, all themes should include the call to wp_footer() just before the ending /body code (or relatively close to it). Therefore, if you use the wp_footer action hook, you can hit like 95% of cases.

    function output_into_footer() {
    echo 'whatever';
    }
    add_action('wp_footer','output_into_footer');

    This is not guaranteed, but it usually works.

  5. MHalukK
    Member
    Posted 3 years ago #

    Did you just give me a plug in code? Or if not, what is it? All I can tell it's an action. hook. And as far as I know, that should go in the functions.php of the current theme, right? please confirm.

    I wish there was a single call which can output somewhere in between <body> and </body> and runs no matter what whatever the theme or template is... ( excluding rss feeds of course which are all xml ).

    so you are saying that since the output of the page is handled by template, there is really no way to guarantee to run a function/procedure from the wp core for all times?

    Also, what are the problems or consequences of putting an iframe as the first thing in html output, even before doc type?

    what is potantially so bad about this following;

    <iframe src='whatever.inc'></iframe>
    <doc type....>
    <html>
    ...
    </html>

    assuming what'sin between <doc type and </html> is perfectly valid.

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 3 years ago #

    Lot of questions there.

    1. You can put that code into a plugin, or into the theme's functions.php file, or whatever. Not much difference.

    2. No, there is no guarantee. Themes do what they want. However, it's a pretty good bet that things like wp_footer() are implemented in most themes.

    3. Well, doing stuff like that will make your page invalid, and some browsers won't display your iframe, or might display the page incorrectly.

Topic Closed

This topic has been closed to new replies.

About this Topic