Skip to content

Commit

Permalink
feat: Added getter trait
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Aug 8, 2023
1 parent d67be41 commit f2fed4d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions src/Loader_Trait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Loader_Trait class file.
*
* @package Asset Loader
*/

namespace Oblak\WP;

/**
* Getters for asset path and URI.
*/
trait Loader_Trait {

/**
* Namespace for the assets
*
* @var string
*/
protected $namespace;

/**
* Initializes the asset loader
*
* @param array $assets Array of assets to load.
*/
protected function init_asset_loader( $assets ) {
add_action(
'init',
function() use ( $assets ) {
Asset_Loader::get_instance()->register_namespace( $this->namespace, $assets );
}
);
}

/**
* Get the cache buster asset path
*
* @param string $asset Asset path.
* @return string Asset path with cache buster.
*/
public function asset_path( $asset ) {
return Asset_Loader::get_instance()->get_path( $this->namespace, $asset );
}

/**
* Get the cache buster asset uri
*
* @param string $asset Asset uri.
* @return string Asset uri with cache buster.
*/
public function asset_uri( $asset ) {
return Asset_Loader::get_instance()->get_uri( $this->namespace, $asset );
}
}

0 comments on commit f2fed4d

Please sign in to comment.