Wordpress plugin idea

I have the idea of ​​launching multiple WordPress themes per ounce. It might be nice to embed the wordpress plugin if possible. And yes, I could undertake such a task if it is not ridiculously difficult.

(Also, if you are interested in joining with me, let me know (leave a comment), I am decent in javascript and php, but not big, and would like to help!)

This is how I see it working: The current "set" theme is available here: "www.foo.com/" The second theme is available here: "www.foo.com/index.php?set_theme=theme2&" The third theme is available here: "www.foo.com/index.php?set_theme=THEME_NAME_HERE&", etc.

This can be used to bounce JavaScript. For example, if you go to www.foo.com/?page_id=9 and enable javascript, you will be redirected to javascript by "www.foo.com/index.php?set_theme=THEM_WITH_JAVASCRIPT&page_id=9".

Here is how I imagine how the plugin looks / works:

   if(isset($_GET['set_theme'])){
       $loadme = cleaned($_GET['set_theme']);       
       if($loadme exists){
          loadtheme($loadme);
       } else {
          //go on as usual, as if this plugin doesnt exist
       }
    } else {
       //go on as usual, as if this plugin doesnt exist
    }

And of course, all links would have to be ad? set_theme = FOOBAR &

So my main questions are:

  • How and where does Wordpress choose the current theme?
  • How / where can you change this for internal links?
    if (Iset ($ _ GET ['set_theme']))) {echo "? set_theme =". $ _GET ['set_theme']; }
  • Do you know of any good websites to point me in the right direction regarding how to create WP plugins?
+3
source share
3

, 98%. Word Switcher Reloaded.

ts_get_theme() :

    function ts_get_theme() {
            if (!empty($_GET["wptheme"])) {
                return  $_GET["wptheme"];
            }        else {
                    return '';
            }
    }
0
+1

Actually no plugin needed, just add it to functions.php:

        function theme_switcher() {
    if(isset($_GET['theme']) $theme = $_GET['theme'];
    global $wpdb;
    if (isset($theme)) {
    $wpdb->prefix
    $queries = "UPDATE ".$wpdb->prefix."options SET option_value = ‘".$theme."‘ WHERE option_name = ‘template’ OR option_name = ‘stylesheet’ OR option_name = ‘current_theme’;";
    $wpdb->query($query);
    }
    }
add_action('wp_head','switchTheme')

then use mywebsite.com/?theme=myNewThemeto switch them

Disclaimer: Unverified !!

0
source

Source: https://habr.com/ru/post/1789884/


All Articles