1
0
Fork 0
mirror of https://github.com/inretio/WordPress-Plugin-Boilerplate synced 2024-12-22 20:03:53 +02:00

Adding the plugin slug to the constructor args

This commit is contained in:
Tom McFarlin 2014-07-29 17:09:55 -04:00
parent 560e5959a5
commit 370c439bb2
2 changed files with 30 additions and 6 deletions

View file

@ -23,6 +23,15 @@
*/ */
class Plugin_Name_Admin { class Plugin_Name_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $slug The ID of this plugin.
*/
private $slug;
/** /**
* The version of this plugin. * The version of this plugin.
* *
@ -39,8 +48,11 @@ class Plugin_Name_Admin {
* @access public * @access public
* @var string $version The version of this plugin. * @var string $version The version of this plugin.
*/ */
public function __construct( $version ) { public function __construct( $slug, $version ) {
$this->slug = $slug;
$this->version = $version; $this->version = $version;
} }
/** /**
@ -62,7 +74,7 @@ class Plugin_Name_Admin {
* class. * class.
*/ */
wp_enqueue_style( 'plugin-name-admin', plugin_dir_url( __FILE__ ) . 'css/plugin-name-admin.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->slug, plugin_dir_url( __FILE__ ) . 'css/plugin-name-admin.css', array(), $this->version, 'all' );
} }
@ -85,7 +97,7 @@ class Plugin_Name_Admin {
* class. * class.
*/ */
wp_enqueue_script( 'plugin-name-admin', plugin_dir_url( __FILE__ ) . 'js/plugin-name-admin.js', array( 'jquery' ), $this->version, FALSE ); wp_enqueue_script( $this->slug, plugin_dir_url( __FILE__ ) . 'js/plugin-name-admin.js', array( 'jquery' ), $this->version, FALSE );
} }

View file

@ -23,6 +23,15 @@
*/ */
class Plugin_Name_Public { class Plugin_Name_Public {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $slug The ID of this plugin.
*/
private $slug;
/** /**
* The version of this plugin. * The version of this plugin.
* *
@ -39,8 +48,11 @@ class Plugin_Name_Public {
* @access public * @access public
* @var string $version The version of this plugin. * @var string $version The version of this plugin.
*/ */
public function __construct( $version ) { public function __construct( $slug, $version ) {
$this->slug = $slug;
$this->version = $version; $this->version = $version;
} }
/** /**
@ -62,7 +74,7 @@ class Plugin_Name_Public {
* class. * class.
*/ */
wp_enqueue_style( 'plugin-name-public', plugin_dir_url( __FILE__ ) . 'css/plugin-name-public.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->slug, plugin_dir_url( __FILE__ ) . 'css/plugin-name-public.css', array(), $this->version, 'all' );
} }
@ -85,7 +97,7 @@ class Plugin_Name_Public {
* class. * class.
*/ */
wp_enqueue_script( 'plugin-name-public', plugin_dir_url( __FILE__ ) . 'js/plugin-name-public.js', array( 'jquery' ), $this->version, FALSE ); wp_enqueue_script( $this->slug, plugin_dir_url( __FILE__ ) . 'js/plugin-name-public.js', array( 'jquery' ), $this->version, FALSE );
} }