/** * 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'); }
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); } }
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); }
/** * 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 }
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(); } }
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>"; } }
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'); }
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'); }
static function set_theme() { $stylesheet = sanitize_text_field($_POST['stylesheet']); do_action('jetpack_start_select_theme', $stylesheet); switch_theme($stylesheet); wp_send_json_success(); }
/** * 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'; }
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')); }
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(); }
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(); }
/** * 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'); }
/** * @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)); }
function testTwigLoadsFromParentTheme() { $this->_setupParentTheme(); $this->_setupChildTheme(); switch_theme('fake-child-theme'); $templates = array('single-parent.twig'); $str = Timber::compile($templates, array()); $this->assertEquals('I am single.twig in parent theme', trim($str)); }
function _manually_load_environment() { // Add your theme … $tlsTheme = 'tls'; switch_theme($tlsTheme); // Update array with plugins to include ... $plugins_to_active = array(); update_option('active_plugins', $plugins_to_active); }
protected function execute(InputInterface $input, OutputInterface $output) { $env = Validators::validateEnv($input->getOption('env')); $root = $this->skeleton->getWebRoot(); $stylesheet = $input->getOption('theme') ?: $this->skeleton->get('domain'); require $root . '/wp-load.php'; $output->write(sprintf('Activating theme <comment>%s</comment>...', $stylesheet)); switch_theme('_s', $stylesheet); $output->writeln('<info>DONE</info>'); }
/** * @ticket 38696 */ function test_page_templates_child_theme() { $theme = wp_get_theme('page-templates-child'); $this->assertNotEmpty($theme); switch_theme($theme['Template'], $theme['Stylesheet']); $this->assertEqualSetsWithIndex(array('Top Level' => 'template-top-level-post-types.php', 'Sub Dir' => 'subdir/template-sub-dir-post-types.php'), get_page_templates(null, 'foo')); $this->assertEqualSetsWithIndex(array('Top Level' => 'template-top-level-post-types.php', 'Sub Dir' => 'subdir/template-sub-dir-post-types.php'), get_page_templates(null, 'post')); $this->assertEqualSetsWithIndex(array('Top Level' => 'template-top-level.php', 'Sub Dir' => 'subdir/template-sub-dir.php', 'This Template Header Is On One Line' => 'template-header.php'), get_page_templates()); $this->assertEquals(array(), get_page_templates(null, 'bar')); }
/** * Change theme according to network option default theme * @param $blog_id * @param $user_id * @param $domain * @param $path * @param $site_id * @param $meta * @author Julien Maury */ static function switch_theme($blog_id, $user_id, $domain, $path, $site_id, $meta) { $default = get_site_option('default_network_theme'); if (empty($default)) { return; } switch_to_blog($blog_id); switch_theme($default); restore_current_blog(); }
function idf_activate_theme() { if (isset($_POST['theme'])) { $slug = esc_attr($_POST['theme']); $slug = str_replace('500', 'fivehundred', $slug); switch_theme($slug); echo 1; } exit; }
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.'); } switch_theme($theme); $new_theme = wp_get_theme($theme); $result['data']['name'] = $new_theme->get('Name'); $result['data']['version'] = $new_theme->get('Version'); return $result; }
static function _setupStarterTheme() { $dest = WP_CONTENT_DIR . '/themes/timber-starter-theme/'; $src = __DIR__ . '/../../timber-starter-theme/'; if (is_dir($src)) { self::_copyDirectory($src, $dest); switch_theme('timber-starter-theme'); } else { echo 'no its not'; } }
function setDefaultTheme() { if ($this->defaultTheme) { if (is_array($this->defaultTheme)) { list($template, $stylesheet) = $this->defaultTheme; } else { $template = $stylesheet = $this->defaultTheme; } switch_theme($template, $stylesheet); } }
function _manually_load_plugin() { // Add your theme … switch_theme('twentyfifteen'); // Update array with plugins to include ... $plugins_to_active = array('multi-rating/multi-rating.php'); update_option('active_plugins', $plugins_to_active); // uncomment this to create db tables //require dirname( dirname( __FILE__ ) ) . '/multi-rating.php'; //Multi_Rating::activate_plugin(); }
/** * @ticket 10959 * @ticket 11216 */ function test_page_templates() { $theme = get_theme('Page Template Theme'); $this->assertFalse(empty($theme)); switch_theme($theme['Template'], $theme['Stylesheet']); $templates = get_page_templates(); $this->assertEquals(3, count($templates)); $this->assertEquals("template-top-level.php", $templates['Top Level']); $this->assertEquals("subdir/template-sub-dir.php", $templates['Sub Dir']); $this->assertEquals("template-header.php", $templates['This Template Header Is On One Line']); }
/** * Activate a theme * * @param array $args **/ public function activate($args = array()) { list($stylesheet, $child) = $this->parse_name($args, __FUNCTION__); $details = get_theme_data($stylesheet); $parent = $details['Template']; if (empty($parent)) { $parent = $child; } elseif (!is_readable($this->get_stylesheet_path($parent))) { WP_CLI::warning('parent theme not found'); exit; } switch_theme($parent, $child); }
function bp_loader_activate() { /* Force refresh theme roots. */ delete_site_transient( 'theme_roots' ); /* Switch the user to the new bp-default if they are using the old bp-default on activation. */ if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) ) switch_theme( 'bp-default', 'bp-default' ); /* Install site options on activation */ bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) ); do_action( 'bp_loader_activate' ); }
/** * Plugin Name: CT Theme Switcher * Plugin URI: http://localhost * Description: A custom plugin that switch theme depend on mobile & web platform for example. * Author: Mainul Hasan * Author URI: http://codetrio.com * Version: 1.0 **/ function maybe_switch_theme($host = false) { $host = ($host) ? $host : str_replace('www.', '', $_SERVER['SERVER_NAME']); $themes = array( 'm.mywordpress.local' => array('twentyfifteen','twentyfifteen'), 'mywordpress.local' => array('twentyfourteen','twentyfourteen') ); if (isset($themes[$host])){ $themes = $themes[$host]; switch_theme($themes[0],$themes[1]); } }
/** * @ticket 34114 */ public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain() { add_filter('locale', array($this, 'filter_set_locale_to_german')); switch_theme('internationalized-theme'); include_once get_stylesheet_directory() . '/functions.php'; $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-theme'); $expected_output = i18n_theme_test(); $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-theme'); unload_textdomain('internationalized-theme'); remove_filter('locale', array($this, 'filter_set_locale_to_german')); $this->assertFalse($is_textdomain_loaded_before); $this->assertSame('Das ist ein Dummy Theme', $expected_output); $this->assertTrue($is_textdomain_loaded_after); }