获取主题信息WordPress函数wp_get_theme

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

获取主题信息WordPress函数wp_get_theme (https://www.yunsxr.com/) WordPress基础教程 第1张

函数组织1 V ? / b C ^ s i

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

函数原型:

function wp_get_theme( $style] m a ( Fsheet = n\ v S / 6 KuP P / \ll,$E 8 \ @ ltheme_root = null ) {

global $wp_them– ; G k o p 0e_direc@ : 6 o 9 : utories;

if ( empty( $stylesheet ) ) {

$stylesheet = get_sf h \tylesheet();

}

if ( empty( $theme_root )q n U m ) q 2 7 ) {

$theme_root = get_raw_theme_root( $stylesheet );

if ( falR r C A W V h Sse === $theme_root ) {

$theme_root = WP_CONTENT_DIR . ‘/theme} A Is’;

} elseif ( ! in_array( $theme_root,(array) $wp_theme_director: b ties ) ) {

$theme_root = WP_CONTENT_DIR . $theme_root;

}

}

return new WP_Theme( $stylesheet,$theme_root );

}

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

参数:

$stylesheetw 0 9 ` $ # : \ 2

(string) (? 7 W , 7 U S可选) 指定的主落款,默许以后主题。

默许值:; M * = y X . 空

$theme_root

(string) (可选): H F & F j q % } 主题的相对h j = k v +路径,假如为空, 则应用 get_rm r $ W y 7 0 : )aw_thea T 9 } \ : eme_root()函数获得的路径 (默许以后主题).

默许值: 空

返归值

(WP_Thew X r ! @ z O ?me) 主题对象。 假如不晓得主题是否存在,请应用主题对象的 exists()要领判定。

简朴应用

<?php

$my_theme = wp_get_theme( ‘twentytwelve’ );

if ( $my_theme->exists() )

echo esc_html( $my_themeL f D F );

?>

成果:

object(WP_Theme)[916]

public ‘update’ => boolean false

private ‘i 6 b 2 X 1 {theme_root’ =&g_ U / *t; string ‘hoj * / E d Q i [me/path/wp-content/themes’ (length=77)

private ‘headers’ =&q Q Q b v Q ngt;

array (size=11)q 4 N G

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

‘Themg 1 ) \ ~eURI’ => string ‘http://exampl– a I x X = %e.com/’ (length=22)

‘De? c f ! Dscriptiou ? k ~n’ => string ‘Description’ (length=11)

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

‘AuthorURI’F * $ => string ‘http://example.com/’ (lengt/ b U ,h=22)

‘VeR ) . [ & z lrsion’ => string ‘1.0.0’ (length=5)

‘Template’ => strinN ^ m E F eg ” (lew b S _ f & :ngth=H . \ / d0)

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

‘Tags’ => string ‘custom-background,custom-logo,custom-menu,featured-images,threaded-comments,translation-ready7 7 5 X w )‘ (l\ U 3 ^ 2 , H S uength=98)

‘TextDomain’ => string ‘mytheme’ (length=7P d P `)

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

private ‘headers_sanit0 5 y 6 nized’ => null

private ‘name_translated’ => null

private ‘errors’ => null

private ‘styleshe) h U m .et’ => string ‘mytheme’ (length=7)

priw 8 s H } A A F 2vate ‘template’ => string ‘mytheme’ (le} R { ^ . {ngth=7)

private ‘parent’ => null

private ‘theme_root_uri’ =&gtP A /; null

private ‘textdomainC F E ( ? ,_loaded’ => null

private ‘caC R o 9che_hash’ => string ‘ca9dd01f^ a \01f2a5cb4616a776eff52690′ (length=32)

以w h V V x上是YUNSXR云上欣然为你网络收拾整顿的获取主题信息WordPress函数wp_get_theme详解全数内容,但愿文章可以或许帮Z , n w 8 E A你解决WordPress获取主题信息函数wp_get2 # e Z D r , m_theme详解所碰到的步伐开提问题。x Z H

给TA打赏
共{{data.count}}人
人已打赏
重要声明

本站资源来自会员发布以及互联网收集,不代表本站立场,如有侵犯你的权益请联系管理员-小然,站内发信联系 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!请用户仔细辨认内容的真实性,避免上当受骗!本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请在下载24小时内删除!


如果遇到付费才可观看的文章,建议升级终身VIP。全站所有资源“任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR。

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
❯
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索