Skip to content

Commit

Permalink
Introduce a helper for plugin asset URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Jan 20, 2018
1 parent 82ab90b commit b892f4d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions class/class-widget-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,16 @@ function admin_scripts( $page ) {
return;
}

$plugin_basename = plugin_basename( $this->plugin_path );

wp_enqueue_style(
'widget-context-css',
plugins_url( $plugin_basename . '/css/admin.css' ),
$this->asset_url( '/css/admin.css' ),
null,
$this->asset_version
);

wp_enqueue_script(
'widget-context-js',
plugins_url( $plugin_basename . '/js/widget-context.js' ),
$this->asset_url( '/js/widget-context.js' ),
array( 'jquery' ),
$this->asset_version
);
Expand Down Expand Up @@ -1027,11 +1025,22 @@ function widget_context_debug_bar_scripts() {

wp_enqueue_script(
'widget-context-debug-js',
plugins_url( plugin_basename( $this->plugin_path ) . '/debug/debug.js' ),
$this->asset_url( '/debug/debug.js' ),
array( 'jquery' )
);

}

/**
* Return the public URL of a plugin asset file.
*
* @param string $asset_relative_path Relative path to the asset file.
*
* @return string
*/
function asset_url( $asset_relative_path ) {
return plugins_url( plugin_basename( $this->plugin_path ) . $asset_relative_path );
}


}

0 comments on commit b892f4d

Please sign in to comment.