PHP code example of bojaghi / scripts

1. Go to this page and download the library: Download bojaghi/scripts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bojaghi / scripts example snippets




// No direct access
if (!defined('ABSPATH')) {
    exit;
}

return [
    'scripts' => [
        'items' => [
            [ /* item */ ],
            [ /* item */ ],
        ],
        'enqueue' => function (string $handle): bool { return 'foo' === $handle; }, // As a callback function
        'admin_enqueue' => fn (string $handle, string $hook): bool => 'post.php' === $hook && 'foo' === $handle, // As a callback
        'enqueue_priority' => 10,
        'admin_enqueue_priority' => 10,
    ],
    'styles'  => [
        'items' => [
            [ /* item */ ],
            [ /* item */ ],
        ],
        'enqueue' => [
            // Per-handle callback functions
            'foo' => function(string $handle): bool { return true; },
            'bar,baz' => function (string $handle): bool { return true; }, // Be sure 'bar' and 'baz' appear only once
        ],
        'admin_enqueue' => [
            // Per-handle callback functions
            'adm_foo' => function(string $handle, $hook): bool { return true; },
            'adm_bar,adm_baz' => fn (string $handle, $hook): bool => true, // Be sure 'bar' and 'baz' appear only once
        ],
        'enqueue_priority' => 10,
        'admin_enqueue_priority' => 10,
    ],
];


$instance = new Scripts([/* ... 설정 배열 ... */]);
// 또는
$instance = new Scripts('/path/to/config/path');