<?php
|
// /taxonomies/product_cat.php
|
|
|
use JVBase\registrar\Registrar;
|
|
add_action('jvbDefineRegistrar', 'ami_product_cat');
|
add_action('jvbDefineRegistrarFields', 'ami_product_cat_fields');
|
|
add_action('plugins_loaded', 'ami_product_cat',1);
|
//Add fields later so we can verify taxonomies/post types exist
|
add_action('plugins_loaded', 'ami_product_cat_fields', 2);
|
|
add_filter('ami_Product_catSchemaDefault', 'ami_product_cat_schema');
|
add_filter('ami_Product_catMetaDefault', 'ami_product_cat_meta');
|
add_filter('ami_Product_catArchiveDefault', 'ami_product_cat_archive');
|
|
function ami_product_cat(){
|
if (!class_exists('JVBase\registrar\Registrar')) {
|
return;
|
}
|
$product_cat = Registrar::forTerm('product_cat', 'Category', 'Categories')
|
->setIcon('folder')
|
->make([
|
'rewrite' => [
|
'slug' => 'in/category',
|
'with_front' => false,
|
'hierarchical' => true,
|
],
|
'for' => [
|
'product',
|
'service',
|
],
|
])
|
->setAll([
|
'show_directory',
|
'show_feed',
|
]);
|
|
//$directory = $product_cat->getConfig('directory');
|
|
}
|
|
function ami_product_cat_fields():void
|
{
|
if (!class_exists('JVBase\registrar\Registrar')) {
|
return;
|
}
|
$product_cat = Registrar::getInstance('product_cat');
|
// $breadcrumbs = $product_cat->config('breadcrumbs');
|
|
|
$fields = $product_cat->fields();
|
$fields->addCommon('wiki');
|
}
|
|
function ami_product_cat_schema():array
|
{
|
return [
|
'name' => '{{post_title}}',
|
];
|
}
|
|
function ami_product_cat_meta():array
|
{
|
return[
|
'name' => '{{post_title}}',
|
];
|
}
|
|
function ami_product_cat_archive(array $defaults):array
|
{
|
return array_merge($defaults, [
|
]);
|
}
|
|
function ami_product_cat_reference_schema(array $defaults):array
|
{
|
return $defaults;
|
}
|
//
|
//function ami_category():array
|
//{
|
// return [
|
// 'singular' => 'Category',
|
// 'plural' => 'Categories',
|
// 'icon' => 'folder',
|
// 'show_feed' => true,
|
// 'show_directory' => true,
|
// 'rewrite' => [
|
// 'slug' => 'in',
|
// 'with_front' => false,
|
// 'hierarchical' => true,
|
// ],
|
// 'hierarchical' => true,
|
// 'for_content' => [
|
// 'product',
|
// 'service',
|
// ],
|
// 'fields' => [
|
// 'term_name' => [
|
// 'label' => 'Name',
|
// 'type' => 'text',
|
// 'quickEdit' => true,
|
// ],
|
// 'common' => [ 'wiki' ]
|
// ]
|
// ];
|
//}
|