本文整理汇总了PHP中WP_Theme::get方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::get方法的具体用法?PHP WP_Theme::get怎么用?PHP WP_Theme::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: get_theme_field
/**
* Returns field from theme data if cookie is set to valid theme.
*
* @param string $field_name
* @param mixed $default
*
* @deprecated :2.0
*
* @return mixed
*/
public static function get_theme_field($field_name, $default = false)
{
if (!empty(self::$theme)) {
return self::$theme->get($field_name);
}
return $default;
}
示例3: get_theme_info_html
protected function get_theme_info_html(WP_Theme $theme)
{
$name = $theme->display('Name');
$version = $theme->display('Version');
$description = $theme->display('Description');
$desc_title = esc_attr($theme->get('Description'));
$author = $theme->display('Author');
$screenshot = $theme->get_screenshot();
$thumbnail_style = $screenshot !== false ? sprintf('style="background-image:url(%s);"', $screenshot) : '';
$theme_url = network_admin_url(add_query_arg('theme', $theme->get_stylesheet(), 'themes.php'));
$version_label = __('Version:', 'wtaiu');
$author_label = __('By', 'wtaiu');
$output = <<<OUTPUT
<div class="theme-info" title="{$desc_title}">
<a href="{$theme_url}" class="theme-screenshot" {$thumbnail_style}></a>
<div class="theme-info-wrap">
<h3 class="theme-info-header" title="{$name}">
<a href="{$theme_url}" class="theme-name">{$name}</a>
</h3>
<p class="theme-version">{$version_label} {$version}</p>
<p class="theme-author">{$author_label} {$author}</p>
</div>
</div>
OUTPUT;
return $output;
}
示例4: __construct
/**
* Constructor.
*
* @param string $store_url This is the URL to your store.
* @param int $product_id This is the product ID of your plugin.
* @param array $args Additional args.
*
* @throws Exception
*/
public function __construct($store_url, $product_id, $args = array())
{
$this->store_url = trailingslashit($store_url);
$this->product_id = $product_id;
$this->theme = wp_get_theme();
if (empty($args['version'])) {
$this->version = $this->theme->get('Version');
} else {
$this->version = $args['version'];
}
if ($args['key']) {
$this->key = $args['key'];
}
if ($args['activation_id']) {
$this->id = absint($args['activation_id']);
}
add_filter('pre_set_site_transient_update_themes', array($this, 'check_for_update'));
add_action("in_theme_update_message-{$this->theme->get_stylesheet()}", array($this, 'show_upgrade_notice_on_list'), 10, 2);
}
示例5:
/**
* Returns the version of the the current theme.
*
* @return string
* The version of the current theme.
*
* @ingroup helperfunc
*/
function get_theme_version()
{
if (class_exists('WP_Theme')) {
$theme = new WP_Theme(get_theme_name(), get_theme_root());
return $theme->get('Version');
} else {
$theme_data = get_theme_data(get_template_directory() . '/style.css');
return $theme_data['Version'];
}
}
示例6: resolveLanguagesPath
public static function resolveLanguagesPath(\WP_Theme $theme)
{
// as taken from wp-includes/class-wp-theme.php:1114
$path = $theme->get_stylesheet_directory();
if ($domainpath = $theme->get('DomainPath')) {
$path .= $domainpath;
} else {
$path .= '/languages';
}
return $path;
}
示例7:
/**
* @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());
}
示例8: get_theme_data
/**
* Retrieve theme data from parsed theme file.
*
* @since 1.5.0
* @deprecated 3.4.0
* @deprecated Use wp_get_theme()
* @see wp_get_theme()
*
* @param string $theme_file Theme file path.
* @return array Theme data.
*/
function get_theme_data($theme_file)
{
_deprecated_function(__FUNCTION__, '3.4', 'wp_get_theme()');
$theme = new WP_Theme(basename(dirname($theme_file)), dirname(dirname($theme_file)));
$theme_data = array('Name' => $theme->get('Name'), 'URI' => $theme->display('ThemeURI', true, false), 'Description' => $theme->display('Description', true, false), 'Author' => $theme->display('Author', true, false), 'AuthorURI' => $theme->display('AuthorURI', true, false), 'Version' => $theme->get('Version'), 'Template' => $theme->get('Template'), 'Status' => $theme->get('Status'), 'Tags' => $theme->get('Tags'), 'Title' => $theme->get('Name'), 'AuthorName' => $theme->get('Author'));
foreach (apply_filters('extra_theme_headers', array()) as $extra_header) {
if (!isset($theme_data[$extra_header])) {
$theme_data[$extra_header] = $theme->get($extra_header);
}
}
return $theme_data;
}
示例9: offsetGet
/**
* Method to implement ArrayAccess for keys formerly returned by get_themes()
*/
public function offsetGet($offset)
{
switch ($offset) {
case 'Name':
case 'Version':
case 'Status':
return $this->get($offset);
case 'Title':
return $this->get('Name');
// Author, Author Name, Author URI, and Description did not
// previously return translated data. We are doing so now.
// Title and Name could have been used as the key for get_themes(),
// so both to remain untranslated for back compatibility.
// Author, Author Name, Author URI, and Description did not
// previously return translated data. We are doing so now.
// Title and Name could have been used as the key for get_themes(),
// so both to remain untranslated for back compatibility.
case 'Author':
return $this->display('Author');
case 'Author Name':
return $this->display('Author', false);
case 'Author URI':
return $this->display('AuthorURI');
case 'Description':
return $this->display('Description');
case 'Template':
return $this->get_template();
case 'Stylesheet':
return $this->get_stylesheet();
case 'Template Files':
$files = $this->get_files('php');
foreach ($files as &$file) {
$file = $this->theme_root . '/' . $file;
}
return $files;
case 'Stylesheet Files':
$files = $this->get_files('css');
foreach ($files as &$file) {
$file = $this->theme_root . '/' . $file;
}
return $files;
case 'Template Dir':
return $this->get_template_directory();
case 'Stylesheet Dir':
return $this->get_stylesheet_directory();
case 'Screenshot':
return $this->get_screenshot('relative');
case 'Tags':
return $this->get('Tags');
case 'Theme Root':
return $this->get_theme_root();
case 'Theme Root URI':
return $this->get_theme_root_uri();
case 'Parent Theme':
return $this->parent ? $this->parent->get('Name') : '';
default:
return null;
}
}
示例10:
/**
* @ticket 26873
*/
function test_display_method_on_get_method_failure()
{
$theme = new WP_Theme('nonexistent', $this->theme_root);
$this->assertEquals('nonexistent', $theme->get('Name'));
$this->assertFalse($theme->get('AuthorURI'));
$this->assertFalse($theme->get('Tags'));
$this->assertFalse($theme->display('Tags'));
}
示例11: tc_get_theme_data
function tc_get_theme_data($theme_file)
{
if (!class_exists('WP_Theme')) {
return get_theme_data($theme_file);
}
$theme = new WP_Theme(basename(dirname($theme_file)), dirname(dirname($theme_file)));
$theme_data = array('Name' => $theme->get('Name'), 'URI' => $theme->display('ThemeURI', true, false), 'Description' => $theme->display('Description', true, false), 'Author' => $theme->display('Author', true, false), 'AuthorURI' => $theme->display('AuthorURI', true, false), 'Version' => $theme->get('Version'), 'Template' => $theme->get('Template'), 'Status' => $theme->get('Status'), 'Tags' => $theme->get('Tags'), 'Title' => $theme->get('Name'), 'AuthorName' => $theme->display('Author', false, false), 'License' => $theme->display('License', false, false), 'License URI' => $theme->display('License URI', false, false), 'Template Version' => $theme->display('Template Version', false, false));
return $theme_data;
}
示例12: _init
/**
* Do a several Clean Up
*
* @brief Clean Up
*/
public function _init()
{
/* Text Domain */
if ($this->setup->autoload_text_domain) {
load_theme_textdomain($this->theme->get('TextDomain'), trailingslashit(TEMPLATEPATH) . $this->theme->get('DomainPath'));
}
/* Clean up wp_head */
if ($this->setup->cleanup_wp_head) {
remove_action('wp_head', 'feed_links_extra', 3);
// Category Feeds
remove_action('wp_head', 'feed_links', 2);
// Post and Comment Feeds
remove_action('wp_head', 'rsd_link');
// EditURI link
remove_action('wp_head', 'wlwmanifest_link');
// Windows Live Writer
remove_action('wp_head', 'index_rel_link');
// index link
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
// previous link
remove_action('wp_head', 'start_post_rel_link', 10, 0);
// start link
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
// Links for Adjacent Posts
remove_action('wp_head', 'wp_generator');
// WP vers
}
}
示例13: column_description
/**
* Handles the description column output.
*
* @since 4.3.0
* @access public
*
* @global string $status
* @global array $totals
*
* @param WP_Theme $theme The current WP_Theme object.
*/
public function column_description($theme)
{
global $status, $totals;
if ($theme->errors()) {
$pre = $status == 'broken' ? __('Broken Theme:') . ' ' : '';
echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
}
if ($this->is_site_themes) {
$allowed = $theme->is_allowed('site', $this->site_id);
} else {
$allowed = $theme->is_allowed('network');
}
$class = !$allowed ? 'inactive' : 'active';
if (!empty($totals['upgrade']) && !empty($theme->update)) {
$class .= ' update';
}
echo "<div class='theme-description'><p>" . $theme->display('Description') . "</p></div>\n\t\t\t<div class='{$class} second theme-version-author-uri'>";
$stylesheet = $theme->get_stylesheet();
$theme_meta = array();
if ($theme->get('Version')) {
$theme_meta[] = sprintf(__('Version %s'), $theme->display('Version'));
}
$theme_meta[] = sprintf(__('By %s'), $theme->display('Author'));
if ($theme->get('ThemeURI')) {
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__('Visit theme homepage') . '">' . __('Visit Theme Site') . '</a>';
}
/**
* Filter the array of row meta for each theme in the Multisite themes
* list table.
*
* @since 3.1.0
*
* @param array $theme_meta An array of the theme's metadata,
* including the version, author, and
* theme URI.
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme WP_Theme object.
* @param string $status Status of the theme.
*/
$theme_meta = apply_filters('theme_row_meta', $theme_meta, $stylesheet, $theme, $status);
echo implode(' | ', $theme_meta);
echo '</div>';
}
示例14:
/**
* If theme is in list of allowed to be switched to.
*
* @param WP_Theme $theme
*
* @return bool
*/
static function is_allowed( $theme ) {
return array_key_exists( $theme->get( 'Name' ), self::get_allowed_themes() );
}
示例15: prepare_item_for_response
/**
* Prepare item for response
*
* @param WP_Theme $item
* @param WP_REST_Request $request
*
* @return array
*/
public function prepare_item_for_response($item, $request)
{
return array('name' => $item->get('Name'), 'slug' => $item->slug, 'version' => $item->get('Version'), 'description' => $item->get('Description'), 'author' => $item->get('Author'), 'author_uri' => $item->get('AuthorURI'), 'text_domain' => $item->get('TextDomain'), 'domain_path' => $item->get('DomainPath'), 'tags' => $item->get('Tags'));
}
开发者ID:danbilauca,项目名称:wp-api-plugins-themes-endpoints,代码行数:12,代码来源:class-wp-rest-themes-controller.php