Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobschweitzer committed Mar 20, 2024
1 parent 9fddddb commit 60b47b5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions php/class-asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,20 @@ public function add_asset( $args ) {
// Enqueue asset if applicable.
if ( in_array( $args['load_method'], $this->wp_enqueue_methods, true ) && empty( $args['loaded'] ) ) {
if ( function_exists( $wp_enqueue_function ) ) {

// If this is for a style, just pass the media argument.
if ( 'style' === $args['type'] ) {
$enqueue_options = $args['media'];
} else {
// If this is for a script, pass the in_footer argument when on a version prior to 6.3.
if ( version_compare( $GLOBALS['wp_version'], '6.3', '<' ) ) {
$enqueue_options = $args['in_footer'];
} else {
// We are on a version of WordPress 6.3+ so the last argument is an array.
$enqueue_options = [
'in_footer' => $args['in_footer'],
];
// If the load method is async or defer, set the strategy.
if ( in_array( $args['load_method'], [ 'async', 'defer' ], true ) ) {
$enqueue_options['strategy'] = $args['load_method'];
}
Expand Down

0 comments on commit 60b47b5

Please sign in to comment.