--- /dev/null
+<?php
+
+/**
+ * scriptRegistry.php
+ *
+ * PHP version 5.2
+ *
+ * @category Classes
+ * @package Script and Style Registry
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2012 Gaslight Media
+ * @license Gaslight Media
+ * @version SVN: $Id$
+ * @link <>
+ */
+
+/**
+ * Script and Style Registry scriptRegistry.php class stores and manages a list of scripts and style
+ * files that are to be enqueued by WordPress functions.
+ *
+ * The intent is to have plugins/add-ons supply information on scripts and styles that might be
+ * loaded in a 'scripts.php' file in the 'setup' directory so that consistency can be maintained and
+ * duplicates can be avoided. Models then simply ask to have a script or style enqueued by
+ * specifying the "handle" of that script using the enqueue() method.
+ *
+ * The 'scripts.php' files should be exclusively a set of calls to the add() method
+ *
+ * @category CommonApps
+ * @package Registry
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2014 Gaslight Media
+ * @license Gaslight Media
+ * @version Release: 1.0
+ * @link <>
+ */
+abstract class glmScriptType
+{
+ const Unknown = 0;
+ const Script = 1;
+ const Style = 2;
+
+}
+
+class glmScript
+{
+
+ /**
+ * Scipt storage class
+ *
+ * @var string $handle Required handle (name) for this script
+ * @var string $src Required source URL of script
+ * @var int $type Required type enumerated (see glmScriptType above)
+ * @var array $deps Optional array of handles for scripts this script depends on
+ * @var boolean $in_footer Optional flag for enqueue before </body> tag
+ * @var string $media Optional media types for styles (i.e. 'all', 'print', 'screen'...)
+ * @var array $attrs Optional tag attribute name/value pairs to be included in tag
+ * @var string $plugin Required plugin slug ('glm-member-db') of requesting plugin
+ * @var string $version Required Version number to use (normally version number of plugin/add-on)
+ * @var boolean $enqueue Flag specifying if it is to be enqueue. Do not supply!
+ * @var boolean $alwaysEnqueue Flag to always enqueue this
+ * @var string $fullHandle A copy of the full handle generated when enqueueing
+ */
+ public $handle = '';
+ public $src = '';
+ public $type = glmScriptType::Unknown;
+ public $deps = false;
+ public $in_footer = false;
+ public $media = 'all';
+ public $attrs = false;
+ public $plugin = false;
+ public $version = false;
+ public $enqueue = false;
+ public $alwaysEnqueue = false;
+ public $fullHandle = '';
+
+ /**
+ * This constructor takes an array of parameters and creates a glmScript object from that.
+ * Not all parameters need to be supplied, only those specified as such above. Defaults will be
+ * used for parameters that are not suplied.
+ *
+ * @param array $scriptVals Array of parameters for script
+ * @return void
+ */
+ public function __construct( $scriptVals )
+ {
+
+ // Add only parameters with valid keys into object
+ if ( is_array( $scriptVals ) && count( $scriptVals ) ) {
+
+ foreach ( $scriptVals as $key=>$val ) {
+ if ( isset( $this->$key ) ) {
+ $this->$key = $val;
+ } else {
+ trigger_error(
+ "glmScriptRegistry invalid glmScipt object parameter: Key = $key, Value = $val",
+ E_USER_NOTICE );
+ }
+ }
+ }
+
+ }
+
+}
+
+/**
+ * Filter for 'script_loader_tag' to add attributes to the
+ * script tag of an enqueued script.
+ *
+ *
+ * @param unknown $tag Supplied script tag
+ * @param unknown $handle Handle for enqueued script
+ * @param unknown $src Source URL for scriptsRgistry
+ *
+ * @return void
+ */
+function glmScriptRegistryTagFilter( $tag, $fullHandle, $src )
+{
+
+ // Is this is not one of our handles, return without change
+ if ( substr( $fullHandle, 0, 4) != 'glm-') {
+ return $tag;
+ }
+
+
+ $script = glmScriptRegistry::find( glmScriptType::Script, $fullHandle);
+
+ if ( $script ) {
+
+ $newTag = "\n".'<script type="text/javascript" src="' . $script->src.'"';
+ if ( $script->attrs && count($script->attrs) ) {
+ foreach ( $script->attrs as $attr=>$attrVal ) {
+ $newTag .= ' '.$attr.'="'.$attrVal.'"';
+ }
+ }
+ $newTag .= '></script>';
+
+ if ( GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ "glmScriptRegistryTagFilter: rewritten = " . $handle,
+ E_USER_NOTICE );
+ }
+
+ }
+
+ return $tag;
+
+}
+
+// Add the above function as 'script_loader_tag' filter
+add_filter( 'script_loader_tag', 'glmScriptRegistryTagFilter', 10, 3 );
+
+class glmScriptRegistry
+{
+
+ // Lists of glmScript objects
+ private static $_scripts = array();
+ private static $_styles = array();
+
+ /**
+ * Add a script to scriptRegistry::_scripts
+ *
+ * @param object $object Object
+ * @param object $name Name of object key
+ *
+ * @return object New script values array or false if failure
+ */
+ static public function add( $scriptVals )
+ {
+
+ // Make sure an array has been submitted
+ if ( !is_array( $scriptVals ) || !count( $scriptVals ) ) {
+ trigger_error(
+ 'glmScriptRegistry add(): No data supplied or not array!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Create an object with the submitted script values
+ $script = new glmScript( $scriptVals );
+
+ // Check if handle not supplied
+ if ( trim( $script->handle ) == '' ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Required "handle" not supplied!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Check if file type is supplied
+ if ( trim( $script->type ) == glmScriptType::Unknown ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Required "type" not supplied or invalid!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Check if src is supplied
+ if ( trim( $script->src ) == '' ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Required "src" not supplied!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Check if plugin is supplied
+ if ( trim( $script->plugin ) == '' ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Required "plugin" not supplied!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Check if version is supplied
+ if ( trim( $script->src ) == '' ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Required "version" not supplied!',
+ E_USER_NOTICE );
+ return false;
+ }
+
+ // Add script to registry list
+ switch ( $script->type ) {
+
+ case glmScriptType::Script:
+
+ // If there's any already listed, check for duplicates
+ if ( count( self::$_scripts ) ) {
+
+ // Check for duplicate handle
+ if ( isset( self::$_scripts[$script->handle] ) ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Duplicate script "handle" submitted! (' .
+ $script->handle . ')', E_USER_NOTICE );
+ return false;
+ }
+
+ // Check for duplicate src
+ foreach ( self::$_scripts as $handle=>$s ) {
+ if ( $script->src == $s->src ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Duplicate script "src" submitted! (' .
+ $s->src . ')', E_USER_NOTICE );
+ return false;
+ }
+ }
+ }
+
+ self::$_scripts[$script->handle] = $script;
+
+ if ( GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ "glmScriptRegistry add(): script handle added = " .
+ $script->handle, E_USER_NOTICE );
+ }
+
+ break;
+
+ case glmScriptType::Style:
+
+ // If there's any already listed, check for duplicates
+ if ( count( self::$_styles ) ) {
+
+ // Check for duplicate handle
+ if ( isset( self::$_styles[$script->handle] ) ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Duplicate style "handle" submitted! (' .
+ $script->handle . ')', E_USER_NOTICE );
+ return false;
+ }
+
+ // Check for duplicate src
+ foreach ( self::$_scripts as $handle=>$s ) {
+ if ( $script->src == $s->src ) {
+ trigger_error(
+ 'glmScriptRegistry add(): Duplicate style "src" submitted! (' .
+ $s->src . ')', E_USER_NOTICE );
+ return false;
+ }
+ }
+ }
+
+ self::$_styles[$script->handle] = $script;
+
+ if ( GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ "glmScriptRegistry add(): style handle added = " .
+ $script->handle, E_USER_NOTICE );
+ }
+
+ break;
+
+ case glmScriptType::Unknown:
+ defaut:
+ trigger_error(
+ "glmScriptRegistry Script Type Unknown: Plugin = $s->plugin, Script = $s->handle",
+ E_USER_NOTICE );
+ break;
+ }
+
+ }
+
+ /**
+ * Find script using fullHandle value
+ *
+ * @param int $type Type - enumerated (see glmScriptType above)
+ * @param string $fullHandle Full handle for script
+ *
+ * @return glmScriptType Script object or false if not found
+ */
+ static public function find( $type, $fullHandle )
+ {
+
+ switch ( $type ) {
+
+ case glmScriptType::Script:
+
+ // Try to find script using fullHandle field
+ if ( count( glmScriptRegistry::$_scripts ) ) {
+ foreach ( glmScriptRegistry::$_scripts as $script ) {
+ if ( $script->fullHandle == $fullHandle ) {
+ return $script;
+ }
+ }
+ }
+
+ break;
+
+ case glmScriptType::Style:
+
+ // Try to find style using fullHandle field
+ if ( count( glmScriptRegistry::$_styles ) ) {
+ foreach ( glmScriptRegistry::$_styles as $style ) {
+ if ( $style->fullHandle == $fullHandle ) {
+ return $style;
+ }
+ }
+ }
+
+ break;
+
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Reset script enqueue selection
+ *
+ * Will reset whether the script is to be enqueued to the setting of the
+ * alwaysEnqueue flag. Normally this would be false.
+ *
+ * @return void
+ */
+ static public function reset()
+ {
+
+ if ( count( self::$_scripts ) ) {
+ foreach ( self::$_scripts as $handle=>$script ) {
+ self::$_scripts[$handle]->enqueue = $script->alwaysEnqueue;
+ }
+ }
+ if ( count( self::$_styles ) ) {
+ foreach ( self::$_styles as $handle=>$script ) {
+ self::$_styles[$handle]->enqueue = $script->alwaysEnqueue;
+ }
+ }
+
+ }
+
+ /**
+ * Selectd a script to be enqueued
+ *
+ * @param int $type Type - enumerated (see glmScriptType above)
+ * @param string $handle Handle of script to be enqueued
+ *
+ * @return boolean Success is true
+ */
+ static public function select( $type, $handle )
+ {
+
+ switch ( $type ) {
+
+ case glmScriptType::Script:
+ if ( isset( self::$_scripts[$handle] ) ) {
+ self::$_scripts[$handle]->enqueue = true;
+ } else {
+ return false;
+ }
+ break;
+
+ case glmScriptType::Style:
+ if ( isset( self::$_styles[$handle] ) ) {
+ self::$_styles[$handle]->enqueue = true;
+ } else {
+ return false;
+ }
+ break;
+
+ case glmScriptType::Unknown:
+ default:
+ return false;
+ break;
+ }
+
+ }
+
+ /**
+ * Get scripts list
+ *
+ * @param boolean $enqueuedOnly Return only enqueued scripts and styles
+ */
+ static public function list( $enqueuedOnly = false)
+ {
+
+ // If not enqueued only, return entire list
+ if ( !$enqueuedOnly ) {
+ return array(
+ 'scripts' => self::$_scripts,
+ 'styles' => self::$_styles
+ );
+ } else {
+
+ // Returning only enqueued scripts
+ $scripts = array();
+ $styles = array();
+
+ if ( count( self::$_scripts ) ) {
+ foreach ( self::$_scripts as $script ) {
+ if ( $script->enqueued ) {
+ $scripts[] = $script;
+ }
+ }
+ }
+ if ( count( self::$_styles ) ) {
+ foreach ( self::$_styles as $style ) {
+ if ( $style->enqueued ) {
+ $styles[] = $style;
+ }
+ }
+ }
+
+ return array(
+ 'scripts' => $scripts,
+ 'styles' => $styles
+ );
+ }
+
+ }
+
+ /**
+ * Enqueue listed scripts
+ */
+ static public function enqueue()
+ {
+
+ // Scripts
+ if ( count( self::$_scripts ) ) {
+
+ foreach ( self::$_scripts as $s ) {
+
+ $handle = $s->plugin . '-script-' . $s->handle;
+
+ wp_register_script( $handle, $s->src, $s->deps, $s->version,
+ $s->in_footer );
+
+ if ( $s->attrs ) {
+ // wp_localize_script( $s->handle, '', $translation_array );
+ }
+
+ // If script is to be enqueued, do so and save full handle
+ if ( $s->enqueue ) {
+ wp_enqueue_script( $handle );
+ self::$_scripts[$s->handle]->fullHandle = $handle;
+
+ if ( GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ "glmScriptRegistry enqueue(): handle = " . $handle .
+ ', src = ' . $s->src . ', version = ' . $s->version,
+ E_USER_NOTICE );
+ }
+ }
+ }
+ }
+
+ // Styles
+ if ( count( self::$_styles ) ) {
+
+ foreach ( self::$_styles as $s ) {
+
+ $handle = $s->plugin . '-style-' . $s->handle;
+
+ wp_register_style( $handle, $s->src, $s->deps, $s->version,
+ $s->media );
+
+ // If style is to be enqueued, do so and save full handle
+ if ( $s->enqueue ) {
+ wp_enqueue_style( $handle );
+ self::$_styles[$s->handle]->fullHandle = $handle;
+
+ if ( GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ "glmScriptRegistry enqueue(): handle = " . $handle,
+ E_USER_NOTICE );
+ }
+ }
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
<?php
+
/**
* Gaslight Media Members Database
* Admin Controller
* @return void
* @access public
*/
- public function __construct ($wpdb, $config)
+ public function __construct( $wpdb, $config )
{
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage().' - Start Admin Controller Constructor',E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() .
+ ' - Start Admin Controller Constructor', E_USER_NOTICE );
}
// Save WordPress Database object
* menuItem/action.
*
*/
- if (isset($_REQUEST['glm_display_direct']) &&
- $_REQUEST['glm_menu_item'] != '') {
+ if ( isset( $_REQUEST['glm_display_direct'] ) &&
+ $_REQUEST['glm_menu_item'] != '' ) {
// Get the desired menu item name and call controller() with that.
- $menuItem = sanitize_text_field($_REQUEST['glm_menu_item']);
- $this->controller($menuItem);
+ $menuItem = sanitize_text_field( $_REQUEST['glm_menu_item'] );
+ $this->controller( $menuItem );
// Exit at this point to stop all WordPress Dashboard output
exit();
}
// Add admin menus
- add_action('admin_menu',
- array(
- $this,
- 'configureMenus'
- )
- );
+ add_action( 'admin_menu', array(
+ $this,
+ 'configureMenus'
+ ) );
// Add dashboard widget
add_action( 'wp_dashboard_setup',
array(
$this,
'glmMembersAdminDashboardWidget'
-
- )
- );
+ ) );
// add shortcode metabox
/*
- add_action('add_meta_boxes', array(
- $this,
- 'glmMembersShortcode'
- ) );
+ * add_action('add_meta_boxes', array(
+ * $this,
+ * 'glmMembersShortcode'
+ * ) );
*/
// Add AJAX image upload action
array(
$this,
'glmMembersAdminAjax'
- )
- );
+ ) );
// Add AJAX image upload action - For front-end access (needs "nopriv")
add_action( 'wp_ajax_nopriv_glm_members_admin_ajax',
array(
$this,
'glmMembersAdminAjax'
- )
- );
+ ) );
// Check the current Git branch and if it's not 'master' then display admin warning
$this->getGitBranch();
- if (count($this->gitBranch) > 0) {
- add_action('admin_notices', array($this, 'glmMembersGitNotice'));
+ if ( count( $this->gitBranch ) > 0 ) {
+ add_action( 'admin_notices', array(
+ $this,
+ 'glmMembersGitNotice'
+ ) );
}
// Create hook for add-ons to create menus
- do_action('glm-member-db-add-menu');
+ do_action( 'glm-member-db-add-menu' );
/*
* Include any misc add-on hooks and filters in add-on setup folder adminMisc.php file.
*
* Note that filter and hook callback functions must be included in-line as shown below...
*
- * add_filter( 'filter_title', function( $parameter ) {
- * // Function code
- * });
+ * add_filter( 'filter_title', function( $parameter ) {
+ * // Function code
+ * });
*
- * Also note that parameters will be in the context of this class.
+ * Also note that parameters will be in the context of this class.
*
*/
- foreach ($this->config['addOns'] as $a) {
+ foreach ( $this->config['addOns'] as $a ) {
- // If setup/adminHooks.php exists include that now - Can be used for additional filters and hooks
- $hooksFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminHooks.php';
- if (is_file($hooksFile)) {
+ // If setup/adminHooks.php exists include that now - Can be used for additional filters
+ // and hooks
+ $hooksFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/adminHooks.php';
+ if ( is_file( $hooksFile ) ) {
require_once $hooksFile;
}
- // If setup/commonHooks.php exists include that now - Can be used for additional filters and hooks
- $commonFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/commonHooks.php';
- if (is_file($commonFile)) {
+ // If setup/commonHooks.php exists include that now - Can be used for additional filters
+ // and hooks
+ $commonFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/commonHooks.php';
+ if ( is_file( $commonFile ) ) {
require_once $commonFile;
}
-
}
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage().' - End Admin Controller Constructor',E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . ' - End Admin Controller Constructor',
+ E_USER_NOTICE );
}
}
* @return void
* @access public
*/
- public function glmMembersAdminAjax()
+ public function glmMembersAdminAjax()
{
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage()." - Start AJAX Controller",E_USER_NOTICE);
- trigger_error(glmAssociateTimeTracker()." - Start AJAX Controller",E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . " - Start AJAX Controller",
+ E_USER_NOTICE );
+ trigger_error(
+ glmAssociateTimeTracker() . " - Start AJAX Controller",
+ E_USER_NOTICE );
}
$defaultTimeZone = date_default_timezone_get();
- date_default_timezone_set($this->config['settings']['time_zone']);
+ date_default_timezone_set( $this->config['settings']['time_zone'] );
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage().' - Start Admin Controller AJAX',E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . ' - Start Admin Controller AJAX',
+ E_USER_NOTICE );
}
// Get the model action
- if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
- $glmAction = sanitize_text_field($_REQUEST['glm_action']);
- if ($glmAction == '') {
+ if ( isset( $_REQUEST['glm_action'] ) && $_REQUEST['glm_action'] != '' ) {
+ $glmAction = sanitize_text_field( $_REQUEST['glm_action'] );
+ if ( $glmAction == '' ) {
// No menu provided - terminating
- trigger_error ( 'ERROR: No "glm_action" string provided in POST array.', E_USER_ERROR);
+ trigger_error(
+ 'ERROR: No "glm_action" string provided in POST array.',
+ E_USER_ERROR );
}
-
} else {
- trigger_error ( 'ERROR: No "glm_action" itme in POST array.', E_USER_ERROR);
+ trigger_error( 'ERROR: No "glm_action" itme in POST array.',
+ E_USER_ERROR );
}
// Scan through the plugins to find the specified action
$actionFound = false;
- foreach ($this->config['addOns'] as $a) {
+ foreach ( $this->config['addOns'] as $a ) {
// Check for a valid action in this plugin
- if (isset($a['actions']['adminActions']['ajax'][$glmAction])) {
+ if ( isset( $a['actions']['adminActions']['ajax'][$glmAction] ) ) {
// Build model and path and class names
- $modelName = $a['dir'].'/models/admin/ajax/'.$glmAction.'.php';
- $className = 'GlmMembersAdmin_ajax_'.$glmAction;
+ $modelName = $a['dir'] . '/models/admin/ajax/' . $glmAction .
+ '.php';
+ $className = 'GlmMembersAdmin_ajax_' . $glmAction;
// If model file doesn't exist - we have an error
- if (!file_exists($modelName)) {
- trigger_error ( "ERROR: The specified model file doesn't exist. ($modelName)", E_USER_ERROR);
+ if ( !file_exists( $modelName ) ) {
+ trigger_error(
+ "ERROR: The specified model file doesn't exist. ($modelName)",
+ E_USER_ERROR );
}
// Load the model file
require_once $modelName;
// check for an invalid model class name
- if (!class_exists($className)) {
- trigger_error ( "ERROR: The specified class naeme doesn't exist. ($className)", E_USER_ERROR);
+ if ( !class_exists( $className ) ) {
+ trigger_error(
+ "ERROR: The specified class naeme doesn't exist. ($className)",
+ E_USER_ERROR );
}
$actionFound = true;
// Instantiate the model and ask it to perform the work
- $model = new $className($this->wpdb, $this->config);
+ $model = new $className( $this->wpdb, $this->config );
$results = $model->modelAction();
// If no results array were passed back (no need for template output), die here
- if (!is_array($results)) {
+ if ( !is_array( $results ) ) {
wp_die();
}
-
-
}
}
// Check if no matching action found
- if (!$actionFound) {
- $err = 'ERROR: The specified action is not valid - '.$glmAction;
- trigger_error ( $err, E_USER_ERROR);
+ if ( !$actionFound ) {
+ $err = 'ERROR: The specified action is not valid - ' . $glmAction;
+ trigger_error( $err, E_USER_ERROR );
}
// Get the current theme directory to check for modified views
// Get the specified view file path and name
$view = false;
- if (isset($results['view'])) {
+ if ( isset( $results['view'] ) ) {
$view = $results['view'];
}
// If a view file is specified
$badView = false;
- if ($view) {
+ if ( $view ) {
// Get the specified view file - check theme first
$viewPath = "$theme/$plugIn/views";
$viewFile = $view;
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
// Next try the plugin/add-on
$viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";
$viewFile = $view;
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
// No matching view file found
$errorMsg .= "<b>Bad or missing view file:</b> $viewPath/$viewfile";
$badView = true;
-
}
-
}
-
}
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
- trigger_error("AJAX Controller, Model = $modelName",E_USER_NOTICE);
- trigger_error("AJAX Controller, View = $viewPath/$viewFile",E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
+ trigger_error( "AJAX Controller, Model = $modelName", E_USER_NOTICE );
+ trigger_error( "AJAX Controller, View = $viewPath/$viewFile",
+ E_USER_NOTICE );
}
/*
$smarty = new smartyTemplateSupport();
// Add standard template parameters
- require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
// Add data from model to Smarty template
- if (is_array($results['data']) && count($results['data']) > 0) {
- foreach ($results['data'] as $k => $d) {
- $smarty->templateAssign($k, $d);
+ if ( is_array( $results['data'] ) && count( $results['data'] ) > 0 ) {
+ foreach ( $results['data'] as $k=>$d ) {
+ $smarty->templateAssign( $k, $d );
}
}
- $smarty->templateAssign ( 'thisAction', $glmAction);
+ $smarty->templateAssign( 'thisAction', $glmAction );
// Update the Smarty view path - *** NEEED TO FIX THIS TO SUPPORT THEME VIEWS SOMEHOW ****
- $smarty->template->addTemplateDir($viewPath);
+ $smarty->template->addTemplateDir( $viewPath );
// Generate output from model data and view
- $smarty->template->display($viewFile);
+ $smarty->template->display( $viewFile );
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage().' - End Admin Controller AJAX',E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . ' - End Admin Controller AJAX',
+ E_USER_NOTICE );
}
// Restore timezone that was set before our code was called
- date_default_timezone_set($defaultTimeZone);
+ date_default_timezone_set( $defaultTimeZone );
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage()." - End AJAX Controller",E_USER_NOTICE);
- trigger_error(glmAssociateTimeTracker()." - End AJAX Controller",E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error( glmAssociateMemoryUsage() . " - End AJAX Controller",
+ E_USER_NOTICE );
+ trigger_error( glmAssociateTimeTracker() . " - End AJAX Controller",
+ E_USER_NOTICE );
}
- exit; // Need to test if this is here for a reason!
+ exit(); // Need to test if this is here for a reason!
wp_die();
}
* @return void
* @access public
*/
- public function glmMembersAdminScripts ()
+ public function glmMembersAdminScripts()
{
+
// jQuery scripts
- wp_enqueue_script('jquery', false, array(), false, true);
- wp_enqueue_script('jquery-style', false, array(), false, true);
- wp_enqueue_script('jquery-ui-core', false, array(), false, true);
- wp_enqueue_script('jquery-ui-widget', false, array(), false, true);
- wp_enqueue_script('jquery-ui-dialog', false, array(), false, true);
- wp_enqueue_script('jquery-ui-autocomplete', false, array(), false, true);
+ wp_enqueue_script( 'jquery', false, array(), false, true );
+ wp_enqueue_script( 'jquery-style', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-core', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-widget', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-dialog', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-autocomplete', false, array(), false,
+ true );
// Jquery DatePicker
- wp_enqueue_script('jquery-ui-datepicker');
+ wp_enqueue_script( 'jquery-ui-datepicker' );
$wp_scripts = wp_scripts();
- wp_enqueue_style(
- 'jquery-style',
+ wp_enqueue_style( 'jquery-style',
sprintf(
'//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css',
- $wp_scripts->registered['jquery-ui-core']->ver
- )
- );
-
+ $wp_scripts->registered['jquery-ui-core']->ver ) );
wp_enqueue_media();
// Register any admin.js files in the js directory of any glm members plugin
- reset($this->config['addOns']);
- foreach ($this->config['addOns'] as $a) {
- $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/js/admin.js';
- if (is_file($jsFile)) {
- $jsName = $a['slug'].'-admin-js';
- wp_register_script(
- $jsName,
- GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/js/admin.js',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script($jsName, false, array('jquery'), false, true);
+ reset( $this->config['addOns'] );
+ foreach ( $this->config['addOns'] as $a ) {
+ $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/js/admin.js';
+ if ( is_file( $jsFile ) ) {
+ $jsName = $a['slug'] . '-admin-js';
+ wp_register_script( $jsName,
+ GLM_MEMBERS_WORDPRESS_PLUGIN_URL . '/' . $a['slug'] .
+ '/js/admin.js', false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( $jsName, false, array(
+ 'jquery'
+ ), false, true );
}
}
// Register any admin.css files in the css directory of any glm members plugin
- reset($this->config['addOns']);
- foreach ($this->config['addOns'] as $a) {
- $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/css/admin.css';
-
- if (is_file($cssFile)) {
- $cssName = $a['slug'].'-admin-css';
- wp_register_style(
- $cssName,
- GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/css/admin.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssName);
+ reset( $this->config['addOns'] );
+ foreach ( $this->config['addOns'] as $a ) {
+ $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/css/admin.css';
+
+ if ( is_file( $cssFile ) ) {
+ $cssName = $a['slug'] . '-admin-css';
+ wp_register_style( $cssName,
+ GLM_MEMBERS_WORDPRESS_PLUGIN_URL . '/' . $a['slug'] .
+ '/css/admin.css', false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssName );
}
}
- $cssGridFileOld = GLM_MEMBERS_PLUGIN_PATH.'/css/glm-grid-old.css';
- $cssGridFile = GLM_MEMBERS_PLUGIN_PATH.'/css/glm-grid.css';
+ $cssGridFileOld = GLM_MEMBERS_PLUGIN_PATH . '/css/glm-grid-old.css';
+ $cssGridFile = GLM_MEMBERS_PLUGIN_PATH . '/css/glm-grid.css';
- if (is_file($cssGridFileOld)) {
+ if ( is_file( $cssGridFileOld ) ) {
$cssGridNameOld = 'grid-admin-css-old';
- wp_register_style(
- $cssGridNameOld,
- GLM_MEMBERS_PLUGIN_BASE_URL.'/css/glm-grid-old.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssGridNameOld);
+ wp_register_style( $cssGridNameOld,
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/glm-grid-old.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssGridNameOld );
}
- if (is_file($cssGridFile)) {
+ if ( is_file( $cssGridFile ) ) {
$cssGridName = 'grid-admin-css';
- wp_register_style(
- $cssGridName,
- GLM_MEMBERS_PLUGIN_BASE_URL.'/css/glm-grid.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssGridName);
+ wp_register_style( $cssGridName,
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/glm-grid.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssGridName );
}
// Image Upload scripts and css for Member DB and perhaps other
- wp_register_script(
- 'glm-members-admin-image-upload',
+ wp_register_script( 'glm-members-admin-image-upload',
GLM_MEMBERS_PLUGIN_URL . 'js/imageUpload/imageUpload.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-image-upload', false, array('jquery'), false, true);
- wp_register_style(
- 'glm-members-admin-image-upload-css',
- GLM_MEMBERS_PLUGIN_URL . 'js/imageUpload/imageUpload.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style('glm-members-admin-image-upload-css');
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-image-upload', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_style( 'glm-members-admin-image-upload-css',
+ GLM_MEMBERS_PLUGIN_URL . 'js/imageUpload/imageUpload.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( 'glm-members-admin-image-upload-css' );
// jQuery Multi-Select
- wp_register_style(
- 'glm-members-admin-jquery-select-css',
+ wp_register_style( 'glm-members-admin-jquery-select-css',
GLM_MEMBERS_PLUGIN_URL . 'js/multiselect/multiselect.css',
- 'glm-members-admin-jquery-select',
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style('glm-members-admin-jquery-select-css');
- wp_register_script(
- 'glm-members-admin-jquery-select',
+ 'glm-members-admin-jquery-select', GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( 'glm-members-admin-jquery-select-css' );
+ wp_register_script( 'glm-members-admin-jquery-select',
GLM_MEMBERS_PLUGIN_URL . 'js/multiselect/multiselect.js',
array(
- 'jquery',
- 'jquery-ui-core',
- 'jquery-ui-widget'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-jquery-select', false, array('jquery'), false, true);
+ 'jquery',
+ 'jquery-ui-core',
+ 'jquery-ui-widget'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-jquery-select', false,
+ array(
+ 'jquery'
+ ), false, true );
// Register and enqueue DateTimePicker
- wp_register_script(
- 'glm-members-admin-datetimepicker',
- GLM_MEMBERS_PLUGIN_URL . 'js/datetimepicker/build/jquery.datetimepicker.full.min.js',
+ wp_register_script( 'glm-members-admin-datetimepicker',
+ GLM_MEMBERS_PLUGIN_URL .
+ 'js/datetimepicker/build/jquery.datetimepicker.full.min.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-datetimepicker', false, array('jquery'), false, true);
- wp_register_style(
- 'glm-members-admin-datetimepicker-css',
- GLM_MEMBERS_PLUGIN_URL . 'js/datetimepicker/build/jquery.datetimepicker.min.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style('glm-members-admin-datetimepicker-css');
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-datetimepicker', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_style( 'glm-members-admin-datetimepicker-css',
+ GLM_MEMBERS_PLUGIN_URL .
+ 'js/datetimepicker/build/jquery.datetimepicker.min.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( 'glm-members-admin-datetimepicker-css' );
// Register and enqueue FullCalendar
- wp_register_script(
- 'glm-members-admin-fullcalendar-moment',
+ wp_register_script( 'glm-members-admin-fullcalendar-moment',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/lib/moment.min.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar-moment', false, array('jquery'), false, true);
- wp_register_script(
- 'glm-members-admin-fullcalendar',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar-moment', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_script( 'glm-members-admin-fullcalendar',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/fullcalendar.min.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar');
- wp_register_script(
- 'glm-members-admin-fullcalendar-langall',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar' );
+ wp_register_script( 'glm-members-admin-fullcalendar-langall',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/lang-all.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar-langall', false, array('jquery'), false, true);
- wp_register_style(
- 'glm-members-admin-fullcalendar-css',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar-langall', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_style( 'glm-members-admin-fullcalendar-css',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/fullcalendar.min.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style('glm-members-admin-fullcalendar-css');
+ false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( 'glm-members-admin-fullcalendar-css' );
- wp_register_script(
- 'glm-members-admin-maskedinput',
+ wp_register_script( 'glm-members-admin-maskedinput',
GLM_MEMBERS_PLUGIN_URL . 'js/jquery.maskedinput-1.2.2.js',
-// Consider migrating to new version and retiring 1.2.2
+ // Consider migrating to new version and retiring 1.2.2
// GLM_MEMBERS_PLUGIN_URL . 'js/jquery.mask.min-1.7.7.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-maskedinput');
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-maskedinput' );
}
* @return void
* @access public
*/
- public function configureMenus ()
+ public function configureMenus()
{
// For each add-on, read in their menu additions - These are optional files
- foreach ($this->config['addOns'] as $a) {
- if (is_file(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php')) {
- require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminMenus.php';
+ foreach ( $this->config['addOns'] as $a ) {
+ if ( is_file(
+ GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/adminMenus.php' ) ) {
+ require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/adminMenus.php';
}
- if (is_file(GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php')) {
- require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/adminTabs.php';
+ if ( is_file(
+ GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/adminTabs.php' ) ) {
+ require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/adminTabs.php';
}
}
* @return void
* @access public
*/
- public function glmMembersAdminDashboardWidget ()
+ public function glmMembersAdminDashboardWidget()
{
if ( current_user_can( 'glm_members_widget' ) ) {
- wp_add_dashboard_widget(
- 'glm_members_admin_dashboard_widget',
+ wp_add_dashboard_widget( 'glm_members_admin_dashboard_widget',
'GLM Associate',
- function() {$this->controller('dashboardWidget'); }
- );
+ function ()
+ {
+ $this->controller( 'dashboardWidget' );
+ } );
// Set widget default position to right column
global $wp_meta_boxes;
$glm_dashboard_widget = $wp_meta_boxes['dashboard']['normal']['core']['glm_members_admin_dashboard_widget'];
- unset($wp_meta_boxes['dashboard']['normal']['core']['glm_members_admin_dashboard_widget']);
+ unset(
+ $wp_meta_boxes['dashboard']['normal']['core']['glm_members_admin_dashboard_widget'] );
$wp_meta_boxes['dashboard']['side']['core']['glm_members_admin_dashboard_widget'] = $glm_dashboard_widget;
-
-
}
+
}
/**
*
* Controller parameters
*
- * @param string $menuItem Name of the menu item that is being processed
- * @param string $action Specified Action to take or false
- * @param array $actionData Optional array of data to pass to the selected action
+ * @param string $menuItem Name of the menu item that is being processed
+ * @param string $action Specified Action to take or false
+ * @param array $actionData Optional array of data to pass to the selected action
* @param boolean $returnOutput Optionally tell controller to return the output rather than display it
- * @param boolean $forceAction Optionally tell controller it must run the supplied action
+ * @param boolean $forceAction Optionally tell controller it must run the supplied action
* This last paramter can prevent a submit paramter from overriding the action.
*
* @return void
* @access public
*/
- public function controller( $menuItem, $action = false, $actionData = false, $returnOutput = false, $forceAction = false )
+ public function controller( $menuItem, $action = false, $actionData = false,
+ $returnOutput = false, $forceAction = false)
{
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage()." - Start Admin Controller, Menu = $menuItem, Action = $action",E_USER_NOTICE);
- trigger_error(glmAssociateTimeTracker()." - Start Admin Controller",E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() .
+ " - Start Admin Controller, Menu = $menuItem, Action = $action",
+ E_USER_NOTICE );
+ trigger_error(
+ glmAssociateTimeTracker() . " - Start Admin Controller",
+ E_USER_NOTICE );
}
// Enque admin scripts and css here so that only happens when we're doing something
$this->glmMembersAdminScripts();
+ // Register admin scripts in setup directory of each plugin
+ foreach ( $this->config['addOns'] as $a ) {
+
+ // If the add-on has registerScripStyle.php file
+ $scriptsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/registerAdminScriptStyle.php';
+ if ( is_file( $scriptsFile ) ) {
+ require_once $scriptsFile;
+ }
+ }
+
$errorMsg = '';
// Get the current theme directory to check for modified views
* (see bottom of this script).
*/
$defaultTimeZone = date_default_timezone_get();
- date_default_timezone_set($this->config['settings']['time_zone']);
+ date_default_timezone_set( $this->config['settings']['time_zone'] );
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
// Also turn on SQL error messages
$this->wpdb->show_errors();
// If debug is VERBOSE
- $consts = get_defined_constants(true);
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+ $consts = get_defined_constants( true );
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
// Not doing anything right now
- // Not verbose
+ // Not verbose
} else {
- $ourConsts = array();
- foreach ($consts['user'] as $k => $v) {
- if (strncmp($k, 'GLM_MEMBERS_PLUGIN', 18) == 0) {
+ $ourConsts = array();
+ foreach ( $consts['user'] as $k=>$v ) {
+ if ( strncmp( $k, 'GLM_MEMBERS_PLUGIN', 18 ) == 0 ) {
$ourConsts[$k] = $v;
}
}
}
- if (isset($_FILES)) {
+ if ( isset( $_FILES ) ) {
// Not doing anything right now
}
} else {
*/
// Default action is "index" if an action wasn't specified in the controller call
- if (!$action) {
+ if ( !$action ) {
$action = 'index';
}
* Get any requested "action" from a form submission and modify path/name
* accordingly.
*
- * The 'glm_action' REQUEST parameter used to override the $action supplied to this controller
+ * The 'glm_action' REQUEST parameter used to override the $action supplied to this
+ * controller
* but that behavior has been changed so that it doesn't. Not sure why we did that.
*
*/
- if (!$forceAction && !$actionData && isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
- $a = sanitize_text_field($_REQUEST['glm_action']);
- if ($a != '') {
+ if ( !$forceAction && !$actionData && isset( $_REQUEST['glm_action'] ) &&
+ $_REQUEST['glm_action'] != '' ) {
+ $a = sanitize_text_field( $_REQUEST['glm_action'] );
+ if ( $a != '' ) {
$action = $a;
}
}
* Check Required Pages
*
*/
- foreach ($this->config['addOns'] as $a) {
- if (isset($a['requiredPages'])) {
- $this->createPages($a['requiredPages']);
+ foreach ( $this->config['addOns'] as $a ) {
+ if ( isset( $a['requiredPages'] ) ) {
+ $this->createPages( $a['requiredPages'] );
}
}
// Loop till we have a final action
$loopCheck = 0;
$loopTracking = "<p>Menu: $menuItem, Action = $action</p>";
-// $actionData = false;
+ // $actionData = false;
do {
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
$option = '';
- if (isset($_REQUEST['option'])) {
- $option = ', Option = '.$_REQUEST['option'];
+ if ( isset( $_REQUEST['option'] ) ) {
+ $option = ', Option = ' . $_REQUEST['option'];
}
}
$modelRedirect = false;
// Verify that we have the requested menu item in the valid actions
- if (!isset($this->config['validActions']['adminActions'][$menuItem])) {
+ if ( !isset(
+ $this->config['validActions']['adminActions'][$menuItem] ) ) {
- trigger_error('Error in Admin Controller: Menu Item not included in validActions.php!', E_USER_NOTICE);
+ trigger_error(
+ 'Error in Admin Controller: Menu Item not included in validActions.php!',
+ E_USER_NOTICE );
$modelRedirect = true;
$menuItem = 'error';
$action = 'index';
- $errorMsg .= "<b>Menu not in valid list:</b> ".$menuItem;
+ $errorMsg .= "<b>Menu not in valid list:</b> " . $menuItem;
$loopTracking .= "<p>*** Failed checking for valid menu selection ***</p>";
}
// Verify Menu item and action using array at top of this file
- if (! isset($this->config['validActions']['adminActions'][$menuItem]) ||
- ! isset($this->config['validActions']['adminActions'][$menuItem][$action])) {
+ if ( !isset(
+ $this->config['validActions']['adminActions'][$menuItem] ) ||
+ !isset(
+ $this->config['validActions']['adminActions'][$menuItem][$action] ) ) {
- trigger_error("Error in Admin Controller: Requested Menu Item is invalid! - $menuItem/$action", E_USER_NOTICE);
+ trigger_error(
+ "Error in Admin Controller: Requested Menu Item is invalid! - $menuItem/$action",
+ E_USER_NOTICE );
$menuItem = 'error';
$action = 'badAction';
$loopTracking .= "<p>*** Failed checking for valid menu action ***</p>";
-
}
/*
$plugIn = $this->config['validActions']['adminActions'][$menuItem][$action];
// Build model and path and class names
- $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/admin/$menuItem/$action.php";
+ $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ "$plugIn/models/admin/$menuItem/$action.php";
$className = 'GlmMembersAdmin_' . $menuItem . '_' . $action;
$loopTracking .= "<p>Loop: $loopCheck<br>Model: $modelName<br>Class: $className</p>";
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
- trigger_error("Model: ".$modelName, E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
+ trigger_error( "Model: " . $modelName, E_USER_NOTICE );
}
// Create hook to add page tabs by add-on plugins
$addOnTabs = array();
- $addOnTabs = apply_filters(
- 'glm-member-db-add-tab-for-'.$menuItem,
- $addOnTabs
- );
+ $addOnTabs = apply_filters( 'glm-member-db-add-tab-for-' .
+ $menuItem, $addOnTabs );
// If model file doesn't exist - we have an error
- if (!file_exists($modelName)) {
+ if ( !file_exists( $modelName ) ) {
- trigger_error("Error in Admin Controller: Model file doesn't exist - ".$modelName, E_USER_NOTICE);
+ trigger_error(
+ "Error in Admin Controller: Model file doesn't exist - " .
+ $modelName, E_USER_NOTICE );
$modelRedirect = true;
$menuItem = 'error';
$action = 'index';
- $errorMsg .= "<b>Model doesn't exist:</b> ".$modelName;
+ $errorMsg .= "<b>Model doesn't exist:</b> " . $modelName;
$loopTracking .= "<p>*** Failed checking model file ***</p>";
- // Otherwise, load and run the model
+ // Otherwise, load and run the model
} else {
// Load the model file
- require_once $modelName;
+ require_once $modelName;
// check for an invalid model class name
- if (!class_exists($className)) {
+ if ( !class_exists( $className ) ) {
- trigger_error("Error in Admin Controller: Invalid Model Class Name - ".$className, E_USER_NOTICE);
+ trigger_error(
+ "Error in Admin Controller: Invalid Model Class Name - " .
+ $className, E_USER_NOTICE );
$modelRedirect = true;
$menuItem = 'error';
$action = 'index';
- $errorMsg .= "<b>Model class doesn't exist:</b> ".$className;
+ $errorMsg .= "<b>Model class doesn't exist:</b> " .
+ $className;
$loopTracking .= "<p>*** Failed checking model class name ***</p>";
-
} else {
// Check if this is a re-direct with parameters
$args = false;
- // Pass the menu to in config in case the model needs to know what menu item was used to get to it.
+ // Pass the menu to in config in case the model needs to know what menu item was
+ // used to get to it.
$this->config['menuItem'] = $menuItem;
// Instantiate the model and ask it to perform the work
- $model = new $className($this->wpdb, $this->config);
- $results = $model->modelAction($actionData);
+ $model = new $className( $this->wpdb, $this->config );
+ $results = $model->modelAction( $actionData );
// Check if there's been a model redirect request
- if ($results['modelRedirect']) {
+ if ( $results['modelRedirect'] ) {
// Set the new model action
$action = $results['modelRedirect'];
// Check if there's also a menu item change
- if ($results['menuItemRedirect']) {
+ if ( $results['menuItemRedirect'] ) {
$menuItem = $results['menuItemRedirect'];
}
// Check if there's data to pass to the new model
- if (isset($results['data']) && count($results['data']) > 0) {
+ if ( isset( $results['data'] ) &&
+ count( $results['data'] ) > 0 ) {
$actionData = $results['data'];
}
$modelRedirect = true;
}
- // If there's no view and no data returned, assume it doesn't want a view processd and just return;
- if (!$results['view'] && !$results['data']) {
+ // If there's no view and no data returned, assume it doesn't want a view
+ // processd and just return;
+ if ( !$results['view'] && !$results['data'] ) {
return false;
}
// Get the specified view file path and name
$view = false;
- if (isset($results['view'])) {
+ if ( isset( $results['view'] ) ) {
$view = $results['view'];
}
// If a view file is specified
$badView = false;
- if ($view) {
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
- trigger_error("View: ".$view, E_USER_NOTICE);
+ if ( $view ) {
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
+ trigger_error( "View: " . $view, E_USER_NOTICE );
}
// Get the specified view file - check theme first
$viewPath = "$theme/$plugIn/views";
$viewFile = $view;
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
// Next try the plugin/add-on
- $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";
+ $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ "$plugIn/views";
$viewFile = $view;
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
- trigger_error("Bad or missing view file: $viewPath/$view", E_USER_NOTICE);
+ trigger_error(
+ "Bad or missing view file: $viewPath/$view",
+ E_USER_NOTICE );
// No matching view file found
$errorMsg .= "<b>Bad or missing view file:</b> $viewPath/$view";
$badView = true;
-
}
-
}
-
}
// If we don't have a good view file
- if ($badView) {
+ if ( $badView ) {
- trigger_error("Error in Admin Controller: Requested View file doesn't exist - ".$viewPath.'/'.$viewFile, E_USER_NOTICE);
+ trigger_error(
+ "Error in Admin Controller: Requested View file doesn't exist - " .
+ $viewPath . '/' . $viewFile, E_USER_NOTICE );
$modelRedirect = true;
$menuItem = 'error';
$action = 'index';
- $errorMsg .= "<b>Bad or missing view file:</b> ".$view;
+ $errorMsg .= "<b>Bad or missing view file:</b> " . $view;
$loopTracking .= "<p>*** Failed checking for valid view file ***</p>";
}
-
} // model class exists
}
// This is just a sanity check on this loop to keep it from getting out of control
- if (++$loopCheck > 5) {
+ if ( ++$loopCheck > 5 ) {
- trigger_error('Serious failure looping on model load!', E_USER_NOTICE);
+ trigger_error( 'Serious failure looping on model load!',
+ E_USER_NOTICE );
- die('
+ die(
+ '
<h1>Serious failure looping on model load in "controllers/admin.php".</h1>
<div class="glm-item-container">
<p>Dear User:</p>
<p>The Management</p>
</div>
</p>
- '.$loopTracking
- );
+ ' . $loopTracking );
}
// Loop again if there's a model redirect
-
- } while ($modelRedirect);
+ } while ( $modelRedirect );
/*
* Check model results
$view = $results['view'];
// If there's a general model failure use the error view
- if (! $results['status']) {
+ if ( !$results['status'] ) {
$view = 'admin/error/index.html';
}
// Check for modified settings to save in conf
- if (isset($results['settings'])) {
- foreach ( $results['settings'] as $key => $val ) {
+ if ( isset( $results['settings'] ) ) {
+ foreach ( $results['settings'] as $key=>$val ) {
$this->config['settings'][$key] = $val;
}
}
// Load Smarty Template support
$smarty = new smartyTemplateSupport();
- // Build Admin Page Text using "adminPageText.html". That template should include a pop-up form and display any selected text.
+ // Build Admin Page Text using "adminPageText.html". That template should include a pop-up
+ // form and display any selected text.
$pageTopText = '';
// **** NEED TO GET PAGE TOP TEXT HERE ****
- $smarty->templateAssign( 'glmAdminPageTopText', $pageTopText);
- $output = $smarty->template->fetch('admin/adminPageText.html');
+ $smarty->templateAssign( 'glmAdminPageTopText', $pageTopText );
+ $output = $smarty->template->fetch( 'admin/adminPageText.html' );
// Add standard template parameters
- require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
// Add data from model to Smarty template
- if (is_array($results['data']) && count($results['data']) > 0) {
- foreach ($results['data'] as $k => $d) {
- $smarty->templateAssign($k, $d);
+ if ( is_array( $results['data'] ) && count( $results['data'] ) > 0 ) {
+ foreach ( $results['data'] as $k=>$d ) {
+ $smarty->templateAssign( $k, $d );
}
}
- $smarty->templateAssign ( 'thisAction', $action);
+ $smarty->templateAssign( 'thisAction', $action );
// If there's an error message, add that also
- if ($errorMsg != '') {
- $smarty->templateAssign('errorMsg', $errorMsg);
+ if ( $errorMsg != '' ) {
+ $smarty->templateAssign( 'errorMsg', $errorMsg );
}
// Update the Smarty view path
- $smarty->template->addTemplateDir($viewPath);
+ $smarty->template->addTemplateDir( $viewPath );
// Generate output from model data and view
if ( $returnOutput ) {
- $output = $output.$smarty->template->fetch( $viewFile );
+ $output = $output . $smarty->template->fetch( $viewFile );
} else {
echo $output;
$smarty->template->display( $viewFile );
}
// Restore timezone that was set before our code was called
- date_default_timezone_set($defaultTimeZone);
+ date_default_timezone_set( $defaultTimeZone );
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage().' - End Admin Controller',E_USER_NOTICE);
- trigger_error(glmAssociateTimeTracker().' - End Admin Controller',E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ trigger_error( glmAssociateMemoryUsage() .
+ ' - End Admin Controller', E_USER_NOTICE );
+ trigger_error( glmAssociateTimeTracker() .
+ ' - End Admin Controller', E_USER_NOTICE );
}
- if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
- $smarty->template->display( 'admin/smartyDebug.html');
+ if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
+ $smarty->template->display( 'admin/smartyDebug.html' );
}
if ( $returnOutput ) {
* @release front.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
* @link http://dev.gaslightmedia.com/
*/
+class scriptsRgistry
+{
+ public static $x = array();
+
+}
/*
* This class controls which models are use for front-end functionality
* @access public
*/
public $config;
-
- public function __construct ($wpdb, $config)
+ public function __construct( $wpdb, $config )
{
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage()." - Controller Constructor Start",E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . " - Controller Constructor Start",
+ E_USER_NOTICE );
}
// Save WordPress Database object
$this->config = $config;
// Add any shortcodes from the config 'shortcodes' table
- foreach ( $this->config['shortcodes'] as $key => $val ) {
- add_shortcode($key,
- array(
- $this,
- 'controller'
- )
- );
+ foreach ( $this->config['shortcodes'] as $key=>$val ) {
+ add_shortcode( $key, array(
+ $this,
+ 'controller'
+ ) );
}
/*
* Include the following files in the setup folder of add-ons
*
- * * Misc hooks and filters - frontMisc.php
- * * Map hooks between add-ons - mapHooks.php
+ * * Misc hooks and filters - frontMisc.php
+ * * Map hooks between add-ons - mapHooks.php
*
* Note that filter and hook callback functions must be included in-line as shown below...
*
- * add_filter( 'filter_title', function( $parameter ) {
- * // Function code
- * });
+ * add_filter( 'filter_title', function( $parameter ) {
+ * // Function code
+ * });
*
- * Also note that parameters will be in the context of this class.
+ * Also note that parameters will be in the context of this class.
*
*/
- foreach ($this->config['addOns'] as $a) {
+ foreach ( $this->config['addOns'] as $a ) {
- // If setup/frontHooks.php exists include that now - Can be used for additional filters and hooks
- $hooksFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/setup/frontHooks.php';
- if (is_file($hooksFile)) {
+ // If setup/frontHooks.php exists include that now - Can be used for additional filters
+ // and hooks
+ $hooksFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/frontHooks.php';
+ if ( is_file( $hooksFile ) ) {
require_once $hooksFile;
}
if (is_file($commonFile)) {
require_once $commonFile;
}
-
}
- // Add filters for use anywhere else (apply_filter). Will have to add this to index.php eventually
- add_filter('glmMembersFrontScriptsFilter',array($this,'glmMembersFrontScripts'));
- add_action('glmMembersFrontCSSFilter',array($this,'glmMembersFrontCSS'));
-
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error(glmAssociateMemoryUsage()." - Controller Constructor End",E_USER_NOTICE);
+ // Add filters for use anywhere else (apply_filter). Will have to add this to index.php
+ // eventually
+ add_filter( 'glmMembersFrontScriptsFilter',
+ array(
+ $this,
+ 'glmMembersFrontScripts'
+ ) );
+ add_action( 'glmMembersFrontCSSFilter',
+ array(
+ $this,
+ 'glmMembersFrontCSS'
+ ) );
+
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error(
+ glmAssociateMemoryUsage() . " - Controller Constructor End",
+ E_USER_NOTICE );
}
}
* @return void
* @access public
*/
- public function glmMembersFrontScripts ()
+ public function glmMembersFrontScripts()
{
- wp_enqueue_script('jquery', false, array(), false, true);
- wp_enqueue_script('jquery-style', false, array(), false, true);
- wp_enqueue_script('jquery-ui-core', false, array(), false, true);
- wp_enqueue_script('jquery-ui-dialog', false, array(), false, true);
- wp_enqueue_style('wp-jquery-ui-dialog');
+ wp_enqueue_script( 'jquery', false, array(), false, true );
+ wp_enqueue_script( 'jquery-style', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-core', false, array(), false, true );
+ wp_enqueue_script( 'jquery-ui-dialog', false, array(), false, true );
+ wp_enqueue_style( 'wp-jquery-ui-dialog' );
// Register any front.js files in the js directory of any glm members plugin
- foreach ($this->config['addOns'] as $a) {
- $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/js/front.js';
- if (is_file($jsFile)) {
- $jsName = $a['slug'].'-front-js';
- wp_register_script(
- $jsName,
- GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/js/front.js',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script($jsName, false, array('jquery'), false, true);
+ foreach ( $this->config['addOns'] as $a ) {
+ $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/js/front.js';
+ if ( is_file( $jsFile ) ) {
+ $jsName = $a['slug'] . '-front-js';
+ wp_register_script( $jsName,
+ GLM_MEMBERS_WORDPRESS_PLUGIN_URL . '/' . $a['slug'] .
+ '/js/front.js', false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( $jsName, false, array(
+ 'jquery'
+ ), false, true );
}
}
// Register and enqueue FullCalendar
- wp_register_script(
- 'glm-members-admin-fullcalendar-moment',
+ wp_register_script( 'glm-members-admin-fullcalendar-moment',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/lib/moment.min.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar-moment', false, array('jquery'), false, true);
- wp_register_script(
- 'glm-members-admin-fullcalendar',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar-moment', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_script( 'glm-members-admin-fullcalendar',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/fullcalendar.min.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar');
- wp_register_script(
- 'glm-members-admin-fullcalendar-langall',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar' );
+ wp_register_script( 'glm-members-admin-fullcalendar-langall',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/lang-all.js',
array(
- 'jquery'
- ),
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_script('glm-members-admin-fullcalendar-langall', false, array('jquery'), false, true);
- wp_register_style(
- 'glm-members-admin-fullcalendar-css',
+ 'jquery'
+ ), GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_script( 'glm-members-admin-fullcalendar-langall', false,
+ array(
+ 'jquery'
+ ), false, true );
+ wp_register_style( 'glm-members-admin-fullcalendar-css',
GLM_MEMBERS_PLUGIN_URL . 'js/fullcalendar/fullcalendar.min.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style('glm-members-admin-fullcalendar-css');
+ false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( 'glm-members-admin-fullcalendar-css' );
// enque the script and css for asmselect
- wp_enqueue_script(
- 'asmselect',
- GLM_MEMBERS_PLUGIN_BASE_URL . '/js/jquery.asmselect.js',
- 'jquery',
- '1.0.4a',
- true
- );
- wp_enqueue_style(
- 'asmselect',
- GLM_MEMBERS_PLUGIN_BASE_URL . '/css/jquery.asmselect.css',
- null,
- '1.0.4a'
- );
- }
+ wp_enqueue_script( 'asmselect',
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/js/jquery.asmselect.js', 'jquery',
+ '1.0.4a', true );
+ wp_enqueue_style( 'asmselect',
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/jquery.asmselect.css', null,
+ '1.0.4a' );
- public function glmMembersFrontCSS () {
+ }
+ public function glmMembersFrontCSS()
+ {
// Register any front.css files in the css directory of any glm members plugin
- foreach ($this->config['addOns'] as $a) {
- $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/css/front.css';
-
- if (is_file($cssFile)) {
- $cssName = $a['slug'].'-front-css';
- wp_register_style(
- $cssName,
- GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/css/front.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssName);
+ foreach ( $this->config['addOns'] as $a ) {
+ $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/css/front.css';
+
+ if ( is_file( $cssFile ) ) {
+ $cssName = $a['slug'] . '-front-css';
+ wp_register_style( $cssName,
+ GLM_MEMBERS_WORDPRESS_PLUGIN_URL . '/' . $a['slug'] .
+ '/css/front.css', false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssName );
}
}
- $cssGridFileOld = GLM_MEMBERS_PLUGIN_PATH.'/css/glm-grid-old.css';
- $cssGridFile = GLM_MEMBERS_PLUGIN_PATH.'/css/glm-grid.css';
- $cssGlmaFoundation = GLM_MEMBERS_PLUGIN_PATH.'/css/glma-foundation.min.css';
+ $cssGridFileOld = GLM_MEMBERS_PLUGIN_PATH . '/css/glm-grid-old.css';
+ $cssGridFile = GLM_MEMBERS_PLUGIN_PATH . '/css/glm-grid.css';
+ $cssGlmaFoundation = GLM_MEMBERS_PLUGIN_PATH .
+ '/css/glma-foundation.min.css';
- if (is_file($cssGridFileOld)) {
+ if ( is_file( $cssGridFileOld ) ) {
$cssGridNameOld = 'grid-front-css-old';
- wp_register_style(
- $cssGridNameOld,
- GLM_MEMBERS_PLUGIN_BASE_URL.'/css/glm-grid-old.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssGridNameOld);
+ wp_register_style( $cssGridNameOld,
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/glm-grid-old.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssGridNameOld );
}
- if (is_file($cssGridFile)) {
+ if ( is_file( $cssGridFile ) ) {
$cssGridName = 'grid-front-css';
- wp_register_style(
- $cssGridName,
- GLM_MEMBERS_PLUGIN_BASE_URL.'/css/glm-grid.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssGridName);
+ wp_register_style( $cssGridName,
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/glm-grid.css', false,
+ GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssGridName );
}
- if (is_file($cssGlmaFoundation)) {
+ if ( is_file( $cssGlmaFoundation ) ) {
$cssGlmaFoundationName = 'glma-foundation-css';
- wp_register_style(
- $cssGlmaFoundationName,
- GLM_MEMBERS_PLUGIN_BASE_URL.'/css/glma-foundation.min.css',
- false,
- GLM_MEMBERS_PLUGIN_VERSION
- );
- wp_enqueue_style($cssGlmaFoundationName);
+ wp_register_style( $cssGlmaFoundationName,
+ GLM_MEMBERS_PLUGIN_BASE_URL . '/css/glma-foundation.min.css',
+ false, GLM_MEMBERS_PLUGIN_VERSION );
+ wp_enqueue_style( $cssGlmaFoundationName );
}
+
}
/**
* @return void
* @access public
*/
- public function controller ($atts, $content = null, $shortcode)
+ public function controller( $atts, $content = null, $shortcode )
{
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG ) {
// Save current error reporting level and add E_NOTICE
$oldErrorLogSetting = error_reporting();
- error_reporting(E_ALL);
+ error_reporting( E_ALL );
// Setup for reports at end of controller
$controllerShortcode = $shortcode;
- $controllerStartTime = microtime(true);
+ $controllerStartTime = microtime( true );
// Report current memory
- trigger_error(glmAssociateMemoryUsage()." - START Shortcode: $controllerShortcode",E_USER_NOTICE);
-
+ trigger_error(
+ glmAssociateMemoryUsage() .
+ " - START Shortcode: $controllerShortcode", E_USER_NOTICE );
}
// Start with no cache_code - This prevents caching for subordinate controller hits
// Enqueue all css here so that only happens when we're doing something
$this->glmMembersFrontCSS();
+ // Register front scripts in setup directory of each plugin
+ foreach ( $this->config['addOns'] as $a ) {
+
+ // If the add-on has registerScripStyle.php file
+ $scriptsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . $a['slug'] .
+ '/setup/registerFrontScriptStyle.php';
+ if ( is_file( $scriptsFile ) ) {
+ require_once $scriptsFile;
+ }
+ }
+
/*
* Shortcode Caching
*
* This feature saves all output from a shortcode into a single entry in the cache table.
*
- * Caching is enabled/disabled on a shortcode by shortcode basis by setting the cacheControl array
- * parameters in the shortcode definition array in "setup/shortcdes.php" for the related add-on.
+ * Caching is enabled/disabled on a shortcode by shortcode basis by setting the cacheControl
+ * array
+ * parameters in the shortcode definition array in "setup/shortcdes.php" for the related
+ * add-on.
*
- * The glmClearShortcodeCache() function is used to clear all shortcode caching. This should normally
+ * The glmClearShortcodeCache() function is used to clear all shortcode caching. This should
+ * normally
* be used when add, update, delete actions occur on information that could be cached.
*/
// If cache control not active, this must be the top-level page content request
- if (!$GLOBALS['cache_control']['active']) {
-
+ if ( !$GLOBALS['cache_control']['active'] ) {
// Check shortcode for cache configuration
$scCacheControl = false;
- foreach ($this->config['addOns'] as $addon) {
- foreach ( $addon['shortcodes'] as $key => $val ) {
- if ($key == $shortcode && isset($val['cacheControl'])) {
+ foreach ( $this->config['addOns'] as $addon ) {
+ foreach ( $addon['shortcodes'] as $key=>$val ) {
+ if ( $key == $shortcode && isset( $val['cacheControl'] ) ) {
$scCacheControl = $val['cacheControl'];
}
}
}
// If cache control is enabled for this shortcode
- if ($scCacheControl && $scCacheControl['active']) {
+ if ( $scCacheControl && $scCacheControl['active'] ) {
// Create cache_code for this request
- $cache_code = md5(GLM_MEMBERS_SITE_BASE_URL.$_SERVER['REQUEST_URI'].print_r($atts,1).print_r($shortcode,1).print_r($_REQUEST,1));
+ $cache_code = md5(
+ GLM_MEMBERS_SITE_BASE_URL . $_SERVER['REQUEST_URI'] .
+ print_r( $atts, 1 ) . print_r( $shortcode, 1 ) .
+ print_r( $_REQUEST, 1 ) );
// Remove all old cache entries from the database
- $sql = "DELETE from ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cache WHERE DATE_ADD(created, INTERVAL ".$scCacheControl['cacheTime'].") < NOW();";
- $this->wpdb->query($sql);
+ $sql = "DELETE from " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+ "cache WHERE DATE_ADD(created, INTERVAL " .
+ $scCacheControl['cacheTime'] . ") < NOW();";
+ $this->wpdb->query( $sql );
// Check if this request is currently cached
- $sql = "SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cache WHERE cache_code = '$cache_code';";
- $cached = $this->wpdb->get_results($sql, ARRAY_A);
- if (count($cached) == 1) {
-
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- trigger_error("Using Cached Result: cache code = $cache_code", E_USER_NOTICE);
+ $sql = "SELECT * FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+ "cache WHERE cache_code = '$cache_code';";
+ $cached = $this->wpdb->get_results( $sql, ARRAY_A );
+ if ( count( $cached ) == 1 ) {
+
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG ) {
+ trigger_error(
+ "Using Cached Result: cache code = $cache_code",
+ E_USER_NOTICE );
}
// Currently cached - Return cached content
return $cached[0]['html'];
-
}
// Setup cache control array for this request
);
$cache_this_request = true;
-
}
}
* (see bottom of this script).
*/
$defaultTimeZone = date_default_timezone_get();
- date_default_timezone_set($this->config['settings']['time_zone']);
+ date_default_timezone_set( $this->config['settings']['time_zone'] );
$controlError = false;
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
// Also turn on SQL error messages
$this->wpdb->show_errors();
}
// Check if the specified shortcode is valid one supplied by this plugin or an add-on
$shortcodeData = false;
$viewPath = false;
- if (isset($this->config['shortcodes'][$shortcode])) {
+ if ( isset( $this->config['shortcodes'][$shortcode] ) ) {
// Get information on the selected shortcode and set the view path
$shortcodeData = $this->config['shortcodes'][$shortcode];
- $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$shortcodeData['plugin'].'/views';
+ $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ $shortcodeData['plugin'] . '/views';
- // If a database table is specified then get defaults from there - otherwise they're already in the attributes array
- if (isset($shortcodeData['table']) && $shortcodeData['table'] != false) {
+ // If a database table is specified then get defaults from there - otherwise they're
+ // already in the attributes array
+ if ( isset( $shortcodeData['table'] ) &&
+ $shortcodeData['table'] != false ) {
// Get the default attribute values
- $defaults = $this->wpdb->get_row("SELECT * FROM ".$shortcodeData['table']." WHERE id = 1;", ARRAY_A);
- if ($defaults) {
+ $defaults = $this->wpdb->get_row(
+ "SELECT * FROM " . $shortcodeData['table'] . " WHERE id = 1;",
+ ARRAY_A );
+ if ( $defaults ) {
- foreach ( $shortcodeData['attributes'] as $key => $val ) {
- if (isset($defaults[$key]) && $val != false) {
+ foreach ( $shortcodeData['attributes'] as $key=>$val ) {
+ if ( isset( $defaults[$key] ) && $val != false ) {
$shortcodeData['attributes'][$key] = $defaults[$val];
}
}
-
} else {
$controlError = true;
}
$menuItem = $shortcodeData['menu'];
$action = $shortcodeData['action'];
- /* Get any requested "action" from a form submission - Overrides short-code default action
+ /*
+ * Get any requested "action" from a form submission - Overrides short-code default
+ * action
*
* This has been commented out because it does not appear to be used
* and was causing the wrong model to be used after a category-based
* search to a page with more than one model..
*/
/*
- if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
- $a = sanitize_text_field($_REQUEST['glm_action']);
- if ($a != '') {
- $action = $a;
- }
- }
+ * if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
+ * $a = sanitize_text_field($_REQUEST['glm_action']);
+ * if ($a != '') {
+ * $action = $a;
+ * }
+ * }
*/
// Set the default attributes and create a filter to update them
$actionData = array(
- 'request' => shortcode_atts(
- $shortcodeData['attributes'],
- $atts,
- $shortcode
- )
+ 'request' => shortcode_atts( $shortcodeData['attributes'],
+ $atts, $shortcode )
);
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error("Executing Shortcode: $shortcode", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error( "Executing Shortcode: $shortcode", E_USER_NOTICE );
}
-
} else {
$controlError = true;
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- trigger_error("Shortcode Not Valid: $shortcode", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG ) {
+ trigger_error( "Shortcode Not Valid: $shortcode", E_USER_NOTICE );
}
-
}
// If there's been no error so far, try to process the supplied action
- if(!$controlError) {
+ if ( !$controlError ) {
/*
* Processing loop - Loop till we have a final action
do {
// If the menu item is "error" reset the view path
- if ($menuItem == 'error') {
+ if ( $menuItem == 'error' ) {
$viewPath = GLM_MEMBERS_PLUGIN_PATH . '/views';
}
// Verify that we have the requested menu item in the valid actions
- if (! isset($this->config['validActions']['frontActions'][$menuItem])) {
+ if ( !isset(
+ $this->config['validActions']['frontActions'][$menuItem] ) ) {
$controlError = true;
}
// Verify Menu item and action as valid action
- if (! isset($this->config['validActions']['frontActions']) ||
- ! isset($action,
- $this->config['validActions']['frontActions'][$menuItem])) {
+ if ( !isset( $this->config['validActions']['frontActions'] ) ||
+ !isset( $action,
+ $this->config['validActions']['frontActions'][$menuItem] ) ) {
$controlError = true;
}
*/
// Get name of plugin where model and view are located - and set the view path
- if (isset($this->config['validActions']['frontActions'][$menuItem][$action])) {
+ if ( isset(
+ $this->config['validActions']['frontActions'][$menuItem][$action] ) ) {
$plugIn = $this->config['validActions']['frontActions'][$menuItem][$action];
} else {
- trigger_error("Front Controller: Invalid Action - menu = $menuItem, action = $action", E_USER_NOTICE);
+ trigger_error(
+ "Front Controller: Invalid Action - menu = $menuItem, action = $action",
+ E_USER_NOTICE );
}
// Build model and path and class names
- $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/front/$menuItem/$action.php";
+ $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ "$plugIn/models/front/$menuItem/$action.php";
$className = 'GlmMembersFront_' . $menuItem . '_' . $action;
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error("Model: $modelName", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error( "Model: $modelName", E_USER_NOTICE );
}
// If model file doesn't exist - we have an error
- if (!file_exists($modelName)) {
+ if ( !file_exists( $modelName ) ) {
$controlError = true;
// Otherwise, load and run the model
} else {
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error("Front Controller: Loading - Model = $modelName, Action = $action, Class = $className", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error(
+ "Front Controller: Loading - Model = $modelName, Action = $action, Class = $className",
+ E_USER_NOTICE );
}
// Load the model file, if it hasn't already
- if (!class_exists($className)) {
+ if ( !class_exists( $className ) ) {
require_once $modelName;
}
// check for an invalid model class name
- if (! class_exists($className)) {
+ if ( !class_exists( $className ) ) {
$controlError = true;
-
} else {
// Check if this is a re-direct with parameters
$args = false;
// Instantiate the model and ask it to perform the work
- $model = new $className($this->wpdb, $this->config);
- $results = $model->modelAction($actionData);
+ $model = new $className( $this->wpdb, $this->config );
+ $results = $model->modelAction( $actionData );
// Check if there's been a model redirect request
- if ($results['modelRedirect']) {
+ if ( $results['modelRedirect'] ) {
// Set the new model action
$action = $results['modelRedirect'];
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error("Model Redirect: ".$results['modelRedirect'], E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error(
+ "Model Redirect: " .
+ $results['modelRedirect'], E_USER_NOTICE );
}
// Check if there's also a menu item change
- if ( isset($results['menuItemRedirect']) && $results['menuItemRedirect']) {
+ if ( isset( $results['menuItemRedirect'] ) &&
+ $results['menuItemRedirect'] ) {
$menuItem = $results['menuItemRedirect'];
}
// Check if there's data to pass to the new model
- if (isset($results['data']) &&
- count($results['data']) > 0) {
+ if ( isset( $results['data'] ) &&
+ count( $results['data'] ) > 0 ) {
$actionData = $results['data'];
}
// Get the specified view file path and name
$view = false;
- if (isset($results['view'])) {
+ if ( isset( $results['view'] ) ) {
$view = $results['view'];
}
// If a view file is specified
- if ($view) {
+ if ( $view ) {
// Get the specified view file - check theme first
- $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR."/$plugIn/views";
- $viewPath2 = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views"; // Save default
+ $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR .
+ "/$plugIn/views";
+ $viewPath2 = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ "$plugIn/views"; // Save default
$viewFile = $view;
- // If the view is not found in the theme, fall back to views in the plugin
+ // If the view is not found in the theme, fall back to views in the
+ // plugin
$inTheme = ' (In Theme)';
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
// Next try the plugin/add-on
- $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views";
+ $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ "$plugIn/views";
$viewFile = $view;
- if (!is_file($viewPath.'/'.$viewFile)) {
+ if ( !is_file( $viewPath . '/' . $viewFile ) ) {
// No matching view file found
$controlError = true;
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- trigger_error("Bad or missing view file: $viewPath/$viewFile", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG ) {
+ trigger_error(
+ "Bad or missing view file: $viewPath/$viewFile",
+ E_USER_NOTICE );
}
-
}
$inTheme = '';
}
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) {
- trigger_error("View$inTheme: $viewPath", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE ) {
+ trigger_error( "View$inTheme: $viewPath",
+ E_USER_NOTICE );
}
-
}
-
} // model class exists
}
// This is just a sanity check on this loop to keep it from getting out of control
- if (++$loopCheck > 10) {
- die('<h1>Serious failure looping on model load in "controllers/front.php".</h1>');
+ if ( ++$loopCheck > 10 ) {
+ die(
+ '<h1>Serious failure looping on model load in "controllers/front.php".</h1>' );
}
// Loop again if there's a model redirect
- } while ($modelRedirect);
+ } while ( $modelRedirect );
/*
* Check model results
// Get suggested view
$view = $results['view'];
// Check for modified settings to save in conf
- if (isset($results['settings'])) {
- foreach ( $results['settings'] as $key => $val ) {
+ if ( isset( $results['settings'] ) ) {
+ foreach ( $results['settings'] as $key=>$val ) {
$this->config['settings'][$key] = $val;
}
}
-
} // if errorMsg
// If there was a controller error - show error page
- if ($controlError != '' && isset($_SERVER['HTTP_REFERER'])) {
- require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/models/front/error/index.php';
- $model = new GlmMembersFront_error_index($this->wpdb, $this->config);
- $results = $model->modelAction($actionData);
+ if ( $controlError != '' && isset( $_SERVER['HTTP_REFERER'] ) ) {
+ require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH .
+ GLM_MEMBERS_PLUGIN_SLUG . '/models/front/error/index.php';
+ $model = new GlmMembersFront_error_index( $this->wpdb, $this->config );
+ $results = $model->modelAction( $actionData );
}
/*
$smarty = new smartyTemplateSupport();
// Add standard parameters
- require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
// Add data from model to Smarty template
- if (is_array($results['data']) && count($results['data']) > 0) {
- foreach ($results['data'] as $k => $d) {
- $smarty->templateAssign($k, $d);
+ if ( is_array( $results['data'] ) && count( $results['data'] ) > 0 ) {
+ foreach ( $results['data'] as $k=>$d ) {
+ $smarty->templateAssign( $k, $d );
}
}
// Update the Smarty view path
- $smarty->template->setTemplateDir($viewPath);
+ $smarty->template->setTemplateDir( $viewPath );
// If the view path doesn't match the default, add the default (using theme view)
- if ($viewPath2 != $viewPath) {
- $smarty->template->addTemplateDir($viewPath2);
+ if ( $viewPath2 != $viewPath ) {
+ $smarty->template->addTemplateDir( $viewPath2 );
}
// Generate output from model data and view
- $out = $smarty->template->fetch($viewFile);
+ $out = $smarty->template->fetch( $viewFile );
// Restore timezone that was set before our code was called
- date_default_timezone_set($defaultTimeZone);
-
+ date_default_timezone_set( $defaultTimeZone );
// If we have a cache code, then this is a top-level caching request
- if ($cache_code) {
+ if ( $cache_code ) {
// Cache this request page content
- $sql = $this->wpdb->prepare("INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cache (shortcode, cache_code, created, html) VALUES (%s, %s, now(), %s);", $shortcode, $cache_code, $out);
- $this->wpdb->query($sql);
+ $sql = $this->wpdb->prepare(
+ "INSERT INTO " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+ "cache (shortcode, cache_code, created, html) VALUES (%s, %s, now(), %s);",
+ $shortcode, $cache_code, $out );
+ $this->wpdb->query( $sql );
// Mark cache control as complete
$GLOBALS['cache_control']['complete'] = true;
-
}
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- trigger_error(glmAssociateMemoryUsage()." - END Shortcode: $controllerShortcode",E_USER_NOTICE);
- $controllerTime = round(microtime(true) - $controllerStartTime, 6);
- trigger_error($controllerTime." seconds - Shortcode: $controllerShortcode, Model class: $className ---", E_USER_NOTICE);
+ if ( GLM_MEMBERS_PLUGIN_FRONT_DEBUG ) {
+ trigger_error(
+ glmAssociateMemoryUsage() .
+ " - END Shortcode: $controllerShortcode", E_USER_NOTICE );
+ $controllerTime = round( microtime( true ) - $controllerStartTime,
+ 6 );
+ trigger_error(
+ $controllerTime .
+ " seconds - Shortcode: $controllerShortcode, Model class: $className ---",
+ E_USER_NOTICE );
// restore error reporting levels
- error_reporting($oldErrorLogSetting);
+ error_reporting( $oldErrorLogSetting );
}
return $out;
}
+
}
// Load Smarty Template Support
require_once GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php';
+// Load Script and Style Registry
+require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/scriptRegistry.php';
+
// Check all database tables for all registered add-ons, allow install/update, and add various items
if (glmCheckDatabase('install')) {
$config = array_replace($config, $addOnIni);
}
+
}
}
}
+/*
+ * Enqueue all scripts and styles registered with glmScriptRegistry
+ */
+function glmEnqueueScripts() {
+ glmScriptRegistry::enqueue();
+}
+add_action('wp_footer', 'glmEnqueueScripts');
+
/*
* Display any notices?
*/
--- /dev/null
+<?php
+/**
+ * registerAdminScriptStyle.php
+ *
+ * PHP version 5.2
+ *
+ * @category Setup
+ * @package Script and Style Registration
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @copyright 2019 Gaslight Media
+ * @license Gaslight Media
+ * @version SVN: $Id$
+ * @link <>
+ */
+
+/**
+ * This file registers scripts and styles with the glmScriptRegistry.
+ *
+ * Scripts and Styles are added to the registry to ensure consistancy and avoid duplication.
+ * This process only lists them in the registry. A further step of calling the enqueue()
+ * method in the running model is required to have the needed scripts and styles passed
+ * to WordPress to have them enqueued. The expection to that is when including an "enqueue"
+ * parameter below that indicates that the scirpt should always be enqueued.
+ *
+ * The parameters below are what can be included. For more information on these parameters see
+ * classes/sciptRegistry.php in the main plugin. When these are loaded a check will be made to
+ * make sure there's no duplicate 'handle' or 'src' strings. The exception for 'handle' is that
+ * it may be the same for a matching script and style (the plugin slug and type prefix the
+ * 'handle' provided below to make them actually unique).
+ *
+ * int type Required type enumerated (see glmScriptType above)
+ * string handle Required handle (name) for this script (no spaces or punctuation)
+ * Handles must be unique for a particular type
+ * A matching script and style may have the same handle
+ * string src Required source URL of script
+ * array deps Optional array of handles for scripts this script depends on
+ * boolean in_footer Optional flag for enqueue before </body> tag
+ * string media Optional media types for styles (i.e. 'all', 'print', 'screen'...)
+ * array attrs Optional tag attribute name/value pairs to be included in tag
+ * string plugin Required plugin slug
+ * string version Required plugin version for cache-busting
+ * boolean enqueue Optional flag, if true always enqueue this
+ *
+ * Please identify the file in the comment area using the URL or application.
+ *
+ * NOTE: The $config array is available in the context of this file. You need to refer
+ * to a config item in a way similar to this...
+ *
+ * $config['settings']['google_maps_api_key']
+ *
+ * Example - Please add multi-line comment above each with script src for reference
+ *
+ * glmScriptRegistry::add(
+ * [
+ * 'type' => glmScriptType::Script,
+ * 'handle' => 'RegApp',
+ * 'src' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js/frontRegApp.js',
+ * 'deps' => array(
+ * 'jquery',
+ * 'backbone',
+ * 'underscore'
+ * ),
+ * 'in_footer' => true,
+ * 'attrs' => array(
+ * 'integrity' => 'sha512-tAGcCfR4Sc5ZP5ZoVz0quoZDYX5aCtEm/eu1KhSLj2c9eFrylXZknQYmxUssFaVJKvvc0dJQixhGjG2yXWiV9Q==',
+ * 'crossorigin' => ''
+ * ),
+ * 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ * 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ * ] );
+ *
+ * NOTE: DO NOT PLACE ANY SCRIPT OR STYLE FILE TAGS INTO VIEW. SELECT THEM IN THE MODEL
+ * USING THIS REGISTRY ONLY.
+ */
+
--- /dev/null
+<?php
+/**
+ * registerFrontScriptStyle.php
+ *
+ * PHP version 5.2
+ *
+ * @category Setup
+ * @package Script and Style Registration
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @copyright 2019 Gaslight Media
+ * @license Gaslight Media
+ * @version SVN: $Id$
+ * @link <>
+ */
+
+/**
+ * This file registers scripts and styles with the glmScriptRegistry.
+ *
+ * Scripts and Styles are added to the registry to ensure consistancy and avoid duplication.
+ * This process only lists them in the registry. A further step of calling the enqueue()
+ * method in the running model is required to have the needed scripts and styles passed
+ * to WordPress to have them enqueued. The expection to that is when including an "enqueue"
+ * parameter below that indicates that the scirpt should always be enqueued.
+ *
+ * The parameters below are what can be included. For more information on these parameters see
+ * classes/sciptRegistry.php in the main plugin. When these are loaded a check will be made to
+ * make sure there's no duplicate 'handle' or 'src' strings. The exception for 'handle' is that
+ * it may be the same for a matching script and style (the plugin slug and type prefix the
+ * 'handle' provided below to make them actually unique).
+ *
+ * int type Required type enumerated (see glmScriptType above)
+ * string handle Required handle (name) for this script (no spaces or punctuation)
+ * Handles must be unique for a particular type
+ * A matching script and style may have the same handle
+ * string src Required source URL of script
+ * array deps Optional array of handles for scripts this script depends on
+ * boolean in_footer Optional flag for enqueue before </body> tag
+ * string media Optional media types for styles (i.e. 'all', 'print', 'screen'...)
+ * array attrs Optional tag attribute name/value pairs to be included in tag
+ * string plugin Required plugin slug
+ * string version Required plugin version for cache-busting
+ * boolean enqueue Optional flag, if true always enqueue this
+ *
+ * Please identify the file in the comment area using the URL or application.
+ *
+ * NOTE: The $config array is available in the context of this file. You need to refer
+ * to a config item in a way similar to this...
+ *
+ * $config['settings']['google_maps_api_key']
+ *
+ * Example - Please add multi-line comment above each with script src for reference
+ *
+ * glmScriptRegistry::add(
+ * [
+ * 'type' => glmScriptType::Script,
+ * 'handle' => 'RegApp',
+ * 'src' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js/frontRegApp.js',
+ * 'deps' => array(
+ * 'jquery',
+ * 'backbone',
+ * 'underscore'
+ * ),
+ * 'in_footer' => true,
+ * 'attrs' => array(
+ * 'integrity' => 'sha512-tAGcCfR4Sc5ZP5ZoVz0quoZDYX5aCtEm/eu1KhSLj2c9eFrylXZknQYmxUssFaVJKvvc0dJQixhGjG2yXWiV9Q==',
+ * 'crossorigin' => ''
+ * ),
+ * 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ * 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ * ] );
+ *
+ * NOTE: DO NOT PLACE ANY SCRIPT OR STYLE FILE TAGS INTO VIEW. SELECT THEM IN THE MODEL
+ * USING THIS REGISTRY ONLY.
+ */
+
+/*
+ * https://unpkg.com/leaflet@1.3.3/dist/leaflet.css
+ */
+glmScriptRegistry::add(
+ [
+ 'type' => glmScriptType::Style,
+ 'handle' => 'Leaflet',
+ 'src' => 'https://unpkg.com/leaflet@1.3.3/dist/leaflet.css',
+ 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ ] );
+
+/*
+ * https://unpkg.com/leaflet@1.3.3/dist/leaflet.js
+ */
+glmScriptRegistry::add(
+ [
+ 'type' => glmScriptType::Script,
+ 'handle' => 'Leaflet',
+ 'src' => 'https://unpkg.com/leaflet@1.3.3/dist/leaflet.js',
+ 'in_footer' => true,
+ 'attrs' => array(
+ 'integrity' => 'sha512-tAGcCfR4Sc5ZP5ZoVz0quoZDYX5aCtEm/eu1KhSLj2c9eFrylXZknQYmxUssFaVJKvvc0dJQixhGjG2yXWiV9Q==',
+ 'crossorigin' => ''
+ ),
+ 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ ] );
+
+/*
+ * {registrations}/js/Leaflet.loading/src/Control.Loading.css
+ * NOTE - This file is actually in glm-member-db plugin. Need to move this at some point ****
+ */
+glmScriptRegistry::add(
+ [
+ 'type' => glmScriptType::Style,
+ 'handle' => 'LeafletControlLoading',
+ 'src' => GLM_MEMBERS_PLUGIN_URL . 'js/Leaflet.loading/src/Control.Loading.css',
+ 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ ] );
+
+/*
+ * GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL/js/Leaflet.loading/src/Control.Loading.js
+ * NOTE - This file is actually in glm-member-db plugin. Need to move this at some point ****
+ */
+glmScriptRegistry::add(
+ [
+ 'type' => glmScriptType::Script,
+ 'handle' => 'LeafletControlLoading',
+ 'src' => GLM_MEMBERS_PLUGIN_URL . 'js/Leaflet.loading/src/Control.Loading.js',
+ 'in_footer' => true,
+ 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ ] );
+
+/*
+ * Google Maps API
+ */
+glmScriptRegistry::add(
+ [
+ 'type' => glmScriptType::Script,
+ 'handle' => 'GoogleMapsAPI',
+ 'src' => 'https://maps.googleapis.com/maps/api/js?sensor=true&key=' .
+ $this->config['settings']['google_maps_api_key'],
+ 'in_footer' => true,
+ 'plugin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+ 'version' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION
+ ] );
+