Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
210 views
in Plugins by
edited by
My shortest question ever ;)

Edit: Can I reset the theme by:

        $themeclass = qa_load_theme_class('mytheme', 'custom', qa_content_prepare(), 'anything');

with a plugin? Or even call it from a plugin and override the former one?

 

I found only this qa-page.php hack: http://www.question2answer.org/qa/1833/how-to-set-theme-by-url-parameter?show=1837#a1837
Q2A version: 1.6.3

1 Answer

0 votes
by

Okay, got it. You need to override function qa_get_site_theme().

1. Open qa-plugin.php, register the override:

    // core function overrides
    qa_register_plugin_overrides('my-q2apro-overrides.php');

2. Create a file my-q2apro-overrides.php and do the override:

<?php
/*
    Plugin Name: MY PLUGIN
*/

    if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
        header('Location: ../../');
        exit;
    }


    // override theme
    function qa_get_site_theme()
    {
        return 'my-custom-theme';
        // default
        return qa_opt(qa_is_mobile_probably() ? 'site_theme_mobile' : 'site_theme');
    }

/*
    Omit PHP closing tag to help avoid accidental output
*/

 

by
And domain specific (as I needed it):

    function qa_get_site_theme()
    {
        if($_SERVER['SERVER_NAME']=='specialdomain.com') {
            // qa_html_theme_base::head_script();
            return 'my-custom-theme';
        }       
        // default
        return qa_opt(qa_is_mobile_probably() ? 'site_theme_mobile' : 'site_theme');
    }
...