Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Plugins by
For example, in the qa-include/qa-page.php , I want to change some code from the orgin:

$qa_content['logo']='<A HREF="'.qa_html .... (Line611)

to my own:

$qa_content['logo']='<A HREF="http://.....

But I don't want to hard-code the Core, so I want to make a plugin.

The example code lies in the function qa_content_prepare($voting=false, $categoryids=null), and I guess I can do it by overriding it.

if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

I've read about  qa_content_prepare in some example plugins

    Line 63:             $qa_content=qa_content_prepare();
    Line 50:             $qa_content=qa_content_prepare();
    Line 35:             $qa_content=qa_content_prepare();
    Line 47:         $qa_content=qa_content_prepare();

but 4 examples above are "widget" plugin. I just want the plugin to override the function in the Core and don't want to create a widget to do that.

Can you help me ( @greenspan, @NoahY , @svivian .... )
Q2A version: lastest

1 Answer

+1 vote

The easiest method would be to make an advanced theme and override the logo function, something like this:

function logo()
        '<DIV CLASS="qa-logo">',
        str_replace('HREF="./', "HREF="http://yoursite.com/', $this->content['logo']),

You may need to use something more advanced like preg_replace to catch the exact URL.

I want to make a plugin because I want this to affect all installed themes.

Anyway, thank you. Your solution is a good workaround.
In that case you can create a layer plugin: http://www.question2answer.org/layers.php