Advertisement
mikelittle

Theme switcher proof of concept

Jul 11th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: zed1.com Theme switcher
  4. Plugin URI: http://zed1.com/
  5. Description: A plugin that switches themes based on the URI
  6. Version: 0.0.1
  7. Author: Mike Little
  8. Author URI: http://zed1.com/
  9. License: GPL2+
  10. */
  11.  
  12. $z1_which_stylesheet = 'twentyeleven';
  13. $z1_which_template = 'twentyeleven';
  14. add_action('setup_theme', 'z1_determine_theme');
  15. function z1_determine_theme() {
  16.     global $z1_which_stylesheet, $z1_which_template;
  17.     if ( isset( $_SERVER['REQUEST_URI'] ) && ( false !== strpos( $_SERVER['REQUEST_URI'], '/shop/' ) ) ) {
  18.         $z1_which_stylesheet = 'twentyten';
  19.         $z1_which_template = 'twentyten';
  20.     }
  21. }
  22.          
  23. add_filter('stylesheet', 'z1_change_the_stylesheet');
  24. function z1_change_the_stylesheet($stylesheet) {
  25.     global $z1_which_stylesheet;
  26.     return $z1_which_stylesheet;
  27. }
  28.  
  29. add_filter('template', 'z1_change_the_template');
  30. function z1_change_the_template($template) {
  31.     global $z1_which_template;
  32.     return $z1_which_template;
  33. }
  34.  
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement