<?php

add_filter("rwmb_meta_boxes", function ($meta_boxes) {
  $useWysiwyg = Inoby_Config::faq_use_wysiwyg();
  $meta_boxes[] = [
    "id" => "faq_page",
    "title" => __("FAQ", "inoby"),
    "post_types" => ["page"],
    "show" => [
      "template" => ["page-templates/faq.php"],
    ],
    "context" => "normal",
    "priority" => "default",
    "autosave" => "false",
    "fields" => [
      [
        "name" => __("Page heading", "inoby"),
        "id" => "faq_page_heading",
        "type" => "text",
        "sanitize_callback" => "none",
        "translate" => true,
      ],
      [
        "name" => __("Subheading", "inoby"),
        "id" => "faq_page_subheading",
        "type" => "text",
        "sanitize_callback" => "none",
        "translate" => true,
      ],
      [
        "group_title" => __("#{#} {faq_tab_title}", "inoby"),
        "id" => "faq_page_tabs",
        "type" => "group",
        "clone" => true,
        "collapsible" => true,
        "default_state" => "collapsed",
        "fields" => [
          [
            "name" => __("Heading of section", "inoby"),
            "id" => "faq_tab_title",
            "type" => "text",
            "sanitize_callback" => "none",
            "translate" => true,
          ],
          [
            "name" => __("Section slug", "inoby"),
            "id" => "faq_tab_slug",
            "type" => "text",
            "translate" => true,
          ],
          [
            "name" => __("Section icon", "inoby"),
            "id" => "faq_tab_icon",
            "type" => "image_advanced",
            "force_delete" => false,
            "max_file_uploads" => 1,
            "max_status" => false,
            "image_size" => "thumbnail",
          ],
          [
            "group_title" => __("#{#} {faq_tabs_question}", "inoby"),
            "id" => "faq_tabs",
            "type" => "group",
            "clone" => true,
            "collapsible" => true,
            "default_state" => "collapsed",
            "fields" => [
              [
                "name" => __("Question", "inoby"),
                "id" => "faq_tabs_question",
                "type" => "text",
                "translate" => true,
              ],
              [
                "name" => __("Answer", "inoby"),
                "id" => "faq_tabs_answer",
                "type" => $useWysiwyg ? "wysiwyg" : "textarea",
                "sanitize_callback" => "none",
                "translate" => true,
              ],
            ],
          ],
        ],
      ],
    ],
  ];
  return $meta_boxes;
});
