switch_theme [ WordPress Function ]
switch_theme ( $template, $stylesheet )
| Parameters: |
|
| Uses: | |
| Defined at: |
|
Switches current theme to new template and stylesheet names.
Source
<?php
function switch_theme( $template, $stylesheet ) {
global $wp_theme_directories, $sidebars_widgets;
if ( is_array( $sidebars_widgets ) )
set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) );
$old_theme = wp_get_theme();
$new_theme = wp_get_theme( $stylesheet );
$new_name = $new_theme->get('Name');
update_option( 'template', $template );
update_option( 'stylesheet', $stylesheet );
if ( count( $wp_theme_directories ) > 1 ) {
update_option( 'template_root', get_raw_theme_root( $template, true ) );
update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
}
update_option( 'current_theme', $new_name );
if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
$default_theme_mods = (array) get_option( 'mods_' . $new_name );
add_option( "theme_mods_$stylesheet", $default_theme_mods );
}
update_option( 'theme_switched', $old_theme->get_stylesheet() );
do_action( 'switch_theme', $new_name, $new_theme );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/switch theme « WordPress Codex
Description. Switches current theme to new template and stylesheet names. Usage. <?php switch_theme( $template, $stylesheet ) ?> Parameters. $template ...
codex.wordpress.org - Switch_Theme vs. Theme Switching
Jun 29, 2011 ... The switch_theme function is exactly what is called when an Administrator changes his WordPress Theme from the Appearance menu.
shibashake.com - Switchtheme | drupal.org
Aug 19, 2006 ... Switchtheme provides optional support for Browscap module to ... on how to modify a single theme and use Switchtheme to allow users to ...
drupal.org - Does the switch_theme action run when you're upgrading a theme ...
Mar 19, 2011 ... It does some stuff with upgrader_post_install hook (seems like a good candidate) and it does run switch_theme() under some conditions (that I ...
wordpress.stackexchange.com