PHP code example of alleyinteractive / wp-asset-manager
1. Go to this page and download the library: Download alleyinteractive/wp-asset-manager 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/ */
alleyinteractive / wp-asset-manager example snippets
// Print the contents of this CSS asset into a <style> tag.
// Also works with `am_enqueue_script` for printing a JavaScript asset into a <script> tag.
am_enqueue_style(
[
'handle' => 'inline-styles',
'src' => 'css/styles.css',
'condition' => 'global',
'load_method' => 'inline',
]
);
// Add JavaScript values to a property on the `window.amScripts` object.
am_enqueue_script(
[
'handle' => 'inline-vars',
'src' => [
'myGlobalVar' => true,
],
'load_method' => 'inline',
]
);
// `as` and `mime_type` options will be automatically added for CSS, but are /styles.css',
'condition' => 'global',
'version' => '1.0.0',
'as' => 'style'
'mime_type' => 'text/css',
]
);
/**
* Add SVG symbols to the admin page content.
*/
function print_admin_sprite() {
if ( class_exists( 'Asset_Manager_SVG_Sprite' ) ) {
Asset_Manager_SVG_Sprite::instance()->print_sprite_sheet();
}
}
add_action( 'in_admin_header', 'print_admin_sprite' );