Ticket #5346: current_theme.diff
File current_theme.diff, 2.2 KB (added by , 18 years ago) |
---|
-
wp-includes/theme.php
294 294 } 295 295 296 296 function get_current_theme() { 297 if ( $theme = get_option('current_theme') ) 298 return $theme; 299 297 300 $themes = get_themes(); 298 301 $theme_names = array_keys($themes); 299 302 $current_template = get_option('template'); … … 310 313 } 311 314 } 312 315 316 update_option('current_theme', $current_theme); 317 313 318 return $current_theme; 314 319 } 315 320 … … 447 452 echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />'; 448 453 } 449 454 455 function switch_theme($template, $stylesheet) { 456 update_option('template', $template); 457 update_option('stylesheet', $stylesheet); 458 delete_option('current_theme'); 459 $theme = get_current_theme(); 460 do_action('switch_theme', $theme); 461 } 462 450 463 function validate_current_theme() { 451 464 // Don't validate during an install/upgrade. 452 465 if ( defined('WP_INSTALLING') ) 453 466 return true; 454 467 455 468 if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) { 456 update_option('template', 'default'); 457 update_option('stylesheet', 'default'); 458 do_action('switch_theme', 'Default'); 469 switch_theme('default', 'default'); 459 470 return false; 460 471 } 461 472 462 473 if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) { 463 update_option('template', 'default'); 464 update_option('stylesheet', 'default'); 465 do_action('switch_theme', 'Default'); 474 switch_theme('default', 'default'); 466 475 return false; 467 476 } 468 477 -
wp-admin/themes.php
5 5 check_admin_referer('switch-theme_' . $_GET['template']); 6 6 7 7 if ('activate' == $_GET['action']) { 8 if ( isset($_GET['template']) ) 9 update_option('template', $_GET['template']); 10 11 if ( isset($_GET['stylesheet']) ) 12 update_option('stylesheet', $_GET['stylesheet']); 13 14 do_action('switch_theme', get_current_theme()); 15 8 switch_theme($_GET['template'], $_GET['stylesheet']); 16 9 wp_redirect('themes.php?activated=true'); 17 10 exit; 18 11 }