当前位置: 首页>>代码示例>>PHP>>正文


PHP switch_theme函数代码示例

本文整理汇总了PHP中switch_theme函数的典型用法代码示例。如果您正苦于以下问题:PHP switch_theme函数的具体用法?PHP switch_theme怎么用?PHP switch_theme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了switch_theme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: twentythirteen_switch_theme

/**
 * Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
 * to the previously activated theme or the default theme.
 *
 * @since Twenty Thirteen 1.0
 *
 * @param string $theme_name The theme name.
 * @param WP_Theme $theme The theme object.
 * @return void
 */
function twentythirteen_switch_theme($theme_name, $theme)
{
    if ('twentythirteen' != $theme->get_template()) {
        switch_theme($theme->get_template(), $theme->get_stylesheet());
    } elseif ('twentythirteen' != WP_DEFAULT_THEME) {
        switch_theme(WP_DEFAULT_THEME);
    }
    unset($_GET['activated']);
    add_action('admin_notices', 'twentythirteen_upgrade_notice');
}
开发者ID:ninnypants,项目名称:WordPress,代码行数:20,代码来源:back-compat.php

示例2: setUp

 function setUp()
 {
     parent::setUp();
     /* Make sure the active theme is Distilled */
     switch_theme('Distilled');
     /* Include the Distilled function file and extensions */
     require_once '../../functions.php';
     include_once '../extensions/comments-extensions.php';
     include_once '../extensions/content-extensions.php';
     include_once '../extensions/discussion-extensions.php';
     include_once '../extensions/discussion.php';
     include_once '../extensions/dynamic-classes.php';
     include_once '../extensions/footer-extensions.php';
     include_once '../extensions/header-extensions.php';
     include_once '../extensions/helpers.php';
     include_once '../extensions/shortcodes.php';
     include_once '../extensions/sidebar-extensions.php';
     include_once '../extensions/theme-options.php';
     include_once '../extensions/widgets-extensions.php';
     include_once '../extensions/widgets.php';
     /* Setup the theme options */
     $this->theme_options = seamless_default_opt();
     $this->update_test_options('seamless_theme_opt', $this->theme_options);
     /* Define Distilled constants */
     define('THEMATIC_MB', false);
     if (defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE) {
         define('THEMATIC_MB', true);
     }
 }
开发者ID:SeamlessThemes,项目名称:seamless,代码行数:29,代码来源:test-thematic.php

示例3: activate_theme

 private function activate_theme($theme)
 {
     if (!is_string($theme)) {
         return new WP_Error('invalid-argument', 'The activate argument only accepts a string representing a single theme.');
     }
     return switch_theme($theme);
 }
开发者ID:jimlongo56,项目名称:rdiv,代码行数:7,代码来源:manage-themes.php

示例4: _book

 /**
  * Create and switch to a new test book
  */
 private function _book()
 {
     $blog_id = $this->factory->blog->create();
     switch_to_blog($blog_id);
     switch_theme('donham');
     // Pick a theme with some built-in $supported_languages
 }
开发者ID:JackDougherty,项目名称:pressbooks,代码行数:10,代码来源:test-globaltypography.php

示例5: bp_groupblog_blog_defaults

function bp_groupblog_blog_defaults($blog_id)
{
    global $bp, $wp_rewrite;
    // only apply defaults to groupblog blogs
    if (bp_is_groups_component()) {
        switch_to_blog($blog_id);
        // get the site options
        $options = get_site_option('bp_groupblog_blog_defaults_options');
        foreach ((array) $options as $key => $value) {
            update_option($key, $value);
        }
        // override default themes
        if (!empty($options['theme'])) {
            // we want something other than the default theme
            $values = explode("|", $options['theme']);
            switch_theme($values[0], $values[1]);
        }
        // groupblog bonus options
        if (strlen($options['default_cat_name']) > 0) {
            global $wpdb;
            $cat = $options['default_cat_name'];
            $slug = str_replace(' ', '-', strtolower($cat));
            $results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s  WHERE term_id = 1", $cat, $slug));
        }
        if (strlen($options['default_link_cat']) > 0) {
            global $wpdb;
            $cat = $options['default_link_cat'];
            $slug = str_replace(' ', '-', strtolower($cat));
            $results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s  WHERE term_id = 2", $cat, $slug));
        }
        if (isset($options['delete_first_post']) && $options['delete_first_post'] == 1) {
            global $wpdb;
            $statement = "UPDATE {$wpdb->posts} SET post_status = 'draft'  WHERE id = 1";
            $results = $wpdb->query($statement);
        }
        if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1) {
            wp_delete_comment(1);
        }
        if ($options['delete_blogroll_links'] == 1) {
            wp_delete_link(1);
            //delete Wordpress.com blogroll link
            wp_delete_link(2);
            //delete Wordpress.org blogroll link
        }
        if ($options['redirectblog'] == 2) {
            $blog_page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_name' => $options['pageslug'], 'post_title' => $options['pagetitle'], 'post_type' => 'page', 'post_content' => __('<p><strong>This page has been created automatically by the BuddyPress GroupBlog plugin.</strong></p><p>Please contact the site admin if you see this message instead of your blog posts. Possible solution: please advise your site admin to create the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">page template</a> needed for the BuddyPress GroupBlog plugin.<p>', 'groupblog'));
            $blog_page_id = wp_insert_post($blog_page);
            if ($blog_page_id) {
                add_post_meta($blog_page_id, '_wp_page_template', 'blog.php');
            }
            add_post_meta($blog_page_id, 'created_by_groupblog_dont_change', '1');
            // Set the Blog Reading Settings to load the template page as front page
            if ($options['deep_group_integration'] == 1) {
                update_option('show_on_front', 'page');
                update_option('page_on_front', $blog_page_id);
            }
        }
        restore_current_blog();
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:60,代码来源:bp-groupblog-admin.php

示例6: hellJustFrozeOver

 function hellJustFrozeOver()
 {
     $error = error_get_last();
     $currentTheme = wp_get_theme();
     if ($error) {
         $foundOneFromTwentySeries = false;
         $themes = wp_get_themes(array('errors' => false, 'allowed' => null, 'blog_id' => 0));
         foreach ($themes as $slug => $theme) {
             if (strpos($slug, 'twenty') !== false) {
                 switch_theme($theme->get_stylesheet());
                 $foundOneFromTwentySeries = true;
                 break;
             }
         }
         if (!$foundOneFromTwentySeries) {
             //dang, no theme from twenty series was present
             foreach ($themes as $slug => $theme) {
                 if ($theme->get_stylesheet() != $currentTheme->get_stylesheet()) {
                     switch_theme($theme->get_stylesheet());
                     break;
                 }
             }
         }
         $fatalErrorMessage = "Your <b>{$currentTheme->Name}</b> theme threw a fatal error on <b>line #{$error['line']}</b> in {$error['file']}. The error message was: <b>{$error['message']}</b>. Please fix it.'";
         update_option('fatalsafe', $fatalErrorMessage);
         echo "<h1>Don't Panic! Refresh This Page To Get Some Oxygen</h1>";
     }
 }
开发者ID:jituu,项目名称:fatalsafe,代码行数:28,代码来源:fatalsafe.php

示例7: _setupStarterTheme

 static function _setupStarterTheme()
 {
     $dest = WP_CONTENT_DIR . '/themes/timber-starter-theme/';
     $src = __DIR__ . '/../timber-starter-theme/';
     self::_copyDirectory($src, $dest);
     switch_theme('timber-starter-theme');
 }
开发者ID:aauroux,项目名称:timber,代码行数:7,代码来源:test-timber-starter-theme.php

示例8: aka_wp_install

function aka_wp_install($user)
{
    // Set default theme
    $dtheme = wp_get_theme('AKA-Bootstrap-Base');
    if ($dtheme->exists() && $dtheme->is_allowed()) {
        switch_theme($dtheme->get_stylesheet());
    }
    // Set blog description (tagline) to blank
    update_option('blogdescription', '');
    //******************************************************************************
    // ACTIVATE DEFAULT PLUGINS
    //******************************************************************************
    function run_activate_plugin($plugin)
    {
        $current = get_option('active_plugins');
        $plugin = plugin_basename(trim($plugin));
        if (!in_array($plugin, $current)) {
            $current[] = $plugin;
            sort($current);
            do_action('activate_plugin', trim($plugin));
            update_option('active_plugins', $current);
            do_action('activate_' . trim($plugin));
            do_action('activated_plugin', trim($plugin));
        }
        return null;
    }
    run_activate_plugin('advanced-custom-fields-pro/acf.php');
    run_activate_plugin('akasettings/akasettings.php');
    run_activate_plugin('wp-migrate-db-pro/wp-migrate-db-pro.php');
    run_activate_plugin('manual-image-crop/manual-image-crop.php');
    run_activate_plugin('safe-redirect-manager/safe-redirect-manager.php');
    run_activate_plugin('title-and-nofollow-for-links/title-and-nofollow-for-links.php');
    run_activate_plugin('akapostorderbytaxonomy/akapostorderbytaxonomy.php');
    run_activate_plugin('post-type-archive-links/post-type-archive-links.php');
}
开发者ID:asha23,项目名称:folio,代码行数:35,代码来源:install.php

示例9: set_theme

 static function set_theme()
 {
     $stylesheet = sanitize_text_field($_POST['stylesheet']);
     do_action('jetpack_start_select_theme', $stylesheet);
     switch_theme($stylesheet);
     wp_send_json_success();
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:7,代码来源:select-theme.php

示例10: showThemePage

 /**
  * Show the theme page which has a form allowing you to child theme currently selected theme.
  */
 function showThemePage()
 {
     if (!empty($_POST['theme_name'])) {
         $theme_name = $_POST['theme_name'];
         $description = empty($_POST['description']) ? '' : $_POST['description'];
         $author_name = empty($_POST['author_name']) ? '' : $_POST['author_name'];
         $result = $this->_make_child_theme($theme_name, $description, $author_name);
         if (is_wp_error($result)) {
             $error = $result->get_error_message();
             // $error is rendered below
         } else {
             var_dump($result);
             var_dump(switch_theme($result['parent_template'], $result['new_theme']));
             // TODO: put a redirect in here somehow?
             //wp_redirect( admin_url('themes.php') ); //buffer issue :-(
             printf(__('<a href="%s">Theme switched!</a>', 'one-click-child-theme'), admin_url('themes.php'));
             exit;
         }
     }
     if (!isset($theme_name)) {
         $theme_name = '';
     }
     if (!isset($description)) {
         $description = '';
     }
     if (empty($author)) {
         global $current_user;
         get_currentuserinfo();
         $author = $current_user->display_name;
     }
     require $this->plugin_dir . '/panel.php';
 }
开发者ID:krystian-thiede,项目名称:local-demo,代码行数:35,代码来源:one-click-child-theme.php

示例11: teardDown

 public function teardDown()
 {
     $GLOBALS['wp_theme_directories'] = $this->original_theme_directories;
     switch_theme($this->original_stylesheet);
     remove_filter('theme_root', array($this, '_theme_root'));
     remove_filter('stylesheet_root', array($this, '_theme_root'));
     remove_filter('template_root', array($this, '_theme_root'));
 }
开发者ID:audiotheme,项目名称:audiotheme-agent,代码行数:8,代码来源:PackageManagerTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     $themes = array('twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen');
     $this->theme = $themes[rand(0, 4)];
     switch_theme($this->theme);
     $this->sender->do_sync();
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:8,代码来源:test_class.jetpack-sync-themes.php

示例13: setUp

 function setUp()
 {
     parent::setUp();
     /* Make sure the active theme is Thematic */
     switch_theme('Thematic');
     /* Include the Thematic function file and extensions */
     include_main_theme_files();
 }
开发者ID:scottnix,项目名称:Thematic,代码行数:8,代码来源:test-thematic.php

示例14: tamatebako_back_compat_switch_theme

/**
 * Prevent theme activation, and force switch to the default theme.
 */
function tamatebako_back_compat_switch_theme()
{
    /* Force switch to default theme. */
    switch_theme(WP_DEFAULT_THEME, WP_DEFAULT_THEME);
    unset($_GET['activated']);
    /* Admin notice */
    add_action('admin_notices', 'tamatebako_back_compat_admin_notice');
}
开发者ID:WPDevHQ,项目名称:nevertheless,代码行数:11,代码来源:back-compat.php

示例15: test_theme_file_path_with_child_theme

 /**
  * @ticket 18302
  *
  * @dataProvider data_theme_files
  */
 public function test_theme_file_path_with_child_theme($file, $expected_theme, $existence)
 {
     switch_theme('theme-file-child');
     // Ensure the returned path uses the expected theme:
     $this->assertSame(WP_CONTENT_DIR . "/themes/{$expected_theme}/{$file}", get_theme_file_path($file));
     // Ensure the returned path always uses the parent theme:
     $this->assertSame(WP_CONTENT_DIR . "/themes/theme-file-parent/{$file}", get_parent_theme_file_path($file));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:13,代码来源:themeFile.php


注:本文中的switch_theme函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。