<?php

if (Inoby_Config::contact_form()) {
  require_once INOBY_BASE . "/inoby-plugins/contact-form/inc/metaboxes.php";
  require_once INOBY_BASE . "/inoby-plugins/contact-form/inc/class-contact-form.php";

  $contact_form = new \Inoby\ContactForm();

  add_action("wp_ajax_inoby_contact_form", [$contact_form, "handle"]);
  add_action("wp_ajax_nopriv_inoby_contact_form", [$contact_form, "handle"]);

  if (!function_exists("inoby_contact_form")) {
    /**
     * Output contact form template
     *
     * @param array $args Optional arguments passed to template part.
     *              Arguments "class" and "textarea-rows" are supported
     * @return void
     */
    function inoby_contact_form(array $args = []): void {
      \Inoby\ContactForm::template($args);
    }
  }
}
