Skip to content

Instantly share code, notes, and snippets.

@ademalp
Created October 23, 2018 07:04
Show Gist options
  • Save ademalp/873d6d51892aea075afa1d783f258a77 to your computer and use it in GitHub Desktop.
Save ademalp/873d6d51892aea075afa1d783f258a77 to your computer and use it in GitHub Desktop.
<?php
if(isset($_GET['tm'])){
$tm = $_GET['tm'];
if(is_dir("wp-content/themes/".$tm)){
define('WP_USE_THEMES', false);
include('path/to/wpsite/wp-load.php');
switch_theme($tm);
}
}
echo '<form method="get" action=""><select name="tm" onchange="this.form.submit()">';
$themes = glob('wp-content/themes/*');
foreach($themes as $theme){
if(is_dir($theme)){
echo '<option>'.basename($theme)."</option>";
}
}
echo '</select></form>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment