make_site_theme

Creates a site theme.

Description

(false|string) make_site_theme(); 

}

Returns (false|string)


Usage

  1. if ( !function_exists( 'make_site_theme' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = make_site_theme(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/upgrade.php  
  1. function make_site_theme() { 
  2. // Name the theme after the blog. 
  3. $theme_name = __get_option('blogname'); 
  4. $template = sanitize_title($theme_name); 
  5. $site_dir = WP_CONTENT_DIR . "/themes/$template"; 
  6.  
  7. // If the theme already exists, nothing to do. 
  8. if ( is_dir($site_dir)) { 
  9. return false; 
  10.  
  11. // We must be able to write to the themes dir. 
  12. if (! is_writable(WP_CONTENT_DIR . "/themes")) { 
  13. return false; 
  14.  
  15. umask(0); 
  16. if (! mkdir($site_dir, 0777)) { 
  17. return false; 
  18.  
  19. if (file_exists(ABSPATH . 'wp-layout.css')) { 
  20. if (! make_site_theme_from_oldschool($theme_name, $template)) { 
  21. // TODO: rm -rf the site theme directory. 
  22. return false; 
  23. } else { 
  24. if (! make_site_theme_from_default($theme_name, $template)) 
  25. // TODO: rm -rf the site theme directory. 
  26. return false; 
  27.  
  28. // Make the new site theme active. 
  29. $current_template = __get_option('template'); 
  30. if ($current_template == WP_DEFAULT_THEME) { 
  31. update_option('template', $template); 
  32. update_option('stylesheet', $template); 
  33. return $template;