/** * 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'); }
/** * @param WP_Theme $theme * @return bool */ public function search_theme($theme) { // Search the features foreach ($this->features as $word) { if (!in_array($word, $theme->get('Tags'))) { return false; } } // Match all phrases foreach ($this->search_terms as $word) { if (in_array($word, $theme->get('Tags'))) { continue; } foreach (array('Name', 'Description', 'Author', 'AuthorURI') as $header) { // Don't mark up; Do translate. if (false !== stripos(strip_tags($theme->display($header, false, true)), $word)) { continue 2; } } if (false !== stripos($theme->get_stylesheet(), $word)) { continue; } if (false !== stripos($theme->get_template(), $word)) { continue; } return false; } return true; }
/** * @ticket 20313 */ function test_new_WP_Theme_subdir_bad_root() { // This is what get_theme_data() does when you pass it a style.css file for a theme in a subdir. $theme = new WP_Theme('theme2', $this->theme_root . '/subdir'); //Meta $this->assertEquals('My Subdir Theme', $theme->get('Name')); $this->assertEquals('http://example.org/', $theme->get('ThemeURI')); $this->assertEquals('An example theme in a sub directory', $theme->get('Description')); $this->assertEquals('Mr. WordPress', $theme->get('Author')); $this->assertEquals('http://wordpress.org/', $theme->get('AuthorURI')); $this->assertEquals('0.1', $theme->get('Version')); $this->assertEquals('', $theme->get('Template')); $this->assertEquals('publish', $theme->get('Status')); $this->assertEquals(array(), $theme->get('Tags')); //Important $this->assertEquals('subdir/theme2', $theme->get_stylesheet()); $this->assertEquals('subdir/theme2', $theme->get_template()); }
/** * @staticvar string $term * @param WP_Theme $theme * @return bool */ public function _search_callback($theme) { static $term; if (is_null($term)) { $term = wp_unslash($_REQUEST['s']); } foreach (array('Name', 'Description', 'Author', 'Author', 'AuthorURI') as $field) { // Don't mark up; Do translate. if (false !== stripos($theme->display($field, false, true), $term)) { return true; } } if (false !== stripos($theme->get_stylesheet(), $term)) { return true; } if (false !== stripos($theme->get_template(), $term)) { return true; } return false; }