<?php

use StoutLogic\AcfBuilder\FieldsBuilder;

$testimonialFields = new FieldsBuilder('Testimonial Fields');

$testimonialFields
    ->setLocation('post_type', '==', 'testimonial')
    ->addText('client_name', [
        'label' => 'Client Name',
        'required' => 0,
    ])
    ->addText('job_title', [
        'label' => 'Job Title',
        'required' => 0,
    ])
    ->addText('client_company', [
        'label' => 'Client Company',
        'required' => 0,
    ])
    ->addUrl('client_website', [
        'label' => 'Link to Website',
        'required' => 0,
    ])
    ->addUrl('project_link', [
        'label' => 'Link to project',
        'required' => 0,
    ])
    ->addTextarea('quote', [
        'label' => 'Quote',
        'new_lines' => 'br',
        'required' => 1,
    ])
    ->addDatePicker('testimonial_date', [
        'label' => 'Date',
        'display_format' => 'F j, Y',
        'return_format' => 'Y-m-d',
        'first_day' => 1,
        'required' => 0,
    ]);

return [
    'post_type' => 'testimonial',
    'args' => [
        'labels' => [
            'name' => __('Testimonials'),
            'singular_name' => __('Testimonial'),
            'add_new_item' => __('Add New Testimonial'),
            'edit_item' => __('Edit Testimonial'),
            'new_item' => __('New Testimonial'),
            'view_item' => __('View Testimonial'),
            'search_items' => __('Search Testimonials'),
        ],
        'public' => false,
        'publicly_queryable' => false,
        'exclude_from_search' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_rest' => true,
        'menu_position' => 20,
        'menu_icon' => 'dashicons-format-quote',
        'supports' => ['title'],
        'has_archive' => false,
        'rewrite' => false,
    ],

    'acf_field_groups' => [
        $testimonialFields->build(),
    ],
];