PHP code example of dawn / wordpress_asset

1. Go to this page and download the library: Download dawn/wordpress_asset 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/ */

    

dawn / wordpress_asset example snippets


Script::add('foo', array(
	'ver' => '1.0.0',
	'deps' => array('jquery'),
	'path' => '/fixtures/foo.js',
	'base' => '/public',
	'footer' => 'true',
	'area' => 'front',
	'async' => true,
  ));

Package::add('foo', array(
	'script' => array(
		'bar' => array(
			'path' => '/fixtures/bar.js',
			'ver' => '1.2.0',
		),
		'foo' => array(
			'path' => '/fixtures/foo.js',
			'area' => 'admin',
		),
	),
	'style' => array(
		'bar' => array(
			'path' => '/fixtures/bar.css',
		),
		'foo' => array(
			'path' => '/fixtures/foo.css',
		),
	),
	'version' => '1.0.0',
	'base' => '/public',
));


$packageManager->register(array(
	'jquery' => array(
		'scripts' => array('jquery.js'),
		'styles' => array('jquery.css'),
	),
	'react' => array(
		'scripts' => array('react.js'),
		'styles' => array('react.css'),
	),
	'bootstrap' => array(
		'scripts' => array('bootstrap.js'),
		'styles' => array('bootstrap.css'),
	),
), array(
	'base' => '/public/asset/',
	'area' => 'public',
	'version' => '1.5.0',
));

//use PackgeManager->add will register asset
$packageManger->add('react');


//use pakcageManger->queue will enqueue asset
$packgeManger->queue('react');