-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} | ||
} |