Support » Fixing WordPress » Get current theme

  • Ferenc Vasóczki



    (first of all, sorry for my poor english).

    I have a big problem guys.
    I want to use a custom theme, if i am on other domain.

    Let’s called the theme name for webshop: “webshop”.
    If user come to for example, he should see this webshop theme.

    I want to change theme, if user come to, to “myplugin” theme.

    Ok, user can access directly.
    Till here, no problem, I am checking the domain, and if user on, i order wp to

    switch_theme('myplugin', 'myplugin');

    my problem is, if the user goes back to, i don’t know, what was the original theme for that page (admin can use any template for webshop).

    if i am using switch_theme function it will update the wp_options table, and set the default theme to switchet theme.

    I thought, i can hack this, and at my very first line of my plugin, i get the actual theme, store it into a session variable, and remember it. But this concept is not good, because any other plugin can switch the theme.

    And from this point, i have no solution to get the original theme name.

    So, what can i do?
    I see several solutions for this problem:

    1.) In my plugins config settings, admin should define, what is the default theme name.
    PRO: i will know the default theme name.
    CONTRA: admin need’s to define this theme in the config file manually, it could be misspelled, but if he/she change the default theme at the dashboard, he should rewrite it at the config file.
    CONSEQUENCES: bad soulution, too many possibilites for errors.

    2.) Somehow i can read it from the database.
    PRO: i always know, what was the template for the wp from the db.
    CONTRA: none
    CONSEQUENCES: this is the ideal solution, i think i shouldn’t explane ths.

    3.) Switching theme without replace the values of current_theme and template rows in the options table.
    PRO: i always know, what was the template for the wp from the db.
    CONTRA: i don’t see any contra for this
    CONSEQUENCES: this could be an optimal solution too.

    4.) i can not do this
    PRO: no pros.
    CONTRA: i think, i shouldn’t explain this.
    CONSEQUENCES: this is not a solution

    5.) when my plugin installs, i’am getting out what is did set in the options table, and store it in the options table.
    PRO: I will always know, what is the template from the dadatabase.
    CONTRA: i need to care about this, if user change the template at the dashboard, and if another plugin, (befor my plugin load) switch the theme, i won’t know, what is the main template for WP.
    CONSEQUENCES: this is not a solution bacuase of contras.

    So, somehow, i should know, what is the template, what admin does set on the Dashboard.

    So as i see, solution number 2 and 3 could be the real solution for my problem.

    Please help me with this, i really need it.
    Thank you

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get current theme’ is closed to new replies.