Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
464 views
in Q2A Core by
Is there a variable or standard way to get base URL of site from within plugin layer?

2 Answers

+1 vote
by

Yes, depending on what exactly you want. In your plugin you will override the load_module function, which gets passed $directory and $urltoroot. It's a good idea to save these to your class. In my Markdown plugin for example, I have this:

class qa_markdown_editor
{
    var $path;
    var $urltoroot;

    function load_module($path, $urltoroot)
    {
        $this->path = $path;
        $this->urltoroot = $urltoroot;
    }
}

$path will be something like /var/www/yoursite/qa/qa-plugin/plugin_name - you can use $this->path to include any other PHP files from your plugin folder.

$urltoroot will be something like http://example.com/qa/ - you can use $this->urltoroot to output URLs for links.

One other variable is QA_INCLUDE_DIR, which points to your qa-includes directory. useful if you need to include certain files like qa-util-string.php.

0 votes
by

I wanted to filter the way content rendered.

So in my qa-theme.php I just did this:

    class qa_html_theme extends qa_html_theme_base
    {
        function some_fn()
        {
        global $qa_root_url_inferred; // This is site root URL.

        }

    }
 

by
This does not work. Any other alternative?
...