From: Chuck Scott Date: Fri, 28 Oct 2016 18:05:17 +0000 (-0400) Subject: Converted plugin to non-functional template for a new Add-On including a setup script. X-Git-Tag: v1.0.0^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=c0d01b1d9e429b8f1f8ae39cf6fd245e2a02a25a;p=WP-Plugins%2Fglm-member-db-sample.git Converted plugin to non-functional template for a new Add-On including a setup script. All important sample names, titles, parameters, and defines are now replaceable parameters that the setup script will replace with strings requested by script input. --- diff --git a/SETUP_SCRIPT b/SETUP_SCRIPT new file mode 100755 index 0000000..e921877 --- /dev/null +++ b/SETUP_SCRIPT @@ -0,0 +1,123 @@ +#!/bin/bash +# +# New Add-On Setup Script +# + +# Make sure this script is only run from the directory where it resides. +THISDIR=`dirname $0` +if [ "$THISDIR" != "." ] ; then + echo "This script MUST be run from the directory where it resides. - Exiting..." +fi + +:' + + Strings that are replaced + + Replaceable String Example of text that might go here + ----------------------- --------------------------------------------------------------- + {descrName} Gaslight Media Members Database Sample Add-On Plugin + {shortName} Sample + {descrString} Gaslight Media Members Database Sample + {slugString} glm-member-db-sample + {definedPrefix} GLM_MEMBERS_SAMPLE + {camelcasePrefix} glmMembersSample Also use for database prefix + {databaseEnable} (Used to enable database tables by removing comment slashes) + +' + +okToProceed="" + +while [ "$okToProceed" != "Yes" ] ; do + + while [ "$descrName" = "" ] || \ + [ "$shortName" = "" ] || \ + [ "$descrString" = "" ] || \ + [ "$slugString" = "" ] || \ + [ "$definedPrefix" = "" ] || \ + [ "$camelcasePrefix" = "" ] || \ + [ "$databaseEnable" = "" ] || \ + [ "$okToProceed" != "" ] \ + ; do + + okToProceed="" + clear + echo " +New GLM Associate Add-On Setup +------------------------------ +" + read -e -i "$descrName" -p "Descriptive name (eg Gaslight Media Members Database Sample) : " descrName + read -e -i "$shortName" -p "Short name (eg Sample) : " shortName + read -e -i "$descrString" -p "Description (eg Gaslight Media Members Database Sample) : " descrString + read -e -i "$slugString" -p "Slug string (eg glm-member-db-sample) : " slugString + read -e -i "$definedPrefix" -p "Defined param prefix (eg GLM_MEMBERS_SAMPLE) : " definedPrefix + read -e -i "$camelcasePrefix" -p "CamelCase prefix (eg glmMembersSample) : " camelcasePrefix + read -e -i "$databaseEnable" -p "Enable Add-On DB tables (Yes/No) : " databaseEnable + done + + echo " + Descriptive name...................: $descrName + Short name.........................: $shortName + Description........................: $descrString + Slug string........................: $slugString + Defined param prefix...............: $definedPrefix + CamelCase prefix...................: $camelcasePrefix + Add-on will have Database tables...: $databaseEnable + + " + read -p "Is this all OK? (Yes/No): " okToProceed + +done + +echo " +Running setup script with the above parameters +----------------------------------------------" + +if [ -d ".git" ] ; then + echo "Git directory exists, removing to disconnect from repository ..." + rm -Rf .git +else + echo "No Git directory detected ..." +fi + +echo "Replace {descrName} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{descrName}/$descrName/g" {} \; + +echo "Replace {shortName} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{shortName}/$shortName/g" {} \; + +echo "Replace {descrString} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{descrString}/$descrString/g" {} \; + +echo "Replace {slugString} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{slugString}/$slugString/g" {} \; + +echo "Replace {definedPrefix} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{definedPrefix}/$definedPrefix/g" {} \; + +echo "Replace {camelcasePrefix} ..." +find . \( -name '*.phtml' -o -name '*.php' -o -name '*.inc' -o -name '*.txt' \) -exec sed -i "s/{camelcasePrefix}/$camelcasePrefix/g" {} \; + +# If add-on is contributing database tables +if [ "$databaseEnable" = "Yes" ] ; then + echo "Enabling database support for this add-on ..." + sed -i "s/{databaseEnable}//g" index.php +else + echo "Dissabling database support for this add-on ..." + sed -i "s|{databaseEnable}|//|g" index.php +fi + +echo "Removing other sample code and extraneous files ..." +rm -Rf setup/databaseScripts/* +rm -f classes/data/dataSample.php +rm -Rf models/admin/info +rm -Rf models/admin/members +rm -Rf models/admin/sample +rm -Rf views/admin/info +rm -Rf views/admin/members +rm -Rf views/admin/sample + +echo "Setup is complete, now removing this script ..." +rm SETUP_SCRIPT + +echo "Done! +" diff --git a/activate.php b/activate.php index ca29be3..d6e076c 100644 --- a/activate.php +++ b/activate.php @@ -1,31 +1,19 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release activate.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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 file activates this add-on. Other than replacing the various - * versions of the work "Sample", this code should not need editing. - * - * Remove this message before using this file in production! - **********************************************************************/ - // Check that we're being called by WordPress. if (!defined('ABSPATH')) { die("Please do not call this code directly!"); @@ -38,7 +26,7 @@ if (!defined('ABSPATH')) { * Currently the only actions are to add role capability to display and modify * prototypes. */ -class glmMembersSamplePluginActivate +class {camelcasePrefix}PluginActivate { /** @@ -80,10 +68,10 @@ class glmMembersSamplePluginActivate $this->config = $config; // Set current plugin version - update_option('glmMembersDatabaseSamplePluginVersion', GLM_MEMBERS_SAMPLE_PLUGIN_VERSION); + update_option('{camelcasePrefix}PluginVersion', {definedPrefix}_PLUGIN_VERSION); // Set Roles and Capabilities for this plugin - require_once GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/rolesAndCapabilities.php'; + require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/rolesAndCapabilities.php'; } /* diff --git a/classes/readme.txt b/classes/readme.txt new file mode 100644 index 0000000..fa5f44e --- /dev/null +++ b/classes/readme.txt @@ -0,0 +1,3 @@ +General class libraries developed specifically for this add-on should be placed in this directory. + +The lib directory should be considered instead for any standard class libraries not specifically developed for this add-on. \ No newline at end of file diff --git a/config/plugin.ini b/config/plugin.ini index 45899fc..9222f7e 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -1,6 +1,6 @@ ; ; Main Configuration File -; Gaslight Media Members Database Sample Add-On Plugin +; {descrName} ; ; Place any static configuration parameters here. ; diff --git a/deactivate.php b/deactivate.php index b7fb800..c2a46b8 100644 --- a/deactivate.php +++ b/deactivate.php @@ -1,30 +1,18 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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 file deactivates this add-on. Other than replacing the various - * versions of the work "Sample", this code should not need editing. - * - * Remove this message before using this file in production! - **********************************************************************/ - // Check that we're being called by WordPress. if (!defined('ABSPATH')) { die("Please do not call this code directly!"); @@ -34,7 +22,7 @@ if (!defined('ABSPATH')) { * This class performs all necessary additional work when this * plugin is deactivated. */ -class glmMembersSamplePluginDeactivate +class {camelcasePrefix}PluginDeactivate { /** @@ -67,7 +55,7 @@ class glmMembersSamplePluginDeactivate $this->config = $config; // Delete our version from WordPress Options - delete_option('glmMembersDatabaseSamplePluginVersion'); + delete_option('{camelcasePrefix}PluginVersion'); } } diff --git a/defines.php b/defines.php index a0baee0..b7d73e8 100644 --- a/defines.php +++ b/defines.php @@ -1,44 +1,34 @@ prefix.'glm_membersSample_'); -define('GLM_MEMBERS_SAMPLE_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersSampleDbVersion'); +define('{definedPrefix}_PLUGIN_DB_PREFIX', $wpdb->prefix.'{camelcasePrefix}'); +define('{definedPrefix}_PLUGIN_ACTIVE_DB_OPTION', '{camelcasePrefix}DbVersion'); // Determine which system we're running on - If not provided, assume PRODUCTION $host = getenv('GLM_HOST_ID'); if (trim($host) == '') { $host = 'PRODUCTION'; } -define('GLM_MEMBER_SAMPLE_PLUGIN_HOST', $host); +define('{definedPrefix}_PLUGIN_HOST', $host); // Determine current http/https protocol $pageProtocol = 'http'; if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') { $pageProtocol = 'https'; } -define('GLM_MEMBERS_SAMPLE_PLUGIN_HTTP_PROTOCOL', $pageProtocol); +define('{definedPrefix}_PLUGIN_HTTP_PROTOCOL', $pageProtocol); // Get various pieces of the URL $urlParts = parse_url(get_bloginfo('url')); @@ -50,25 +40,25 @@ $WPUploadDir = wp_upload_dir(); * Create a copy of the plugin slug that can be used as a variable prefix used to keep * global instances from clashing with instances in other plugins. */ -$vprefix = str_replace('-', '_', GLM_MEMBERS_SAMPLE_PLUGIN_SLUG); -define('GLM_MEMBERS_SAMPLE_PLUGIN_PREFIX', $vprefix.'_'); +$vprefix = str_replace('-', '_', {definedPrefix}_PLUGIN_SLUG); +define('{definedPrefix}_PLUGIN_PREFIX', $vprefix.'_'); // URLs -define('GLM_MEMBERS_SAMPLE_SITE_BASE_URL', home_url('/') ); -define('GLM_MEMBERS_SAMPLE_PLUGIN_URL', plugin_dir_url(__FILE__)); -define('GLM_MEMBERS_SAMPLE_PLUGIN_ADMIN_URL', admin_url('admin.php')); -define('GLM_MEMBERS_SAMPLE_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG); -define('GLM_MEMBERS_SAMPLE_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]); +define('{definedPrefix}_SITE_BASE_URL', home_url('/') ); +define('{definedPrefix}_PLUGIN_URL', plugin_dir_url(__FILE__)); +define('{definedPrefix}_PLUGIN_ADMIN_URL', admin_url('admin.php')); +define('{definedPrefix}_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.{definedPrefix}_PLUGIN_SLUG); +define('{definedPrefix}_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]); // Directories -define('GLM_MEMBERS_SAMPLE_PLUGIN_PATH', dirname(__FILE__)); -define('GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH', GLM_MEMBERS_SAMPLE_PLUGIN_PATH.'/setup'); -define('GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS', GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/databaseScripts'); -define('GLM_MEMBERS_SAMPLE_PLUGIN_CLASS_PATH', GLM_MEMBERS_SAMPLE_PLUGIN_PATH.'/classes'); -define('GLM_MEMBERS_SAMPLE_PLUGIN_CONFIG_PATH', GLM_MEMBERS_SAMPLE_PLUGIN_PATH.'/config'); +define('{definedPrefix}_PLUGIN_PATH', dirname(__FILE__)); +define('{definedPrefix}_PLUGIN_SETUP_PATH', {definedPrefix}_PLUGIN_PATH.'/setup'); +define('{definedPrefix}_PLUGIN_DB_SCRIPTS', {definedPrefix}_PLUGIN_SETUP_PATH.'/databaseScripts'); +define('{definedPrefix}_PLUGIN_CLASS_PATH', {definedPrefix}_PLUGIN_PATH.'/classes'); +define('{definedPrefix}_PLUGIN_CONFIG_PATH', {definedPrefix}_PLUGIN_PATH.'/config'); // Parameters related to the Main GLM Member DB plugin - Depending on what's going on these may already defined by the main plugin -$pluginsPath = str_replace(GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, '', GLM_MEMBERS_SAMPLE_PLUGIN_PATH); -define('GLM_MEMBERS_SAMPLE_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db'); -define('GLM_MEMBERS_SAMPLE_PLUGIN_LIB_PATH', GLM_MEMBERS_SAMPLE_MAIN_PLUGIN_PATH.'/lib'); +$pluginsPath = str_replace({definedPrefix}_PLUGIN_SLUG, '', {definedPrefix}_PLUGIN_PATH); +define('{definedPrefix}_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db'); +define('{definedPrefix}_PLUGIN_LIB_PATH', {definedPrefix}_MAIN_PLUGIN_PATH.'/lib'); diff --git a/index.php b/index.php index 4d24f4a..4655105 100644 --- a/index.php +++ b/index.php @@ -1,41 +1,25 @@ * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.1.1 + * @version 0.0.1 */ /* @@ -53,15 +37,15 @@ * 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.7'); -// define('GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION', '0.0.1'); +define('{definedPrefix}_PLUGIN_VERSION', '0.0.1'); +{databaseEnable}define('{definedPrefix}_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'); +define('{definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); // 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); +if ({definedPrefix}_PLUGIN_VERSION != get_option('{camelcasePrefix}PluginVersion')) { + update_option('{camelcasePrefix}PluginVersion', {definedPrefix}_PLUGIN_VERSION); } /* @@ -107,7 +91,7 @@ include_once ABSPATH . 'wp-admin/includes/plugin.php'; */ // Check if database version should be defined and it isn't - This would be a plugin/add-on setup issue -if (is_file(GLM_MEMBERS_SAMPLE_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.php') && !defined('GLM_MEMBERS_SAMPLE_PLUGIN_DB_VERSION')) { +if (is_file({definedPrefix}_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.php') && !defined('{definedPrefix}_PLUGIN_DB_VERSION')) { die('You have database scripts but have not defined a current database version at the top of index.php for this plugin/add-on!'); } @@ -116,99 +100,99 @@ if (is_file(GLM_MEMBERS_SAMPLE_PLUGIN_PATH.'/setup/databaseScripts/dbVersions.ph */ // Check for main plugin and that it's active -function glmMembersSamplePluginRequired() { +function {camelcasePrefix}PluginRequired() { 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.

+

The '.{definedPrefix}_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!

+

The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.

'; } $plugin_name = 'glm-member-db/index.php'; $is_active = is_plugin_active($plugin_name); if ($is_active != '1') { - add_action( 'admin_notices', 'glmMembersSamplePluginRequired' ); - deactivate_plugins('/'.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG.'/index.php'); + add_action( 'admin_notices', '{camelcasePrefix}PluginRequired' ); + deactivate_plugins('/'.{definedPrefix}_PLUGIN_SLUG.'/index.php'); } // Check for Minimum DB version for main Member DB -function glmMembersPluginSampleMinVerRequired() { +function {camelcasePrefix}MinVerRequired() { 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.

+

The '.{definedPrefix}_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than ' + .{definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!
+ '.{definedPrefix}_MIN_VERSION_NOTE.'

+

The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.

'; } $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'); +if (version_compare($glmMembersDatabasePluginVersion, {definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION) < 0) { + define('{definedPrefix}_MIN_VERSION_NOTE', "Members DB: $glmMembersDatabasePluginVersion, {shortName} Requires: ".{definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION); + add_action( 'admin_notices', '{camelcasePrefix}MinVerRequired'); + deactivate_plugins('/'.{definedPrefix}_PLUGIN_SLUG.'/'.{definedPrefix}_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'; -if (is_file(GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) { - require_once GLM_MEMBERS_SAMPLE_PLUGIN_DB_SCRIPTS.'/dbVersions.php'; +require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/validActions.php'; +require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/shortcodes.php'; +if (is_file({definedPrefix}_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) { + require_once {definedPrefix}_PLUGIN_DB_SCRIPTS.'/dbVersions.php'; } -// Load Sample Management Settings data +// Load Add-On 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']); +${camelcasePrefix}ManagementSettings = $wpdb->get_row( "SELECT * FROM ".{definedPrefix}_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); +unset(${camelcasePrefix}ManagementSettings['id']); */ -function glmMembersRegisterSample($addOns) { +function {camelcasePrefix}RegisterAddOn($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'], + $addOns[{definedPrefix}_PLUGIN_SLUG] = array( + 'dir' => {definedPrefix}_PLUGIN_PATH, + 'name' => {definedPrefix}_PLUGIN_NAME, + 'short_name' => {definedPrefix}_PLUGIN_SHORT_NAME, + 'slug' => {definedPrefix}_PLUGIN_SLUG, + 'actions' => $GLOBALS['{camelcasePrefix}AddOnValidActions'], 'config' => array( ), - 'shortcodes' => $GLOBALS['glmMembersSampleShortcodes'], - 'shortcodesDescription' => $GLOBALS['glmMembersSampleShortcodesDescription'] + 'shortcodes' => $GLOBALS['{camelcasePrefix}Shortcodes'], + 'shortcodesDescription' => $GLOBALS['{camelcasePrefix}ShortcodesDescription'] ); // If we have database tables for this plugin/addon, provide that data also - if (isset($GLOBALS['glmMembersSampleDbVersions'])) { - $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'] + if (isset($GLOBALS['{camelcasePrefix}DbVersions'])) { + $addOns[{definedPrefix}_PLUGIN_SLUG]['database'] = array( + 'dbPrefix' => {definedPrefix}_PLUGIN_DB_PREFIX, + 'dbCurrentVersion' => {definedPrefix}_PLUGIN_DB_VERSION, + 'dbActiveVersionOption' => {definedPrefix}_PLUGIN_ACTIVE_DB_OPTION, + 'dbScriptPath' => {definedPrefix}_PLUGIN_DB_SCRIPTS, + 'dbVersions' => $GLOBALS['{camelcasePrefix}DbVersions'] ); } else { - $addOns[GLM_MEMBERS_SAMPLE_PLUGIN_SLUG]['database'] = false; + $addOns[{definedPrefix}_PLUGIN_SLUG]['database'] = false; } // Return the array with our data added return $addOns; } -add_filter('glm-member-db-register-addon','glmMembersRegisterSample', 10, 1); +add_filter('glm-member-db-register-addon','{camelcasePrefix}RegisterAddOn', 10, 1); /* * Plugin Update Support - uses Gaslight Media update server */ /* Not functional yet - Need to resolve JavaScript conflicts with this feature in other plugins -require GLM_MEMBERS_SAMPLE_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php'; -${GLM_MEMBERS_SAMPLE_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker( - 'http://www.gaslightmedia.com/update_server/?action=get_metadata&slug='.GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, +require {definedPrefix}_PLUGIN_LIB_PATH.'/opentools-update-checker/opentools-update-checker.php'; +${{definedPrefix}_PLUGIN_PREFIX."updateChecker"} = new OpenToolsPluginUpdateChecker( + 'http://www.gaslightmedia.com/update_server/?action=get_metadata&slug='.{definedPrefix}_PLUGIN_SLUG, __FILE__, - GLM_MEMBERS_SAMPLE_PLUGIN_SLUG + {definedPrefix}_PLUGIN_SLUG ); -${GLM_MEMBERS_SAMPLE_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array( +${{definedPrefix}_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array( 'license_key' => __('License Key:') )); */ @@ -220,26 +204,26 @@ ${GLM_MEMBERS_SAMPLE_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array( */ // Activate - function glmMembersSamplePluginActivate () + function {camelcasePrefix}PluginActivate () { global $wpdb, $config; - require_once GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/activate.php'; - new glmMembersSamplePluginActivate($wpdb, $config); + require_once {definedPrefix}_PLUGIN_PATH . '/activate.php'; + new {camelcasePrefix}PluginActivate($wpdb, $config); } - register_activation_hook(__FILE__, 'glmMembersSamplePluginActivate'); + register_activation_hook(__FILE__, '{camelcasePrefix}PluginActivate'); // Deactivate - function glmMembersSamplePluginDeactivate () + function {camelcasePrefix}PluginDeactivate () { global $wpdb, $config; - require_once GLM_MEMBERS_SAMPLE_PLUGIN_PATH . '/deactivate.php'; - $x = new glmMembersSamplePluginDeactivate($wpdb, $config); + require_once {definedPrefix}_PLUGIN_PATH . '/deactivate.php'; + $x = new {camelcasePrefix}PluginDeactivate($wpdb, $config); return false; } - register_deactivation_hook(__FILE__, 'glmMembersSamplePluginDeactivate'); + register_deactivation_hook(__FILE__, '{camelcasePrefix}PluginDeactivate'); /* * Hooks for testing capabilities provided by this add-on */ -require_once GLM_MEMBERS_SAMPLE_PLUGIN_SETUP_PATH.'/permissions.php'; +require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/permissions.php'; diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000..8373066 --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,3 @@ +Standard class libraries not specifically developed for this add-on should be placed here. + +The classes directory should be considered instead for class libraries developed specifically for this add-on. diff --git a/misc/documentation/CreateNewAddOn.txt b/misc/documentation/CreateNewAddOn.txt index ece4624..b93235f 100644 --- a/misc/documentation/CreateNewAddOn.txt +++ b/misc/documentation/CreateNewAddOn.txt @@ -3,12 +3,7 @@ Procedure to create a new GLM Members add-on plugin * Checkout glm-member-db-sample and rename directory to glm-member-db-{add-on name} -* Rename glm-member-db-sample.php to glm-member-db-{addon name}.php - -* Review all files and change references to "sample" (any case) to the new add-on name. - - Read the information in the "NOTE: THIS IS A SAMPLE FILE - DO NOT USE UNMODIFIED" and - do anything recommended there. - - Remove all of the "NOTE: THIS IS A SAMPLE FILE - DO NOT USE UNMODIFIED" blocks. +* From a bash prompt, run "SETUP_SCRIPT" * Create new repository named WP-Plugins/glm-member-db-{name of add-on}.git diff --git a/readme.txt b/readme.txt index 2bbad40..3f35dc7 100644 --- a/readme.txt +++ b/readme.txt @@ -1,18 +1,18 @@ -=== Gaslight Media Member Database Sample Child Plugin === +=== {descrName} === Contributors: cscott@gaslightmedia.com Donate link: http://www.gaslightmedia.com -Tags: Gaslight Media,Plugin,Members Sample +Tags: Gaslight Media,Plugin,{shortName} Requires at least: 3.0.1 Tested up to: 3.4 Stable tag: 4.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -This is the Gaslight Media Members Database Sample Child Plugin. +This is the {descrName}. == Description == -The Gaslight Media Members Database Sample Child Plugin is an add-on to the Gaslight Media Members Database, +The {descrName} is an add-on to the Gaslight Media Members Database, which is required to install and run this plugin == Installation == diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 8c36dfc..e0ca786 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -1,6 +1,6 @@ controller('sample');}, // Called function - false, // Icon URL - '92' // Menu Position -); - -add_submenu_page( - 'glm-members-admin-menu-sample', // Parent slug - 'Sample', // Page title - 'Sample', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-sample-sample', // Menu slug - function() {$this->controller('sample');} -); - -add_submenu_page( - 'glm-members-admin-menu-sample', // Parent slug - 'Info', // Page title - 'Info', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-sample-info', // Menu slug - function() {$this->controller('info');} -); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 9f22164..234c914 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -1,7 +1,7 @@ 'Sample', - 'menu' => 'members', - 'action' => 'sample' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } -); - diff --git a/setup/frontHooks.php b/setup/frontHooks.php index f04d3c3..ed5868f 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -1,7 +1,7 @@ - - -/********************************************************************** - * 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 file is used to document hooks provided by this add-on. Content - * here will be displayed in the "Management" page "Hooks" tab. If - * there is no content for this page, this file should be omitted. - * - * Remove this message before using this file in production! - **********************************************************************/ - + \ No newline at end of file diff --git a/setup/permissions.php b/setup/permissions.php index 1e0c902..68554ec 100644 --- a/setup/permissions.php +++ b/setup/permissions.php @@ -1,7 +1,7 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release rolesAndPermissions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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 file is used to add roles and capability. If none are required, - * this file should be omitted. - * - * Remove this message before using this file in production! - **********************************************************************/ - /** * NOTE: This file is only included in the activate.php process. * It is not regularly used during operation. diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 383e673..8e0f462 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -1,32 +1,18 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release shortcodes.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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 file is used to define shortcodes that will be handled by this - * add-0n. - * - * DO NOT DELETE THIS FILE EVEN IF THERE ARE NOT SHORTCODES - * - * Remove this message before using this file in production! - **********************************************************************/ - /* * Array of short-code * @@ -100,8 +86,8 @@ * */ -$glmMembersSampleShortcodes = array( +${camelcasePrefix}Shortcodes = array( ); -$glmMembersSampleShortcodesDescription = ''; +${camelcasePrefix}ShortcodesDescription = ''; diff --git a/setup/validActions.php b/setup/validActions.php index 658d1d6..9e83daf 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -1,32 +1,18 @@ * @license http://www.gaslightmedia.com Gaslightmedia * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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 file is used to define valid actions for both admin and - * front-end pages. - * - * DO NOT DELETE THIS FILE EVEN IF THERE ARE NO ACTIONS - * - * Remove this message before using this file in production! - **********************************************************************/ - /* * Array of valid menu items and actions. * @@ -42,28 +28,39 @@ * * This array is integrated into the valid actions array in the main GLM Member * DB plugin when this plugin registers itself. + * + * EXAMPLE + * + * ${camelcasePrefix}AddOnValidActions = array( + * 'adminActions' => array( + * 'members' => array( + * 'sample' => {definedPrefix}_PLUGIN_SLUG, + * ), + * 'sample' => array( + * 'index' => {definedPrefix}_PLUGIN_SLUG, + * 'more' => {definedPrefix}_PLUGIN_SLUG, + * ), + * 'info' => array( + * 'index' => {definedPrefix}_PLUGIN_SLUG + * ) + * ), + * 'frontActions' => array( + * 'sample' => array( + * 'list' => {definedPrefix}_PLUGIN_SLUG, + * 'detail' => {definedPrefix}_PLUGIN_SLUG + * ) + * ) + * ); + * + * + * + * */ -$glmMembersSampleAddOnValidActions = array( +${camelcasePrefix}AddOnValidActions = array( 'adminActions' => array( - 'members' => array( - 'sample' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, - ), - 'sample' => array( - 'index' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, - 'more' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, - ), - 'info' => array( - 'index' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG - ) ), 'frontActions' => array( -/* - 'sample' => array( - 'list' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG, - 'detail' => GLM_MEMBERS_SAMPLE_PLUGIN_SLUG - ) -*/ ) ); diff --git a/uninstall.php b/uninstall.php index 181a827..02de592 100644 --- a/uninstall.php +++ b/uninstall.php @@ -3,28 +3,19 @@ die('uninstall not configured - See plugin uninstall.php script!'); /** - * Gaslight Media Members Database Sample Child Plugin + * {descrName} * Uninstall Plugin * * PHP version 5.5 * * @category glmWordPressPlugin - * @package glmMembersDatabaseSample + * @package {camelcasePrefix} * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * 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. - * - * Remove this message before using this file in production! - **********************************************************************/ - // Check that we're being called by WordPress. if (!defined('ABSPATH')) { die("Please do not call this code directly!");