<?php

namespace ModernFields\FieldGroups\Hooks;

use ModernFields\WordPress\Interfaces\Hooks;

defined('ABSPATH') || exit;

/**
 * Registers the mf_field post type and its meta fields.
 *
 * Each mf_field post represents a single field definition belonging to a
 * mf_field_group. This CPT is used as a queryable index so field data can
 * be retrieved from the database instead of parsed from block HTML.
 *
 * @since 0.6
 */
class FieldPostType implements Hooks
{
  /**
   * @since 0.6
   */
  public function registerHooks(): void
  {
    add_action('init', [$this, 'registerPostType']);
  }

  /**
   * @since 0.6
   */
  public function registerPostType(): void
  {
    register_post_type(MODERN_FIELDS_FIELD_CPT_SLUG, [
      'label'        => 'Field',
      'public'       => false,
      'show_ui'      => false,
      'show_in_rest' => false,
      'supports'     => ['title', 'editor', 'custom-fields'],
    ]);
  }

}
