Jake Vanderwerf
2026-04-26 5fe601cd1962dca79c0765a54ce864af5abb7d40
taxonomies/theme.php
@@ -1,73 +1,179 @@
<?php
// /taxonomies/theme.php
function ajv_theme():array
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
    exit;
}
add_action('plugins_loaded', 'ajv_theme',1);
//Add fields later so we can verify taxonomies/post types exist
add_action('plugins_loaded', 'ajv_theme_fields', 2);
add_filter('ajv_ThemeSchemaDefault', 'ajv_theme_schema');
add_filter('ajv_ThemeMetaDefault', 'ajv_theme_meta');
add_filter('ajv_ThemeArchiveDefault', 'ajv_theme_archive');
function ajv_theme(){
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $theme = Registrar::forTerm('theme', 'Theme', 'Themes')
        ->setIcon('hash')
        ->make([
            'rewrite'   => [
                'slug'          => 'in/theme',
                'with_front'    => false,
                'hierarchical' => true,
            ],
            'for'    => [
                'art',
                'design',
                'development',
                'strategy',
                'writing'
            ],
            'hierarchical'  => true,
        ])
        ->setAll([
            'show_feed',
            'show_directory'
        ]);
}
function ajv_theme_fields():void
{
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $theme = Registrar::getInstance('theme');
    //$directory = $theme->getConfig('directory');
    //$breadcrumbs = $theme->config('breadcrumbs');
    //$breadcrumbs->setCrumb('project');
    $fields = $theme->fields();
    $fields->addField(
        'similar',
        [
            'type'          => 'selector',
            'subtype'          => 'taxonomy',
            'isReference' => true,
            'taxonomy'      => 'theme',
            'label'         => 'Similar Themes',
        ]
    );
    $fields->addField(
        'description',
        [
            'type'  => 'textarea',
            'quill' => true,
            'label' => 'Description',
        ]
    );
    $fields->addCommon('wiki');
    $fields->addCommon('alternate_name');
    $fields->addCommon('keywords');
}
//function ajv_theme():array
//{
//    return [
//        'directory'    => 'Themes',
//        'show_directory' => true,
//        'isGrouped'     => true,
//        'description'    => [
//            'What makes up the tattoo, asides from style.',
//            'From bees to ideas to carrots.'
//        ],
//        'singular'     => 'Theme',
//        'plural'       => 'Themes',
//        'icon'         => 'hash',
//        'favouritable' => true,
//        'show_feed'    => true,
//        'approve_new'  => false,
//        'rewrite'      => [
//            'slug'         => 'themes',
//            'with_front'   => false,
//            'hierarchical' => true,
//        ],
//        'hierarchical' => true,
//        'for_content'  => [
//            'art',
//            'theme',
//            'development',
//            'strategy',
//            'writing',
//        ],
//        'seo' => [
//            'schema' => [
//                'type' => 'DefinedTerm',
//                'name' => '{{name}}',
//                'description' => '{{description}}',
//                'alternateName' => '{{alternate_name}}',
//            ],
//            'meta' => [
//                'title' => '{{name}} | Themes',
//                'description' => '{{description}}',
//            ],
//            'archive' => [
//                'type' => 'CollectionPage',
//                'name' => '{{name}} Projects',
//            ],
//        ],
//        'fields'       => [
//            'term_name'       => [
//                'label'     => 'Name',
//                'type'      => 'text',
//                'quickEdit' => true,
//            ],
//            'similar'         => [
//                'type'          => 'taxonomy',
//                'isReference' => true,
//                'taxonomy'      => 'theme',
//                'label'         => 'Similar Themes',
//            ],
//            'description'     => [
//                'type'  => 'textarea',
//                'quill' => true,
//                'label' => 'Description',
//            ],
//            'archive_title'   => [
//                'type'        => 'text',
//                'label'       => 'Archive Title',
//                'description' => 'If the generated title does not jive, set it here',
//            ],
//            'common'          => [ 'wiki', 'alternate_name', 'keywords' ]
//        ]
//    ];
//}
function ajv_theme_schema():array
{
    return [
        'directory'    => 'Themes',
        'show_directory' => true,
        'isGrouped'     => true,
        'description'    => [
            'What makes up the tattoo, asides from style.',
            'From bees to ideas to carrots.'
        ],
        'singular'     => 'Theme',
        'plural'       => 'Themes',
        'icon'         => 'hash',
        'favouritable' => true,
        'show_feed'    => true,
        'approve_new'  => false,
        'rewrite'      => [
            'slug'         => 'themes',
            'with_front'   => false,
            'hierarchical' => true,
        ],
        'hierarchical' => true,
        'for_content'  => [
            'art',
            'design',
            'development',
            'strategy',
            'writing',
        ],
        'seo' => [
            'schema' => [
                'type' => 'DefinedTerm',
                'name' => '{{term_name}}',
                'description' => '{{description}}',
                'alternateName' => '{{alternate_name}}',
            ],
            'meta' => [
                'title' => '{{term_name}} | Themes',
                'description' => '{{description}}',
            ],
            'archive' => [
                'type' => 'CollectionPage',
                'name' => '{{term_name}} Projects',
            ],
        ],
        'fields'       => [
            'term_name'       => [
                'label'     => 'Name',
                'type'      => 'text',
                'quickEdit' => true,
            ],
            'similar'         => [
                'type'          => 'taxonomy',
                'taxonomy_type' => 'reference',
                'taxonomy'      => 'theme',
                'label'         => 'Similar Themes',
            ],
            'description'     => [
                'type'  => 'textarea',
                'quill' => true,
                'label' => 'Description',
            ],
            'archive_title'   => [
                'type'        => 'text',
                'label'       => 'Archive Title',
                'description' => 'If the generated title does not jive, set it here',
            ],
            'common'          => [ 'wiki', 'alternate_name', 'keywords' ]
        ]
//        'type'              => 'JVBase\managers\SEO\render\Thing\CreativeWork\CreativeWork',
        'name'              => '{{name}} | Themes',
        'alternateName'     => '{{alternate_name}}',
        'description'       => '{{description}}',
    ];
}
function ajv_theme_meta():array
{
    return[
        'name' => '{{name}} | Themes',
    ];
}
function ajv_theme_archive(array $defaults):array
{
    return array_merge($defaults, [
        'name' => '{{name}} | Themes',
    ]);
}
function ajv_theme_reference_schema(array $defaults):array
{
    return $defaults;
}