本文整理汇总了PHP中get_raw_theme_root函数的典型用法代码示例。如果您正苦于以下问题:PHP get_raw_theme_root函数的具体用法?PHP get_raw_theme_root怎么用?PHP get_raw_theme_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_raw_theme_root函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_detheme_number
function get_detheme_number()
{
global $wp_theme_directories;
$stylesheet = get_stylesheet();
$theme_root = get_raw_theme_root($stylesheet);
if (false === $theme_root) {
$theme_root = WP_CONTENT_DIR . '/themes';
} elseif (!in_array($theme_root, (array) $wp_theme_directories)) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
$theme = $theme_root . '/' . $stylesheet . '/style.css';
if (!file_exists($theme)) {
return __('Stylesheet is missing.', 'billio');
}
$themeinfo = get_file_data($theme, array('SN' => 'Serial Number'), '');
return $themeinfo['SN'];
}
开发者ID:estrategasdigitales,项目名称:lactibox,代码行数:17,代码来源:framework.php
示例2: get_stylesheet_root
/**
* Retrieve the stylesheet root of the previewed theme.
*
* @since 3.4.0
*
* @return string Theme root.
*/
public function get_stylesheet_root()
{
return get_raw_theme_root($this->get_stylesheet(), true);
}
开发者ID:RA2WP,项目名称:RA2WP,代码行数:11,代码来源:class-wp-customize-manager.php
示例3: switch_theme
/**
* Switches current theme to new template and stylesheet names.
*
* @since 2.5.0
* @uses do_action() Calls 'switch_theme' action, passing the new theme.
*
* @param string $template Template name
* @param string $stylesheet Stylesheet name.
*/
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) > 1) {
update_option('template_root', get_raw_theme_root($template, true));
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
}
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);
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:32,代码来源:theme.php
示例4: switch_theme
/**
* Switches the theme.
*
* Accepts one argument: $stylesheet of the theme. It also accepts an additional function signature
* of two arguments: $template then $stylesheet. This is for backwards compatibility.
*
* @since 2.5.0
*
* @global array $wp_theme_directories
* @global WP_Customize_Manager $wp_customize
* @global array $sidebars_widgets
*
* @param string $stylesheet Stylesheet name
*/
function switch_theme($stylesheet)
{
global $wp_theme_directories, $wp_customize, $sidebars_widgets;
$_sidebars_widgets = null;
if ('wp_ajax_customize_save' === current_action()) {
$_sidebars_widgets = $wp_customize->post_value($wp_customize->get_setting('old_sidebars_widgets_data'));
} elseif (is_array($sidebars_widgets)) {
$_sidebars_widgets = $sidebars_widgets;
}
if (is_array($_sidebars_widgets)) {
set_theme_mod('sidebars_widgets', array('time' => time(), 'data' => $_sidebars_widgets));
}
$nav_menu_locations = get_theme_mod('nav_menu_locations');
if (func_num_args() > 1) {
$stylesheet = func_get_arg(1);
}
$old_theme = wp_get_theme();
$new_theme = wp_get_theme($stylesheet);
$template = $new_theme->get_template();
update_option('template', $template);
update_option('stylesheet', $stylesheet);
if (count($wp_theme_directories) > 1) {
update_option('template_root', get_raw_theme_root($template, true));
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
} else {
delete_option('template_root');
delete_option('stylesheet_root');
}
$new_name = $new_theme->get('Name');
update_option('current_theme', $new_name);
// Migrate from the old mods_{name} option to theme_mods_{slug}.
if (is_admin() && false === get_option('theme_mods_' . $stylesheet)) {
$default_theme_mods = (array) get_option('mods_' . $new_name);
if (!empty($nav_menu_locations) && empty($default_theme_mods['nav_menu_locations'])) {
$default_theme_mods['nav_menu_locations'] = $nav_menu_locations;
}
add_option("theme_mods_{$stylesheet}", $default_theme_mods);
} else {
/*
* Since retrieve_widgets() is called when initializing a theme in the Customizer,
* we need to to remove the theme mods to avoid overwriting changes made via
* the Customizer when accessing wp-admin/widgets.php.
*/
if ('wp_ajax_customize_save' === current_action()) {
remove_theme_mod('sidebars_widgets');
}
if (!empty($nav_menu_locations)) {
$nav_mods = get_theme_mod('nav_menu_locations');
if (empty($nav_mods)) {
set_theme_mod('nav_menu_locations', $nav_menu_locations);
}
}
}
update_option('theme_switched', $old_theme->get_stylesheet());
/**
* Fires after the theme is switched.
*
* @since 1.5.0
*
* @param string $new_name Name of the new theme.
* @param WP_Theme $new_theme WP_Theme instance of the new theme.
*/
do_action('switch_theme', $new_name, $new_theme);
}
开发者ID:renanmpimentel,项目名称:WordPress,代码行数:78,代码来源:theme.php
示例5: bp_deactivation
/**
* Runs on BuddyPress deactivation
*
* @since BuddyPress (1.6)
*
* @uses do_action() Calls 'bp_deactivation' hook
*/
function bp_deactivation()
{
// Force refresh theme roots.
delete_site_transient('theme_roots');
// Switch to WordPress's default theme if current parent or child theme
// depend on bp-default. This is to prevent white screens of doom.
if (in_array('bp-default', array(get_template(), get_stylesheet()))) {
switch_theme(WP_DEFAULT_THEME, WP_DEFAULT_THEME);
update_option('template_root', get_raw_theme_root(WP_DEFAULT_THEME, true));
update_option('stylesheet_root', get_raw_theme_root(WP_DEFAULT_THEME, true));
}
// Use as of (1.6)
do_action('bp_deactivation');
// @deprecated as of (1.6)
do_action('bp_loader_deactivate');
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:23,代码来源:bp-core-update.php
示例6: switch_theme
/**
* Switches the theme.
*
* Accepts one argument: $stylesheet of the theme. It also accepts an additional function signature
* of two arguments: $template then $stylesheet. This is for backwards compatibility.
*
* @since 2.5.0
*
* @param string $stylesheet Stylesheet name
*/
function switch_theme($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);
if (func_num_args() > 1) {
$template = $stylesheet;
$stylesheet = func_get_arg(1);
} else {
$template = $new_theme->get_template();
}
update_option('template', $template);
update_option('stylesheet', $stylesheet);
if (count($wp_theme_directories) > 1) {
update_option('template_root', get_raw_theme_root($template, true));
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
} else {
delete_option('template_root');
delete_option('stylesheet_root');
}
$new_name = $new_theme->get('Name');
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());
/**
* Fires after the theme is switched.
*
* @since 1.5.0
*
* @param string $new_name Name of the new theme.
* @param WP_Theme $new_theme WP_Theme instance of the new theme.
*/
do_action('switch_theme', $new_name, $new_theme);
}
开发者ID:dot2006,项目名称:jobify,代码行数:50,代码来源:theme.php
示例7: switch_theme
/**
* Switches current theme to new template and stylesheet names.
*
* @since 2.5.0
* @uses do_action() Calls 'switch_theme' action on updated theme display name.
*
* @param string $template Template name
* @param string $stylesheet Stylesheet name.
*/
function switch_theme($template, $stylesheet)
{
global $wp_theme_directories;
update_option('template', $template);
update_option('stylesheet', $stylesheet);
if (count($wp_theme_directories) > 1) {
update_option('template_root', get_raw_theme_root($template, true));
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
}
delete_option('current_theme');
$theme = get_current_theme();
if (is_admin() && false === get_option("theme_mods_{$stylesheet}")) {
$default_theme_mods = (array) get_option("mods_{$theme}");
add_option("theme_mods_{$stylesheet}", $default_theme_mods);
}
do_action('switch_theme', $theme);
}
开发者ID:thomashorta31,项目名称:BHS,代码行数:26,代码来源:theme.php
示例8: _wp_get_theme
/**
* Check to see if the theme is already installed.
*
* @since 3.4
* @access private
*
* @param object $theme - A WordPress.org Theme API object.
* @return string Theme status.
*/
private function _wp_get_theme($stylesheet = null, $theme_root = null)
{
global $wp_theme_directories;
if (empty($stylesheet)) {
$stylesheet = get_stylesheet();
}
if (empty($theme_root)) {
$theme_root = get_raw_theme_root($stylesheet);
if (false === $theme_root) {
$theme_root = WP_CONTENT_DIR . '/themes';
} elseif (!in_array($theme_root, (array) $wp_theme_directories)) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
}
if (class_exists('WP_Theme')) {
return new WP_Theme($stylesheet, $theme_root);
} else {
WPRC_Loader::includeClass('class-wp-theme.php');
return new WP_Theme($stylesheet, $theme_root);
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:30,代码来源:wprc-theme-install-list-table.php
示例9: get_theme_root
function get_theme_root($stylesheet_or_template = false)
{
global $wp_theme_directories;
if ($stylesheet_or_template && ($theme_root = get_raw_theme_root($stylesheet_or_template))) {
// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
// This gives relative theme roots the benefit of the doubt when things go haywire.
if (!in_array($theme_root, (array) $wp_theme_directories)) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
} else {
$theme_root = WP_CONTENT_DIR . '/themes';
}
return apply_filters('theme_root', $theme_root);
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:14,代码来源:theme.php
示例10: filter_stylesheet_root
/**
* Get the switched stylesheet (child) theme root path.
* Used as a callback for 'pre_option_stylesheet_root' WP filter.
*
* @return string
* @since 0.4
*/
public function filter_stylesheet_root($stylesheet_root = '')
{
$stylesheet = $this->get_stylesheet();
if (!empty($stylesheet)) {
$stylesheet_root = get_raw_theme_root($stylesheet, true);
}
return $stylesheet_root;
}
开发者ID:austbot,项目名称:WP-Conditional-Themes,代码行数:15,代码来源:main.php
示例11: base_url
/**
* Retrieves the absolute URL to the current file.
* Like a WordPress function `plugins_url`.
*
* @link https://codex.wordpress.org/Function_Reference/plugins_url
* @since 1.0.1
* @param string $file_path Optional. Extra path appended to the end of the URL.
* @param string $module_path A full path to the core or module file.
* @return string
*/
public static function base_url($file_path = '', $module_path)
{
$module_path = wp_normalize_path($module_path);
$module_dir = dirname($module_path);
$plugin_dir = wp_normalize_path(WP_PLUGIN_DIR);
$stylesheet = get_stylesheet();
$theme_root = get_raw_theme_root($stylesheet);
$theme_dir = "{$theme_root}/{$stylesheet}";
if (0 === strpos($module_path, $plugin_dir)) {
$url = plugin_dir_url($module_path);
} else {
if (false !== strpos($module_path, $theme_dir)) {
$explode = explode($theme_dir, $module_dir);
$url = get_stylesheet_directory_uri() . end($explode);
} else {
$site_url = site_url();
$abs_path = wp_normalize_path(ABSPATH);
$url = str_replace(untrailingslashit($abs_path), $site_url, $module_dir);
}
}
if ($file_path && is_string($file_path)) {
$url = trailingslashit($url);
$url .= ltrim($file_path, '/');
}
return apply_filters('cherry_core_base_url', $url, $file_path, $module_path);
}
开发者ID:CherryFramework,项目名称:cherry-framework,代码行数:36,代码来源:cherry-core.php
示例12: get_instance
/**
* Determine if instance already exists and Return Instance
*
* Attention: The method MUST be called from plugin core file at first to set correct path to plugin!
*
* @author peshkov@UD
*/
public static function get_instance($args = array())
{
$class = get_called_class();
//** We must be sure that final class contains static property $instance to prevent issues. */
if (!property_exists($class, 'instance')) {
exit("{$class} must have property \$instance");
}
$prop = new \ReflectionProperty($class, 'instance');
if (!$prop->isStatic()) {
exit("Property \$instance must be <b>static</b> for {$class}");
}
if (null === $class::$instance) {
//** Get custom ( undefined ) Headers from style.css */
global $wp_theme_directories;
$stylesheet = get_stylesheet();
$theme_root = get_raw_theme_root($stylesheet);
if (false === $theme_root) {
$theme_root = WP_CONTENT_DIR . '/themes';
} elseif (!in_array($theme_root, (array) $wp_theme_directories)) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
$data = get_file_data($theme_root . '/' . get_stylesheet() . '/style.css', array('uservoice_url' => 'UserVoice', 'support_url' => 'Support'));
$t = wp_get_theme(get_template());
$args = array_merge((array) $args, $data, array('name' => $t->get('Name'), 'version' => $t->get('Version'), 'template' => $t->get('Template'), 'domain' => $t->get('TextDomain'), 'is_child' => is_child_theme(), 'root_path' => trailingslashit(wp_normalize_path(get_template_directory())), 'root_url' => trailingslashit(wp_normalize_path(get_template_directory_uri())), 'schema_path' => trailingslashit(wp_normalize_path(get_template_directory())) . 'composer.json', 'boot_file' => trailingslashit(wp_normalize_path(get_template_directory())) . 'style.css'));
//echo "<pre>"; print_r( $args ); echo "</pre>"; die();
$class::$instance = new $class($args);
}
return $class::$instance;
}
开发者ID:ksan5835,项目名称:rankproperties,代码行数:36,代码来源:class-bootstrap-theme.php
注:本文中的get_raw_theme_root函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论