WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Is functions.php called before plugins? (10 posts)

  1. richarduk
    Member
    Posted 3 years ago #

    I'm trying to pass a variable to a plugin. The variable is the url of the referring page. I'm currently putting the bit of code to get this in functions.php

    Is functions.php called befoAre plugins?

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

    No, the theme's functions.php file is called well after plugins are loaded.

  3. richarduk
    Member
    Posted 3 years ago #

    Thanks.

    That explains it.

    Is there a page I can add my code snippet to that's called before the plugins? How about config.php, as that doesn't get updated?

  4. Xephan
    Member
    Posted 3 years ago #

    If you just need the url of the referring page, you could grab that anywhere using $_SERVER['HTTP_REFERER'], there shouldn't be any need to run other code elsewhere.

  5. richarduk
    Member
    Posted 3 years ago #

    I want to pass it to the plugin, that's the problem. I'm guessing that all the theme files are called well after the plugins?

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

    The $_SERVER['HTTP_REFERER'] is a superglobal. You can get it in plugins directly. You don't need any theme code to do that.

  7. hospedagem de sites
    Member
    Posted 3 years ago #

    just as curiosity: what's the exact output of $_SERVER['HTTP_REFERER']? I need the referrer's URL to lack the 'http://wwww.', how could I do that?

  8. Xephan
    Member
    Posted 3 years ago #

    @hospedagem: the exact output is the referring page's url ;)

    So the only way you can be sure there isn't the www is to do a str_replace to remove any leading www.

  9. richarduk
    Member
    Posted 3 years ago #

    Thanks, Otto. In my case it didn't help, but it's useful to know.

  10. toto
    Member
    Posted 3 years ago #

    Can we modify, add, or change params in plugins through functions.php ?

    I have a plugin and i wand to change the title of one field in the plugin. But every time i update the plugin i loose the changes.

    Is there a way to modify plugin and to save the changes for future updates of these plugins?

    Thanks friends

Topic Closed

This topic has been closed to new replies.

About this Topic