Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




switch_theme [ WordPress Function ]

switch_theme ( $template, $stylesheet )
Parameters:
  • (string) $template Template name
  • (string) $stylesheet Stylesheet name.
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 ) > ) {
        
update_option'template_root'get_raw_theme_root$templatetrue ) );
        
update_option'stylesheet_root'get_raw_theme_root$stylesheettrue ) );
    }

    
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

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics