Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WordPress] WordPress Plugin Interfaces: Working With Assets
namespace Acme\Admin\Interfaces;
interface Asset {
public function init();
public function enqueue();
namespace Acme\Admin;
use Acme\Admin\Interfaces;
class JavaScript_Assets implements Interfaces\Asset {
private $assets_dir;
private $js_dir;
public function __construct() {
$this->assets_dir = trailingslashit(
plugin_dir_url( __FILE__ ) . 'assets'
$this->js_dir = trailingslashit( $this->assets_dir . 'js' );
public function init() {
array( $this, 'enqueue' )
public function enqueue() {
$this->js_dir . 'admin.js',
array( 'jquery' ),
$assets = new Admin\JavaScript_Assets();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.