也想出现在这里? 联系我们

获取主题信息WordPress函数wp_get_theme

作者 : 小编 本文共1995个字,预计阅读时间需要5分钟 发布时间: 2020-08-7 共1.43K人阅读
也想出现在这里? 联系我们

wp_get_theme 函数可以间接获得以后启用的主题或许指定的主题信息,包孕版本作者路径等。就主题更新功效而言,开发者只要要判定返归的主题对象中版本号是否小于最新版本号即可断定是否更新。今天主题盒子为大家分享一下获取主题信息WordPress函数wp_get_theme。

函数组织

wp_get_theme( string $stylesheet = null,string $theme_root = null )

函数原型:

function wp_get_theme( $stylesheet = null,$theme_root = null ) {

global $wp_theme_directories;

if ( empty( $stylesheet ) ) {

$stylesheet = get_stylesheet();

}

if ( empty( $theme_root ) ) {

$theme_root = get_raw_theme_root( $stylesheet );

if ( false === $theme_root ) {

$theme_root = WP_CONTENT_DIR . ‘/themes’;

} elseif ( ! in_array( $theme_root,(array) $wp_theme_directories ) ) {

$theme_root = WP_CONTENT_DIR . $theme_root;

}

}

return new WP_Theme( $stylesheet,$theme_root );

}

形容:得到以后主题或指定主题的信息。

参数:

$stylesheet

(string) (可选) 指定的主落款,默许以后主题。

默许值: 空

$theme_root

(string) (可选) 主题的相对路径,假如为空, 则应用 get_raw_theme_root()函数获得的路径 (默许以后主题).

默许值: 空

返归值

(WP_Theme) 主题对象。 假如不晓得主题是否存在,请应用主题对象的 exists()要领判定。

简朴应用

<?php

$my_theme = wp_get_theme( ‘twentytwelve’ );

if ( $my_theme->exists() )

echo esc_html( $my_theme );

?>

成果:

object(WP_Theme)[916]

public ‘update’ => boolean false

private ‘theme_root’ => string ‘home/path/wp-content/themes’ (length=77)

private ‘headers’ =>

array (size=11)

‘Name’ => string ‘mytheme’ (length=7)

‘ThemeURI’ => string ‘http://example.com/’ (length=22)

‘Description’ => string ‘Description’ (length=11)

‘Author’ => string ‘Something Here’ (length=14)

‘AuthorURI’ => string ‘http://example.com/’ (length=22)

‘Version’ => string ‘1.0.0’ (length=5)

‘Template’ => string ” (length=0)

‘Status’ => string ” (length=0)

‘Tags’ => string ‘custom-background,custom-logo,custom-menu,featured-images,threaded-comments,translation-ready’ (length=98)

‘TextDomain’ => string ‘mytheme’ (length=7)

‘DomainPath’ => string ” (length=0)

private ‘headers_sanitized’ => null

private ‘name_translated’ => null

private ‘errors’ => null

private ‘stylesheet’ => string ‘mytheme’ (length=7)

private ‘template’ => string ‘mytheme’ (length=7)

private ‘parent’ => null

private ‘theme_root_uri’ => null

private ‘textdomain_loaded’ => null

private ‘cache_hash’ => string ‘ca9dd01f01f2a5cb4616a776eff52690’ (length=32)

以上是主题盒子为你网络收拾整顿的获取主题信息WordPress函数wp_get_theme详解全数内容,但愿文章可以或许帮你解决WordPress获取主题信息函数wp_get_theme详解所碰到的步伐开提问题。

1. 本站所提供的源码模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: rayer@88.com),我们会及时删除,给您带来的不便,我们深表歉意!
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布投稿,分享有金币奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务 请大家谅解!
5. 如有链接无法下载、失效或广告,请联系站长,可领回失去的金币,并额外有奖!
6. 如遇到加密压缩包,默认解压密码为"www.zyfx8.cn",如遇到无法解压的请联系管理员!
本站部分文章、资源来自互联网,版权归原作者及网站所有,如果侵犯了您的权利,请及时联系我站删除。免责声明
资源分享吧 » 获取主题信息WordPress函数wp_get_theme

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
织梦模板使用说明
你下载的织梦模板并不包括DedeCMS使用授权,根据DedeCMS授权协议,除个人非盈利站点外,均需购买DedeCMS商业使用授权。购买地址: http://www.desdev.cn/service-dedecms.html

发表评论

Copyright 2015-2020 版权所有 资源分享吧 Rights Reserved. 蜀ICP备14022927号-1
开通VIP 享更多特权,建议使用QQ登录