From 72477b2c0f28fedcc29971641af7cadeedbfa0e6 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 12 Feb 2016 14:34:21 -0500 Subject: [PATCH] Moved main php file to index.php for convenience --- glm-member-db-sample.php | 230 -------------------------------------- index.php | 231 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 229 insertions(+), 232 deletions(-) delete mode 100644 glm-member-db-sample.php diff --git a/glm-member-db-sample.php b/glm-member-db-sample.php deleted file mode 100644 index c182f64..0000000 --- a/glm-member-db-sample.php +++ /dev/null @@ -1,230 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.1.1 - */ - -/* - * Plugin and Database Versions - * - * Note that the database version matches the version of the last - * plugin version where there was a change in the database. - * - * Updates to checkDatabase() in glmPluginSupport.php must be - * made together with the DB_VERSION below. ONLY bump the DB - * version when there's a change in the database!! Use the - * version nunmber of that release for the DB version. - * - * We check the plugin version stored in the WordPress option below - * so that we're sure the other add-ons see an up to date - * version from this plugin. - */ -define('GLM_MEMBERS_SAMPLE_PLUGIN_VERSION', '0.0.5'); -// define('GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION', '0.0.1'); - -// This is the minimum version of the GLM Members DB plugin require for this plugin. -define('GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.57'); - -// Check if plugin version is not current in WordPress option and if needed updated it -if (GLM_MEMBERS_SAMPLE_PLUGIN_VERSION != get_option('glmMembersDatabaseSamplePluginVersion')) { - update_option('glmMembersDatabaseSamplePluginVersion', GLM_MEMBERS_SAMPLE_PLUGIN_VERSION); -} - -/* - * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -// Check that we're being called by WordPress. -if (!defined('ABSPATH')) { - die("Please do not call this code directly!"); -} - -/* -* Some initial setup and tests -*/ - -$startupNotices = ''; - -// Get standard defined parameters -require_once('defines.php'); - -// Required to be able to get user capabilities when being called as a filter from the main plugin -require_once(ABSPATH . 'wp-includes/pluggable.php'); - -/* - * Do some checks to make sure the main GLM Member DB is active and of a recceint enough version - */ - -// Function to generate message regarding main GLM Member DB plugin not installed and active -function glmMembersSamplePluginRequired() { - echo ' -
-

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

-

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check installation, activation, and version of main Member DB plugin - */ -include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); -$plugin_name = 'glm-member-db/glm-member-db.php'; -$is_active = is_plugin_active($plugin_name); - -// If it's not active, then warn user and deactivate this add-on plugin -if ($is_active != '1') { - add_action( 'admin_notices', 'glmMembersSamplePluginRequired' ); - deactivate_plugins('/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'.php'); -} - -// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on -function glmMembersPluginSampleMinVerRequired() { - echo ' -
-

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than ' - .GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!
- '.GLM_MEMBERS_SAMPLE_MIN_VERSION_NOTE.'

-

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' plugin has been de-activated.

-
- '; -} - -/* - * Check for Minimum DB version for main Member DB - */ -$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion'); -if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { - define('GLM_MEMBERS_SAMPLE_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Sample Requires: ".GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION); - add_action( 'admin_notices', 'glmMembersPluginSampleMinVerRequired'); - deactivate_plugins('/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'.php'); -} - -/* - * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded. - */ -require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/validActions.php'); -require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/shortcodes.php'); -$havePluginDatabase = false; -if (is_file(GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) { - require_once(GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); - $havePluginDatabase = true; -} - -// Load Sample Management Settings data -/* None - Need to figure out a smooth way to do this. -$sampleManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); -unset($sampleManagementSettings['id']); -*/ - -function glmMembersRegisterSample($addOns) { - - // Add this add-on to the add-ons array - $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG] = array( - 'dir' => GLM_MEMBERS_SAMPLE_PLUGIN_PATH, - 'name' => GLM_MEMBERS_SAMPLE_PLUGIN_NAME, - 'short_name' => GLM_MEMBERS_SAMPLE_PLUGIN_SHORT_NAME, - 'slug' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, - 'actions' => $GLOBALS['glmMembersSampleAddOnValidActions'], - 'config' => array( - ), - 'shortcodes' => $GLOBALS['glmMembersSampleShortcodes'], - 'shortcodesDescription' => $GLOBALS['glmMembersSampleShortcodesDescription'] - ); - - // If we have database tables for this plugin/addon, provide that data also - if ($GLOBALS['havePluginDatabase']) { - $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG]['database'] = array( - 'dbPrefix' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX, - 'dbCurrentVersion' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION, - 'dbActiveVersionOption' => GLM_MEMBERS_SAMPLE_PLUGIN_ACTIVE_DB_OPTION, - 'dbScriptPath' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS, - 'dbVersions' => $GLOBALS['glmMembersSampleDbVersions'] - ); - } else { - $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG]['database'] = false; - } - - // Return the array with our data added - return $addOns; -} -add_filter('glm-member-db-register-addon','glmMembersRegisterSample', 10, 1); - - /* - * - * Activate and Deactivate hooks - * - */ - - // Activate - function glmMembersSamplePluginActivate () - { - global $wpdb, $config; - require_once (GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/activate.php'); - new glmMembersSamplePluginActivate($wpdb, $config); - } - register_activation_hook(__FILE__, 'glmMembersSamplePluginActivate'); - - // Deactivate - function glmMembersSamplePluginDeactivate () - { - global $wpdb, $config; - require_once (GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/deactivate.php'); - $x = new glmMembersSamplePluginDeactivate($wpdb, $config); - return false; - } - register_deactivation_hook(__FILE__, 'glmMembersSamplePluginDeactivate'); - -/* - * Hooks for testing capabilities provided by this add-on - */ -require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/permissions.php'); - diff --git a/index.php b/index.php index 4e6c07c..fa60ac7 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,230 @@ \ No newline at end of file +/** + * Plugin Name: GLM Members Database Sample + * Plugin URI: http://www.gaslightmedia.com/ + * Description: Gaslight Media Members Database. + * Version: 0.0.6 + * Author: Chuck Scott + * Author URI: http://www.gaslightmedia.com/ + * License: GPL2 + */ + +/********************************************************************** + * NOTE: THIS IS A SAMPLE FILE - DO NOT USE UNMODIFIED + * + * Please change all references to sample, Sample, or SAMPLE to a name + * appropriate for your new Add-On. + * + * This is the main file for this add-on. It is the file called by + * WordPress to run aspects of this add-on. + * + * NOTE: Versions in this file must be reset as appropriate when + * creating a new add-on. Be sure to preserve the versions listed + * for "...MIN_MEMBERS_REQUIRED_VERSION". + * + * Remove this message before using this file in production! + **********************************************************************/ + +/** + * Gaslight Media Members Database Sample Add-On + * Index + * + * PHP version 5.5 + * + * @category glmWordPressPluginChild + * @package glmMembersDatabaseSampleAddOn + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 1.1.1 + */ + +/* + * Plugin and Database Versions + * + * Note that the database version matches the version of the last + * plugin version where there was a change in the database. + * + * Updates to checkDatabase() in glmPluginSupport.php must be + * made together with the DB_VERSION below. ONLY bump the DB + * version when there's a change in the database!! Use the + * version nunmber of that release for the DB version. + * + * We check the plugin version stored in the WordPress option below + * so that we're sure the other add-ons see an up to date + * version from this plugin. + */ +define('GLM_MEMBERS_SAMPLE_PLUGIN_VERSION', '0.0.6'); +// define('GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION', '0.0.1'); + +// This is the minimum version of the GLM Members DB plugin require for this plugin. +define('GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.57'); + +// Check if plugin version is not current in WordPress option and if needed updated it +if (GLM_MEMBERS_SAMPLE_PLUGIN_VERSION != get_option('glmMembersDatabaseSamplePluginVersion')) { + update_option('glmMembersDatabaseSamplePluginVersion', GLM_MEMBERS_SAMPLE_PLUGIN_VERSION); +} + +/* + * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +// Check that we're being called by WordPress. +if (!defined('ABSPATH')) { + die("Please do not call this code directly!"); +} + +/* +* Some initial setup and tests +*/ + +$startupNotices = ''; + +// Get standard defined parameters +require_once('defines.php'); + +// Required to be able to get user capabilities when being called as a filter from the main plugin +require_once(ABSPATH . 'wp-includes/pluggable.php'); + +/* + * Do some checks to make sure the main GLM Member DB is active and of a recceint enough version + */ + +// Function to generate message regarding main GLM Member DB plugin not installed and active +function glmMembersSamplePluginRequired() { + echo ' +
+

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

+

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' plugin has been de-activated.

+
+ '; +} + +/* + * Check installation, activation, and version of main Member DB plugin + */ +include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); +$plugin_name = 'glm-member-db/glm-member-db.php'; +$is_active = is_plugin_active($plugin_name); + +// If it's not active, then warn user and deactivate this add-on plugin +if ($is_active != '1') { + add_action( 'admin_notices', 'glmMembersSamplePluginRequired' ); + deactivate_plugins('/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'.php'); +} + +// Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on +function glmMembersPluginSampleMinVerRequired() { + echo ' +
+

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than ' + .GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!
+ '.GLM_MEMBERS_SAMPLE_MIN_VERSION_NOTE.'

+

The '.GLM_MEMBERS_SAMPLE_PLUGIN_NAME.' plugin has been de-activated.

+
+ '; +} + +/* + * Check for Minimum DB version for main Member DB + */ +$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion'); +if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { + define('GLM_MEMBERS_SAMPLE_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, Sample Requires: ".GLM_MEMBERS_SAMPLE_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION); + add_action( 'admin_notices', 'glmMembersPluginSampleMinVerRequired'); + deactivate_plugins('/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'.php'); +} + +/* + * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded. + */ +require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/validActions.php'); +require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/shortcodes.php'); +$havePluginDatabase = false; +if (is_file(GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) { + require_once(GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php'); + $havePluginDatabase = true; +} + +// Load Sample Management Settings data +/* None - Need to figure out a smooth way to do this. +$sampleManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); +unset($sampleManagementSettings['id']); +*/ + +function glmMembersRegisterSample($addOns) { + + // Add this add-on to the add-ons array + $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG] = array( + 'dir' => GLM_MEMBERS_SAMPLE_PLUGIN_PATH, + 'name' => GLM_MEMBERS_SAMPLE_PLUGIN_NAME, + 'short_name' => GLM_MEMBERS_SAMPLE_PLUGIN_SHORT_NAME, + 'slug' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, + 'actions' => $GLOBALS['glmMembersSampleAddOnValidActions'], + 'config' => array( + ), + 'shortcodes' => $GLOBALS['glmMembersSampleShortcodes'], + 'shortcodesDescription' => $GLOBALS['glmMembersSampleShortcodesDescription'] + ); + + // If we have database tables for this plugin/addon, provide that data also + if ($GLOBALS['havePluginDatabase']) { + $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG]['database'] = array( + 'dbPrefix' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_PREFIX, + 'dbCurrentVersion' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION, + 'dbActiveVersionOption' => GLM_MEMBERS_SAMPLE_PLUGIN_ACTIVE_DB_OPTION, + 'dbScriptPath' => GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS, + 'dbVersions' => $GLOBALS['glmMembersSampleDbVersions'] + ); + } else { + $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG]['database'] = false; + } + + // Return the array with our data added + return $addOns; +} +add_filter('glm-member-db-register-addon','glmMembersRegisterSample', 10, 1); + + /* + * + * Activate and Deactivate hooks + * + */ + + // Activate + function glmMembersSamplePluginActivate () + { + global $wpdb, $config; + require_once (GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/activate.php'); + new glmMembersSamplePluginActivate($wpdb, $config); + } + register_activation_hook(__FILE__, 'glmMembersSamplePluginActivate'); + + // Deactivate + function glmMembersSamplePluginDeactivate () + { + global $wpdb, $config; + require_once (GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/deactivate.php'); + $x = new glmMembersSamplePluginDeactivate($wpdb, $config); + return false; + } + register_deactivation_hook(__FILE__, 'glmMembersSamplePluginDeactivate'); + +/* + * Hooks for testing capabilities provided by this add-on + */ +require_once(GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/permissions.php'); + -- 2.17.1