函数原型:
get_theme_feature_list( bool $api = true ): array
检索WordPress主题功能列表(又名主题标签)。
参数说明:
$api 是否尝试从WordPress.org API获取标记。默认为true。
函数源码:
function get_theme_feature_list( $api = true ) {
// Hard-coded list is used if API is not accessible.
$features = array(
__( 'Subject' ) => array(
'blog' => __( 'Blog' ),
'e-commerce' => __( 'E-Commerce' ),
'education' => __( 'Education' ),
'entertainment' => __( 'Entertainment' ),
'food-and-drink' => __( 'Food & Drink' ),
'holiday' => __( 'Holiday' ),
'news' => __( 'News' ),
'photography' => __( 'Photography' ),
'portfolio' => __( 'Portfolio' ),
),
__( 'Features' ) => array(
'accessibility-ready' => __( 'Accessibility Ready' ),
'block-patterns' => __( 'Block Editor Patterns' ),
'block-styles' => __( 'Block Editor Styles' ),
'custom-background' => __( 'Custom Background' ),
'custom-colors' => __( 'Custom Colors' ),
'custom-header' => __( 'Custom Header' ),
'custom-logo' => __( 'Custom Logo' ),
'editor-style' => __( 'Editor Style' ),
'featured-image-header' => __( 'Featured Image Header' ),
'featured-images' => __( 'Featured Images' ),
'footer-widgets' => __( 'Footer Widgets' ),
'full-site-editing' => __( 'Site Editor' ),
'full-width-template' => __( 'Full Width Template' ),
'post-formats' => __( 'Post Formats' ),
'sticky-post' => __( 'Sticky Post' ),
'style-variations' => __( 'Style Variations' ),
'template-editing' => __( 'Template Editing' ),
'theme-options' => __( 'Theme Options' ),
),
__( 'Layout' ) => array(
'grid-layout' => __( 'Grid Layout' ),
'one-column' => __( 'One Column' ),
'two-columns' => __( 'Two Columns' ),
'three-columns' => __( 'Three Columns' ),
'four-columns' => __( 'Four Columns' ),
'left-sidebar' => __( 'Left Sidebar' ),
'right-sidebar' => __( 'Right Sidebar' ),
'wide-blocks' => __( 'Wide Blocks' ),
),
);
if ( ! $api || ! current_user_can( 'install_themes' ) ) {
return $features;
}
$feature_list = get_site_transient( 'wporg_theme_feature_list' );
if ( ! $feature_list ) {
set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
}
if ( ! $feature_list ) {
$feature_list = themes_api( 'feature_list', array() );
if ( is_wp_error( $feature_list ) ) {
return $features;
}
}
if ( ! $feature_list ) {
return $features;
}
set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
$category_translations = array(
'Layout' => __( 'Layout' ),
'Features' => __( 'Features' ),
'Subject' => __( 'Subject' ),
);
$wporg_features = array();
// Loop over the wp.org canonical list and apply translations.
foreach ( (array) $feature_list as $feature_category => $feature_items ) {
if ( isset( $category_translations[ $feature_category ] ) ) {
$feature_category = $category_translations[ $feature_category ];
}
$wporg_features[ $feature_category ] = array();
foreach ( $feature_items as $feature ) {
if ( isset( $features[ $feature_category ][ $feature ] ) ) {
$wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
} else {
$wporg_features[ $feature_category ][ $feature ] = $feature;
}
}
}
return $wporg_features;
}
-
WordPress函数:esc_attr__ 转义属性及翻译WordPress函数:esc_attr__ 转义属性及翻译
-
WordPress函数:esc_attr_e 属性转义、翻译、显示WordPress函数:esc_attr_e 属性转义、翻译、显示
-
WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示
-
WP Multilang WordPress翻译插件WP Multilang插件的主要功能是提供多语言支持,使用户能够创建多语言版本的网站,满足不同语言用户的需求。
-
WordPress公司官网主题在众多的WordPress企业官网主题中,追格公司推出了多款关于WordPress企业官网主题作品。我们之前已经分享过一些关于追格的企业官网主题,包括收费和免费版本,这些主题都因其独特的设计和出色的功能而深受用户喜爱。
-
WordPress必备:使用wp_get_theme()函数获取当前主题详情在WordPress中,wp_get_theme() 函数用于获取当前启用的主题或指定主题的信息。这个函数返回一个 WP_Theme 对象,该对象包含了主题的详细信息,如主题名称、版本、模板目录、样式表目录等。
暂无评论,抢个沙发...