本文整理汇总了PHP中WP_Theme::get_template方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::get_template方法的具体用法?PHP WP_Theme::get_template怎么用?PHP WP_Theme::get_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::get_template方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例2: search_theme
/**
* @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;
}
示例3:
/**
* @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());
}
示例4: _search_callback
/**
* @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;
}