<?php

if (! defined('ABSPATH')) {
    exit;
} class PufferGo_Commands
{
    public const MIN_WP_VERSION = '7.0';

    public const HANDLE = 'puffergo-commands';

    public static function init()
    {
        add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue'));
    }

    public static function enqueue()
    {
        if (version_compare(get_bloginfo('version'), self::MIN_WP_VERSION, '<')) {
            return;
        }

if (! wp_script_is('wp-commands', 'registered')) {
            return;
        } $plugin_dir = dirname(__DIR__);
        $asset_file = $plugin_dir . '/build/admin/commands/index.asset.php';
        $script_file = $plugin_dir . '/build/admin/commands/index.js';

        if (! file_exists($asset_file) || ! file_exists($script_file)) {
            return;
        } $asset = require $asset_file;
        wp_enqueue_script(self::HANDLE, plugin_dir_url($plugin_dir . '/puffergo.php') . 'build/admin/commands/index.js', array_merge($asset['dependencies'], array('wp-commands')), $asset['version'], true);
        wp_localize_script(self::HANDLE, 'puffergoCommands', array('adminUrl' => admin_url(), 'caps' => array('manage_options' => current_user_can('manage_options'), 'edit_posts' => current_user_can('edit_posts'), ), ));
    }
}
