make_site_theme() - WordPress 函数参考中文文档

返回介绍

make_site_theme()

发布于 2017-09-11 字数1953 浏览 899 评论 0

make_site_theme()

Creates a site theme.


描述


返回值

(false|string)


源代码

File: wp-admin/includes/upgrade.php

function make_site_theme() {
	// Name the theme after the blog.
	$theme_name = __get_option('blogname');
	$template = sanitize_title($theme_name);
	$site_dir = WP_CONTENT_DIR . "/themes/$template";

	// If the theme already exists, nothing to do.
	if ( is_dir($site_dir)) {
		return false;
	}

	// We must be able to write to the themes dir.
	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
		return false;
	}

	umask(0);
	if (! mkdir($site_dir, 0777)) {
		return false;
	}

	if (file_exists(ABSPATH . 'wp-layout.css')) {
		if (! make_site_theme_from_oldschool($theme_name, $template)) {
			// TODO: rm -rf the site theme directory.
			return false;
		}
	} else {
		if (! make_site_theme_from_default($theme_name, $template))
			// TODO: rm -rf the site theme directory.
			return false;
	}

	// Make the new site theme active.
	$current_template = __get_option('template');
	if ($current_template == WP_DEFAULT_THEME) {
		update_option('template', $template);
		update_option('stylesheet', $template);
	}
	return $template;
}

更新日志

Version 描述
1.5.0 Introduced.

相关函数

Uses

  • wp-admin/includes/upgrade.php:
    make_site_theme_from_oldschool()
  • wp-admin/includes/upgrade.php:
    make_site_theme_from_default()
  • wp-includes/formatting.php:
    sanitize_title()
  • wp-includes/option.php:
    update_option()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!