Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.3k views
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

  q2a\qa-plugin\example-page\qa-example-page.php
    Line 63:             $qa_content=qa_content_prepare();
  q2a\qa-plugin\NoahY-q2a-faq\qa-faq-page.php
    Line 50:             $qa_content=qa_content_prepare();
  q2a\qa-plugin\svivian-badges\qa-badge-page.php
    Line 35:             $qa_content=qa_content_prepare();
  q2a\qa-plugin\svivian-q2a-user-activity-plus\qa-user-activity.php
    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
by

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

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

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

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

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