<?php
declare(strict_types=1);

use AuxCF\Entities\Field\Enum\WysiwygFieldToolbarEnum;
use WP_AUX\Entities\Admin\AuxComponents\AuxComponentsPageEntity;
use WP_AUX\Entities\Admin\AuxDeprecationsPageEntity;
use WP_AUX\Services\AuxCF\ValidationService;
use WP_AUX\Services\HeadService;

/**
 * Main class for AUX Custom Fields
 * @since 1.0.0
 */
class AuxCF
{
  public const FIELDS_DIR = 'Entities/Field';
  public const FIELD_GROUPS_DIR = 'Entities/FieldGroup';

  public const DOCUMENTATION_BASE = 'https://aggieux.tamu.edu/?path=/docs/';

  /**
   * Load admin pages and prepare filters and actions for AUX Custom Fields
   * @since 1.0.0
   */
  public static function prepareHooks() {
    new AuxComponentsPageEntity();
    new AuxDeprecationsPageEntity();

    // Initialize validation service
    ValidationService::prepareHooks();

    /**
     * Add AUX-ACF javascript
     */
    add_action('admin_init', function() {
      HeadService::enqueueLocalScript('acf-submenu', 'js/acf-aux.js');
    });

    /**
     * Add custom WYWIWYG toolbar configuration options
     */
    add_filter( 'acf/fields/wysiwyg/toolbars', function ( $toolbars ) {
      $toolbars[WysiwygFieldToolbarEnum::UltraBasic->value] = [
        1 => [ 'link' , 'undo' , 'redo' ],
      ];
      $toolbars[WysiwygFieldToolbarEnum::ComponentFull->value] = $toolbars[WysiwygFieldToolbarEnum::Full->name];

      return $toolbars;
    });
  }
}
