From 27c86bc7939c2a04094fce01029ce0e96049751b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 19 Jan 2015 13:39:30 -0500 Subject: [PATCH] Fixed errors with encueing scripts --- controllers/admin.php | 27 ++++++- controllers/front.php | 2 +- index.php | 28 -------- lib/smartyTemplateSupport.php | 129 ++++++++++++++++------------------ 4 files changed, 87 insertions(+), 99 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index 3eb77bb..a27dc3b 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -162,6 +162,13 @@ class glmProtoAdmin $this, 'configureMenus' )); + + // Add admin scripts and css + add_action('admin_enqueue_scripts', + array( + $this, + 'glmProtoAdminScripts' + )); } /** @@ -208,6 +215,23 @@ class glmProtoAdmin } } + function glmProtoAdminScripts () + { + wp_enqueue_media(); + wp_register_script('glm-proto-index-js', + GLM_PROTO_PLUGIN_URL . 'js/index.js', + array( + 'jquery' + )); + wp_enqueue_script('glm-proto-index-js'); + + // A simple set of styles for things I haven't found as a WordPress + // default yet + wp_register_style('glmProtoIndexStyle', + GLM_PROTO_PLUGIN_URL . 'css/index.css'); + wp_enqueue_style('glmProtoIndexStyle'); + } + /* * Menu item specific "Callback" methods * @@ -388,11 +412,10 @@ class glmProtoAdmin // Generate output from model data and view if ($viewText) { - $smarty->template->display('string:'.$view); + $smarty->template->display('string:' . $view); } else { $smarty->template->display($view); } - } } diff --git a/controllers/front.php b/controllers/front.php index 6ba764c..1756399 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -29,7 +29,7 @@ class glmProtoFront */ public $wpdb; - public function __construct () + public function __construct ($wpdb) { // Save WordPress Database object diff --git a/index.php b/index.php index ce0cdf7..dd767af 100644 --- a/index.php +++ b/index.php @@ -222,34 +222,6 @@ function glmProtoPluginUninstall () } register_uninstall_hook(__FILE__, 'glmProtoPluginUninstall'); -/* - * - * Style Sheets - * - */ - -// A simple set of styles for things I haven't found as a WordPress default yet -wp_register_style('glmProtoIndexStyle', GLM_PROTO_PLUGIN_URL . 'css/index.css'); -wp_enqueue_style('glmProtoIndexStyle'); - -/* - * - * JAVAscript files that need to be enqueued. - * - */ - -add_action('admin_enqueue_scripts', 'glmProtoScripts'); - -function glmProtoScripts () -{ - wp_enqueue_media(); - wp_register_script('glm-proto-index-js', - GLM_PROTO_PLUGIN_URL . 'js/index.js', - array( - 'jquery' - )); - wp_enqueue_script('glm-proto-index-js'); -} /* * diff --git a/lib/smartyTemplateSupport.php b/lib/smartyTemplateSupport.php index 7325035..75ee778 100644 --- a/lib/smartyTemplateSupport.php +++ b/lib/smartyTemplateSupport.php @@ -29,83 +29,76 @@ * new smartyTemplateSupport(); * */ -class smartyTemplateSupport -{ +class smartyTemplateSupport { - /** - * Smarty Template Object - * - * @var $template - * @access public - */ - public $template; + /** + * Smarty Template Object + * + * @var $template + * @access public + */ + public $template; - /* - * Smarty Template Support Constructor - * - * This constructor loads and instatiates smarty templates, then adds some - * standard template parameters. - * - * @return object Class object - * - */ - public function __construct () - { + /* + * Smarty Template Support Constructor + * + * This constructor loads and instatiates smarty templates, then adds some + * standard template parameters. + * + * @return object Class object + * + */ + public function __construct() { - /* - * Load and instatiate Smarty Templates - */ - require (GLM_PROTO_PLUGIN_DIR . - '/lib/Smarty-3.1.21/libs/Smarty.class.php'); + /* + * Load and instatiate Smarty Templates + */ + require (GLM_PROTO_PLUGIN_DIR . '/lib/Smarty-3.1.21/libs/Smarty.class.php'); - $this->template = new Smarty(); + $this->template = new Smarty (); - /* - * Configure Smarty Templates for this site - */ - $this->template->setTemplateDir(GLM_PROTO_PLUGIN_DIR . '/views'); - $this->template->setCompileDir( - GLM_PROTO_PLUGIN_DIR . '/misc/smarty/templates_c'); - $this->template->setCacheDir( - GLM_PROTO_PLUGIN_DIR . '/misc/smarty/cache'); - $this->template->setConfigDir( - GLM_PROTO_PLUGIN_DIR . '/misc/smarty/configs'); - } + /* + * Configure Smarty Templates for this site + */ + $this->template->setTemplateDir ( GLM_PROTO_PLUGIN_DIR . '/views' ); + $this->template->setCompileDir ( GLM_PROTO_PLUGIN_DIR . '/misc/smarty/templates_c' ); + $this->template->setCacheDir ( GLM_PROTO_PLUGIN_DIR . '/misc/smarty/cache' ); + $this->template->setConfigDir ( GLM_PROTO_PLUGIN_DIR . '/misc/smarty/configs' ); + } - /* - * Assign parameters to the template - * - * This method assigns either one parameter to the template object in this - * class or an array of parameters. - * - * Submit an array of parameters to the template. - * - * @name array Array of arrays with parameter name (key), value pairs - * - * or - * - * Submit one parameter to the template - * - * @param text parameter name - * @param {whatever} parameter value - * - * @return void - */ - public function templateAssign ($param, $value = null) - { + /* + * Assign parameters to the template + * + * This method assigns either one parameter to the template object in this + * class or an array of parameters. + * + * Submit an array of parameters to the template. + * + * @name array Array of arrays with parameter name (key), value pairs + * + * or + * + * Submit one parameter to the template + * + * @param text parameter name + * @param {whatever} parameter value + * + * @return void + */ + public function templateAssign($param, $value = null) { - // If this is a single assignment - if ($value !== null) { - $this->template->assign($param, $value); + // If this is a single assignment + if ($value !== null) { + $this->template->assign ( $param, $value ); - // Otherwise it's an array of parameter/value pairs - } elseif (is_array($param)) { + // Otherwise it's an array of parameter/value pairs + } elseif (is_array ( $param )) { - while (list ($key, $value) = each($param)) { - $this->template->assign($key, $value); - } - } - } + while ( list ( $key, $value ) = each ( $param ) ) { + $this->template->assign ( $key, $value ); + } + } + } } ?> \ No newline at end of file -- 2.17.1