Permalink
Browse files

fixing admin includes and ensuring Sanity can have

multiple instances.
  • Loading branch information...
1 parent beb7575 commit 1a16a407ea3e5fea5b9344e3ee1cc3174fecb219 Emerson Lackey committed Jul 26, 2011
Showing with 35 additions and 20 deletions.
  1. +15 −2 README
  2. 0 css/empty
  3. +4 −3 example-plugin.php
  4. +16 −15 framework/sanity.php
  5. 0 js/empty
View
17 README
@@ -33,5 +33,18 @@ Whenever possible, we should separate PHP from HTML. Within Wordpress, you'll se
<h2>The Separation of Logic and Views</h2>
<p><?php echo $this->data['message'];?></p>
-
-
+
+Admin Javascript
+================
+Sometimes you might like to include some handy javascript or stylesheet files within the admin area of your wordpress installation. Well, Sanity makes this task quite easy! Just populate our $admin_js and $admin_css class variables with an array of scripts you would like to include.
+
+ class YourPlugin extends SanityPluginFramework {
+
+ // Loads /plugin/js/example.js
+ $admin_js = array('example');
+
+ // Loads /plugin/css/example.css
+ $admin_css = array('example');
+
+ }
+
View
No changes.
View
@@ -11,7 +11,8 @@
// Derive the current path and load up Sanity
$plugin_path = dirname(__FILE__).'/';
-require($plugin_path.'framework/sanity.php');
+if(class_exists('SanityPluginFramework') != true)
+ require_once($plugin_path.'framework/sanity.php');
/*
@@ -22,10 +23,10 @@
class ExamplePlugin extends SanityPluginFramework {
/*
- * Some required plugin information
+ * Some required plugin information
*/
var $version = '1.0';
-
+ var $admin_js = array('hello');
/*
* Required __construct() function that initalizes the Sanity Framework
View
@@ -1,37 +1,38 @@
<?php
class SanityPluginFramework {
- // Container variables
+ // Container variables
var $view = '';
var $data = array();
var $wpdb;
- var $nonce;
-
+ var $nonce;
+
// Assets to load
var $admin_css = array();
var $admin_js = array();
var $plugin_css = array();
var $plugin_js = array();
- // Paths
- var $css_path = '';
- var $js_path = '';
- var $plugin_dir = '';
+ // Paths
+ var $css_path = 'css';
+ var $js_path = 'js';
+ var $plugin_dir = '';
- // AJAX actions
- var $ajax_actions = array(
- 'admin' => array(),
- 'plugin' => array()
- );
+ // AJAX actions
+ var $ajax_actions = array(
+ 'admin' => array(),
+ 'plugin' => array()
+ );
function __construct() {
global $wpdb;
- $this->add_ajax_actions();
+ $this->plugin_dir = basename(dirname(dirname(__FILE__)));
+ $this->add_ajax_actions();
$this->wpdb = $wpdb;
$this->css_path = WP_PLUGIN_URL.'/'.$this->plugin_dir.'/css/';
$this->js_path = WP_PLUGIN_URL.'/'.$this->plugin_dir.'/js/';
- $this->plugin_dir = basename(dirname(dirname(__FILE__)));
- add_action('wp_loaded', array(&$this, 'create_nonce'));
+ $this->plugin_dir = basename(dirname(dirname(__FILE__)));
+ add_action('wp_loaded', array(&$this, 'create_nonce'));
if(!empty($this->admin_css) || !empty($this->admin_js) ) {
add_action('admin_enqueue_scripts', array(&$this, 'load_admin_scripts'));
}
View
No changes.

0 comments on commit 1a16a40

Please sign in to comment.