redux分类Taxonomy

Taxonomy

/ Extensions  /Taxonomy

If you are used the ReduxFramework declaration arrays, you know Redux Taxonomy. They’re one and the same! The only difference is a parent array. We’ll go through a few examples to get you up and running. Please know, you MUST have an options page for taxonomy to work. They’re inter-connected. You can, however, make a fake options panel, and hide it from the admin menu.

如果你使用的reduxframework声明数组,你知道框架的分类。它们是同一个!唯一的区别是父数组。我们将通过几个例子来让你起来跑步。请知道,您必须有一个用于分类的选项页面才能工作。他们是相互连接的。但是,你可以做一个假的选项面板,并从管理菜单中隐藏它。

Getting Started

To understand how to use extensions, you should read this article on Loading Extensions. To shortcut the process, you should use the Redux Generator.

入门
要理解如何使用扩展,您应该阅读关于加载扩展的这篇文章。快捷方式的过程中,你应该使用Redux发生器。

Arguments 参数

NameTypeDescription
idstringYou must provide an ID of some kind. This can be shared with your keys from your panel, and if so the values will be overridden for that given page in your global variable.
titlestringThis is the title that appears on the box
taxonomy_typesarrayProvide any number of taxonomy slugs for a given “term” box to appear.
add_visibilitybooleanAll fields are by default hidden on the add term (edit-term.php) page. By specifying true to a “term” box, section, or field, it will be visible on this page.
stylestring
wp|wordpress
Removes the Redux box & sections styles to look like standard WordPress input fields. Must be used at the “box” level.
permissionsarrayJust like standard Redux, you can set permission levels for “term” boxes, sections, or fields.
sectionsarrayYour sections array, the same style as a standard Redux config file.

Example Declaration

Since we’ve kept the structure exactly the same, start by constructing a section array like you normally would. We then add a level above called a “term” box, and away we go!

既然我们一直保持结构完全相同,那么就开始构建一个像通常一样的截面数组。然后我们加上一个称为“术语”的级别,然后我们离开!

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Redux_Taxonomy::setTerm( $opt_name , array (
         'id'             => 'demo-taxonomy' ,
         'title'          => __( 'Cool Options' , 'redux-framework-demo' ),
         'taxonomy_types' => array ( 'category' , 'post_tag' ),
         // Slug for every taxonomy you want
         'sidebar'        => false,
         // Sidebar with default Redux designs. If only one section is defined, this will be set to true.
         'style'       => 'wp' ,
         // Removes the Redux box/section styles. Makes Redux Taxonomy look like standard WP fields.
         //'add_visibility' => true, // Can bet set on term, section, or field level. Denotes what fields to be displayed on the add {TERM} pages.
         'sections'       => array (
             array (
                 'title'  => __( 'Home Settings' , 'redux-framework-demo' ),
                 'icon'   => 'el-icon-home' ,
                 'fields' => array (
                     array (
                         'id'             => 'text1' ,
                         'type'           => 'text' ,
                         'add_visibility' => true,
                         'title'          => __( 'Test Input' , 'redux-framework-demo' ),
                     ),
                     array (
                         'id'    => 'text1' ,
                         'type'  => 'text' ,
                         'title' => __( 'Test Input2' , 'redux-framework-demo' ),
                     ),
                 )
             ),
             array (
                 'title'  => __( 'Home Layout' , 'redux-framework-demo' ),
                 'desc'   => __( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at: <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>' , 'redux-framework-demo' ),
                 'icon'   => 'el-icon-home' ,
                 'fields' => array (
                     array (
                         "id"             => "homepage_blocks" ,
                         "type"           => "sorter" ,
                         "title"          => "Homepage Layout Manager" ,
                         "desc"           => "Organize how you want the layout to appear on the homepage" ,
                         "compiler"       => 'true' ,
                         'add_visibility' => true,
                         'required'       => array ( 'layout' , '=' , '1' ),
                         'options'        => array (
                             "enabled"  => array (
                                 "placebo"    => "placebo" , //REQUIRED!
                                 "highlights" => "Highlights" ,
                                 "slider"     => "Slider" ,
                                 "staticpage" => "Static Page" ,
                                 "services"   => "Services"
                             ),
                             "disabled" => array (
                                 "placebo" => "placebo" , //REQUIRED!
                             ),
                         ),
                     ),
                 ),
             )
         )
     )
);

Example Usage

Getting the data from a taxonomy term is as simple as using regular WordPress, and the get_term_meta() function. However, to keep things slim, Redux_Taxonomy never saves defaults to the database. If you want the default values, you need to use our custom function.

使用示例
从分类项得到的数据是经常使用WordPress一样简单,和get_term_meta()功能。然而,保持苗条的身材,redux_taxonomy永远保存默认数据库。如果你想要默认值,你需要使用我们的自定义函数。

1
2
3
4
5
6
7
$data = Redux_Taxonomy::get_term_meta(
     array (
         'taxonomy' => $tag_id , // Taxonomy ID, also required
         'opt_name' => $opt_name , // Required
         'key' => false, // If you only want one value instead of the full array
     )
);

This will return an array with all the meta for that taxonomy, as well as all the defaults. You will, however, have to know the ID of the term you wish to grab the defaults from.

这将返回一个带有该分类法所有元数据的数组,以及所有默认值。但是,您必须知道您希望从中获取默认值的术语的ID。

Missing Sidebar?!

For boxes with only one section, the sidebar is omitted when the HTML is output. If you want a side bar, use at least two sections within any given “term” box.

How are the Redux Taxonomy Values Stored?

Redux Taxonomy stores each value as it’s own key in the taxonomy meta using the new WordPress update_term_meta() and delete_term_meta() functions. In this way, you can query against specific taxonomy values. If a value is default, our extension deletes it from the database to reduce on bloat.

失踪的侧边栏?!


对于只有一个部分的框,当HTML输出时省略边栏。如果你想要一个侧栏,在任何给定的“术语”框中至少要使用两个小节。


如何在Redux分类存储的值?


Redux分类存储每个值作为它自己的关键在分类元使用新的WordPress update_term_meta()和delete_term_meta()功能。通过这种方式,您可以查询特定的分类值。如果一个值是默认的,我们的扩展删除它从数据库减少膨胀。

Related Articles

Leave a Reply

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值