Jake Vanderwerf
4 hours ago ffd41931fa4517d66fe9764b91d445769bc43acf
content/soap.php
@@ -1,69 +1,171 @@
<?php
// /content/soap.php
function atat_soap():array
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
    exit;
}
add_action('jvbDefineRegistrar', 'atat_soap');
add_action('jvbDefineRegistrarFields', 'atat_soap_fields');
add_action('plugins_loaded', 'atat_soap',3);
//Add fields later so we can verify taxonomies/post types exist
add_action('plugins_loaded', 'atat_soap_fields', 4);
add_filter('atat_FaqSchemaDefault', 'atat_soap_schema');
add_filter('atat_FaqMetaDefault', 'atat_soap_meta');
add_filter('atat_FaqArchiveDefault', 'atat_soap_archive');
function atat_soap(){
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $soap = Registrar::forPost('soap', 'Soap', 'Soaps')
        ->setIcon('sparkle')
        ->make([
            'rewrite'   => [
                'slug'          => 'soap',
                'with_front'    => false,
            ],
            'taxonomies'    => [
                'flag',
            ],
            'public'    => false,
        ])
        ->setAll([
            'show_directory',
        ])
        ->setIntegration('helcim')
        ->setIntegration('facebook')
        ->setIntegration('instagram');
//$directory = $soap->getConfig('directory');
}
function atat_soap_fields():void
{
    if (!class_exists('JVBase\registrar\Registrar')) {
        return;
    }
    $soap = Registrar::getInstance('soap');
//    $breadcrumbs = $soap->config('breadcrumbs');
//    $breadcrumbs->setCrumb('section');
    $fields = $soap->fields();
    $fields->addField('ingredients', [
        'type'      => 'textarea',
        'quill'     => true,
        'label'     => 'Ingredients',
    ]);
    $fields->addField('extra_info', [
        'type'      => 'textarea',
        'quill'     => true,
        'label'     => 'Extra Info',
    ]);
    $fields->addField('flag', [
        'type'      => 'selector',
        'subtype'   => 'taxonomy',
        'taxonomy'  => 'flag',
        'label'     => 'Flags',
    ]);
}
function atat_soap_schema():array
{
    return [
        'singular'       => 'Soap',
        'plural'       => 'Soaps',
        'dash_title'    => 'Soap',
        'dash_description' => 'Manage your soap',
        'breadcrumb'    => 'Soap',
        'icon'         => 'sparkle',
      'integrations' => [
         'helcim' => [
            'initial'   => true,
            'update' => true,
         ],
      ],
        'rewrite'      => [
            'slug'       => 'soap',
            'with_front' => false,
        ],
        'fields'       => [
            'post_title'     => [
                'type'  => 'text',
                'label' => 'Name',
            ],
            'post_status'         => [
                'type'      => 'radio',
                'label'     => 'Status',
                'hidden'    => true,
                'options'   => [
                    'publish'   => 'Show',
                    'draft'     => 'Hide',
                    'trash'     => 'Scrap',
                    'delete'    => 'Permanently Delete'
                ]
            ],
            'post_slug' => [
                'type'  => 'text',
                'label' => 'Slug',
            'hidden' => true,
            ],
            'post_content'        => [
                'type'  => 'textarea',
                'label' => 'Description',
                'quill' => true,
            ],
            'ingredients' => [
                'type'  => 'textarea',
                'label' => 'Ingredients',
            'quill'  => true,
            ],
            'extra_info' => [
                'type'  => 'textarea',
                'label' => 'Extra Info',
            'quill'  => true,
            ],
            'flags'  => [
                'type'  => 'taxonomy',
            'taxonomy'  => 'flags',
                'term'  => 'flags',
                'label' => 'Flags',
            ]
        ],
        'single_image' => true,
        'upload_title' => 'Upload Soaps',
        'type'              => 'JVBase\managers\SEO\render\Thing\Product\Product',
        'name'              => '{{post_title}} | Handmade in Edmonton',
    ];
}
function atat_soap_meta():array
{
    return[
        'name' => '{{post_title}} | Handmade in Edmonton',
    ];
}
function atat_soap_archive(array $defaults):array
{
    return array_merge($defaults, [
        'name' => 'Handmade Soaps',
        'description' => 'Handmade Soaps in Edmonton, Alberta.'
    ]);
}
function atat_soap_reference_schema(array $defaults):array
{
    return $defaults;
}
// /content/soap.php
//function atat_soap():array
//{
//    return [
//        'singular'       => 'Soap',
//        'plural'       => 'Soaps',
//        'dash_title'    => 'Soap',
//        'dash_description' => 'Manage your soap',
//        'breadcrumb'    => 'Soap',
//        'icon'         => 'sparkle',
//    'integrations' => [
//       'helcim' => [
//          'initial'   => true,
//          'update' => true,
//       ],
//    ],
//        'rewrite'      => [
//            'slug'       => 'soap',
//            'with_front' => false,
//        ],
//        'fields'       => [
//            'post_title'     => [
//                'type'  => 'text',
//                'label' => 'Name',
//            ],
//            'post_status'         => [
//                'type'      => 'radio',
//                'label'     => 'Status',
//                'hidden'    => true,
//                'options'   => [
//                    'publish'   => 'Show',
//                    'draft'     => 'Hide',
//                    'trash'     => 'Scrap',
//                    'delete'    => 'Permanently Delete'
//                ]
//            ],
//            'post_slug' => [
//                'type'  => 'text',
//                'label' => 'Slug',
//          'hidden' => true,
//            ],
//            'post_content'        => [
//                'type'  => 'textarea',
//                'label' => 'Description',
//                'quill' => true,
//            ],
//            'ingredients' => [
//                'type'  => 'textarea',
//                'label' => 'Ingredients',
//          'quill'  => true,
//            ],
//            'extra_info' => [
//                'type'  => 'textarea',
//                'label' => 'Extra Info',
//          'quill'  => true,
//            ],
//            'flags'  => [
//                'type'  => 'taxonomy',
//          'taxonomy'  => 'flags',
//                'term'   => 'flags',
//                'label'  => 'Flags',
//            ]
//        ],
//        'single_image' => true,
//        'upload_title' => 'Upload Soaps',
//    ];
//}