File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/heku-cms/HekuClass/Admin/Cmb2Taxonomies.php
<?php
namespace Heku\HekuClass\Admin;
/**
* @package Heku\HekuClass\Admin
* @subpackage Classes/Cmb2Taxonomies
* @author Heku Daleconan <http://www.daleconan.com>
* @copyright Copyright (c) 2022-2023, Heku Daleconan
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
class Cmb2Taxonomies{
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance->init();
}
return self::$instance;
}
public function init(){
add_action( 'cmb2_admin_init', array($this,'register_taxonomy_metabox' ));
}
// 定位 为 注册到 分类页 和 标签页的 自定义参数
public function register_taxonomy_metabox(){
$cmb_term = new_cmb2_box( array(
'id' => 'heku_tax',
'title' => __( 'Tax 设置', 'heku' ),
'object_types' => array( 'term' ),
'taxonomies' => array( 'category', 'post_tag' ),
'new_term_section' => true,
) );
$cmb_term->add_field( array(
'name' => __( 'SEO标题', 'b2' ),
'id' => 'seo_title',
'type' => 'text',
) );
$cmb_term->add_field( array(
'name' => __( 'SEO关键词', 'b2' ),
'id' => 'seo_keywords',
'type' => 'text',
) );
//筛选设置
// $filter = $cmb_term->add_field( array(
// 'id' => 'b2_filter',
// 'type' => 'group',
// 'desc' => __( '多级筛选设置', 'b2' ),
// 'repeatable' => false,
// 'options' => array(
// 'group_title' => __( '多级筛选设置设置', 'b2' ),
// 'add_button' => __( '添加新模块', 'b2' ),
// 'remove_button' => __( '删除模块', 'b2' ),
// 'sortable' => false,
// 'closed' => false,
// 'remove_confirm' => __( '确定要删除这个模块吗?', 'b2' ),
// ),
// 'desc'=>sprintf(__('如果需要批量设置多个分类的的筛选,您可以前往%s分类筛选批量设置%s中进行操作','b2'),'<a target="_blank" href="'.admin_url('/admin.php?page=b2_template_fliter').'">','</a>')
// ));
// $cmb_term->add_group_field( $filter,array(
// 'name' => __( '是否开启筛选', 'b2' ),
// 'id' => 'show',
// 'type' => 'select',
// 'default' => 0,
// 'options' => array(
// 1 => __( '开启', 'cmb2' ),
// 0 => __( '关闭', 'cmb2' )
// ),
// ));
// $cats = array();
// $categories = get_categories( array(
// 'orderby' => 'name',
// 'order' => 'ASC',
// 'hide_empty' => false,
// ) );
// foreach( $categories as $category ) {
// $cats[$category->term_id] = $category->name;
// }
// $cmb_term->add_group_field($filter,array(
// 'name' => '允许筛选的分类',
// 'id' => 'cat',
// 'desc' => __('请选择要显示的文章分类,可以拖动排序','b2'),
// 'type' => 'pw_multiselect',
// 'options' =>$cats,
// ) );
// $cmb_term->add_group_field( $filter,array(
// 'name' => __('允许筛选的分类','b2'),
// 'id' => 'cat',
// 'type' => 'taxonomy_multicheck_hierarchical',
// 'taxonomy'=>'category',
// 'text' => array(
// 'no_terms_text' => sprintf(__('没有分类,请前往%s添加','b2'),'<a target="__blank" href="'.admin_url('//edit-tags.php?taxonomy=category').'"></a>')
// ),
// 'remove_default' => 'true',
// 'query_args' => array(
// 'orderby' => 'count',
// 'hide_empty' => false,
// ),
// 'select_all_button' => true,
// 'desc'=>__('请确保您的分类别名不是中文,否则无法选中','b2'),
// ));
// $arr = array();
// $cats = get_terms('collection',array(
// 'orderby' => 'name',
// 'order' => 'ASC',
// 'hide_empty' => false,
// 'cache_domain'=>'b2_collection'
// ) );
}
}