本文整理汇总了PHP中WP_Theme::get_stylesheet_directory方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::get_stylesheet_directory方法的具体用法?PHP WP_Theme::get_stylesheet_directory怎么用?PHP WP_Theme::get_stylesheet_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::get_stylesheet_directory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveLanguagesPath
public static function resolveLanguagesPath(\WP_Theme $theme)
{
// as taken from wp-includes/class-wp-theme.php:1114
$path = $theme->get_stylesheet_directory();
if ($domainpath = $theme->get('DomainPath')) {
$path .= $domainpath;
} else {
$path .= '/languages';
}
return $path;
}
示例2: procreate
/**
* Runs the actual child theme creation functionality
*
* @global WP_Filesystem_Base $wp_filesystem
*
* @param string $new_theme
* @param WP_Theme $template
*
* @throws Exception If the global filesystem object isn't available
*/
public static function procreate($new_theme, WP_Theme $template)
{
/** @var WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
if (!$wp_filesystem instanceof WP_Filesystem_Base) {
if (!WP_Filesystem()) {
throw new Exception(esc_html__('Could not access the filesystem!', 'child-themify'));
}
}
$oldStylesheet = $template->get_stylesheet();
$templateDirectory = untrailingslashit($template->get_stylesheet_directory());
$oldName = $template->name;
$new_theme_directory = trailingslashit(get_theme_root()) . sanitize_file_name(strtolower($new_theme));
$wp_filesystem->mkdir($new_theme_directory);
$newStylesheet = trailingslashit($new_theme_directory) . 'style.css';
$wp_filesystem->touch($newStylesheet);
$stylesheetContents = <<<EOF
/*
Theme Name: {$new_theme}
Version: 1.0
Description: A child theme of {$oldName}
Template: {$oldStylesheet}
*/
@import url("../{$oldStylesheet}/style.css");
EOF;
$wp_filesystem->put_contents($newStylesheet, $stylesheetContents);
if (file_exists("{$templateDirectory}/screenshot.png")) {
$wp_filesystem->copy("{$templateDirectory}/screenshot.png", "{$new_theme_directory}/screenshot.png");
}
add_settings_error('', 'child-themify', esc_html__('Your child theme was created successfully.', 'child-themify'), 'updated');
}
示例3: loadFile
private function loadFile($file, \WP_Theme $theme)
{
if (!is_file($file) || !preg_match('/\\.ya?ml$/', $file)) {
return;
}
$theme_dir = $theme->get_stylesheet_directory();
$theme_uri = $theme->get_stylesheet_directory_uri();
$components_uri = WP_CONTENT_URL . '/components';
ob_start();
include $file;
$content = ob_get_clean();
try {
$config = Yaml::parse($content);
self::array_overwrite($this->configs, $config);
} catch (ParseException $e) {
trigger_error("Error while parsing {$file}: " . $e->getMessage(), E_USER_WARNING);
}
}