Skip to content

Commit

Permalink
Updating the constants section, updating the load_file() function to …
Browse files Browse the repository at this point in the history
…give identifiers to the scripts and styles
  • Loading branch information
tommcfarlin committed Dec 5, 2011
1 parent efb0a5b commit cf819ba
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
// TODO: rename this class to a proper name for yuour plugin
class PluginName {

/*--------------------------------------------*
* Constants
*--------------------------------------------*/

/**
* TODO: update these values to reflect the name, locale, and slug
* of your plugin.
* TODO: update these values to reflect the name and slug of your plugin.
*/

const name = 'Plugin Name';
Expand Down Expand Up @@ -117,7 +120,7 @@ private function init_plugin_constants() {
* For example: WordPress Widget Boilerplate.
*/
if ( !defined( 'PLUGIN_NAME' ) ) {
define( 'PLUGIN_NAME', 'Plugin Name' );
define( 'PLUGIN_NAME', self::name );
} // end if

/* TODO
Expand All @@ -131,7 +134,7 @@ private function init_plugin_constants() {
* For example: wordpress-widget-boilerplate
*/
if ( !defined( 'PLUGIN_SLUG' ) ) {
define( 'PLUGIN_SLUG', 'plugin-name-slug' );
define( 'PLUGIN_SLUG', self::slug );
} // end if

} // end init_plugin_constants
Expand All @@ -142,11 +145,11 @@ private function init_plugin_constants() {
*/
private function register_scripts_and_styles() {
if ( is_admin() ) {
$this->load_file( plugin_dir_path(__FILE__) . '/js/admin.js', true );
$this->load_file( plugin_dir_path(__FILE__) . '/css/admin.css' );
$this->load_file( self::slug . '-admin-script', plugin_dir_path(__FILE__) . '/js/admin.js', true );
$this->load_file( self::slug . '-admin-styles', plugin_dir_path(__FILE__) . '/css/admin.css' );
} else {
$this->load_file( plugin_dir_path(__FILE__) . '/js/widget.js', true );
$this->load_file( plugin_dir_path(__FILE__) . '/css/widget.css' );
$this->load_file( self::slug . '-scripts', plugin_dir_path(__FILE__) . '/js/display.js', true );
$this->load_file( self::slug . '-styles', plugin_dir_path(__FILE__) . '/css/display.css' );
} // end if/else
} // end register_scripts_and_styles

Expand Down

0 comments on commit cf819ba

Please sign in to comment.