<?php
/**
 * BookiFlex
 *
 * @package   BookiFlex
 * @author    BookiFlex
 * @copyright Copyright (c) 2025 BookiFlex
 * @license   GPL-2.0-or-later
 *
 * @link      https://bookiflex.com
 */

declare(strict_types=1);

namespace BookiFlex\Core\Admin\Field;

use Carbon_Fields\Field;

defined( 'ABSPATH' ) || exit;

class SectionNotice
{
    public static function make(string $id, string $text, string $docsUrl = ''): \Carbon_Fields\Field\Field
    {
        $link = '';

        if ($docsUrl) {
            $link = sprintf(
                '<a href="%s" target="_blank" rel="noopener noreferrer" class="bflex-section-notice__link">'
                . '%s <span class="dashicons dashicons-external"></span>'
                . '</a>',
                esc_url($docsUrl),
                esc_html__('Documentation', 'bookiflex')
            );
        }

        $html = sprintf(
            '<div class="bflex-section-notice"><p>%s</p>%s</div>',
            wp_kses_post($text),
            $link
        );

        return Field::make('html', $id)->set_html($html);
    }
}
