Now making sure that the sample add-on is not detected as a WordPress plugin till setup is complete.
--- /dev/null
+<?php
+/**
+ * Plugin Name: {descrName}
+ * Plugin URI: http://www.gaslightmedia.com/
+ * Description: {descrString}
+ * Version: 0.0.1
+ * Author: Gaslight Media
+ * Author URI: http://www.gaslightmedia.com/
+ * License: GPL2
+ */
+
+/**
+ * {descrName}
+ * Index
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPluginChild
+ * @package {camelcasePrefix}AddOn
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.0.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('{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('{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 ({definedPrefix}_PLUGIN_VERSION != get_option('{camelcasePrefix}PluginVersion')) {
+ update_option('{camelcasePrefix}PluginVersion', {definedPrefix}_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';
+
+// Include defines to tell if a plugin is active
+include_once ABSPATH . 'wp-admin/includes/plugin.php';
+
+/*
+ * Do some preliminary sanity checks
+ */
+
+// Check if database version should be defined and it isn't - This would be a plugin/add-on setup issue
+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!');
+}
+
+/*
+ * Check installation, activation, and version of main Member DB plugin
+ */
+
+// Check for main plugin and that it's active
+function {camelcasePrefix}PluginRequired() {
+ echo '
+ <div class="error">
+ <p>The '.{definedPrefix}_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
+ <p>The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$plugin_name = 'glm-member-db/index.php';
+$is_active = is_plugin_active($plugin_name);
+if ($is_active != '1') {
+ add_action( 'admin_notices', '{camelcasePrefix}PluginRequired' );
+ deactivate_plugins('/'.{definedPrefix}_PLUGIN_SLUG.'/index.php');
+}
+
+// Check for Minimum DB version for main Member DB
+function {camelcasePrefix}MinVerRequired() {
+ echo '
+ <div class="error">
+ <p>The '.{definedPrefix}_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than '
+ .{definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!<br>
+ '.{definedPrefix}_MIN_VERSION_NOTE.'</p>
+ <p>The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
+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 {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 Add-On Management Settings data
+/* None - Need to figure out a smooth way to do this.
+${camelcasePrefix}ManagementSettings = $wpdb->get_row( "SELECT * FROM ".{definedPrefix}_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+unset(${camelcasePrefix}ManagementSettings['id']);
+*/
+
+function {camelcasePrefix}RegisterAddOn($addOns) {
+
+ // Add this add-on to the add-ons array
+ $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['{camelcasePrefix}Shortcodes'],
+ 'shortcodesDescription' => $GLOBALS['{camelcasePrefix}ShortcodesDescription']
+ );
+
+ // If we have database tables for this plugin/addon, provide that data also
+ 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[{definedPrefix}_PLUGIN_SLUG]['database'] = false;
+ }
+
+ // Return the array with our data added
+ return $addOns;
+}
+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 {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__,
+ {definedPrefix}_PLUGIN_SLUG
+);
+
+${{definedPrefix}_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array(
+ 'license_key' => __('License Key:')
+));
+*/
+
+/*
+ *
+ * Activate and Deactivate hooks
+ *
+ */
+
+ // Activate
+ function {camelcasePrefix}PluginActivate ()
+ {
+ global $wpdb, $config;
+ require_once {definedPrefix}_PLUGIN_PATH . '/activate.php';
+ new {camelcasePrefix}PluginActivate($wpdb, $config);
+ }
+ register_activation_hook(__FILE__, '{camelcasePrefix}PluginActivate');
+
+ // Deactivate
+ function {camelcasePrefix}PluginDeactivate ()
+ {
+ global $wpdb, $config;
+ require_once {definedPrefix}_PLUGIN_PATH . '/deactivate.php';
+ $x = new {camelcasePrefix}PluginDeactivate($wpdb, $config);
+ return false;
+ }
+ register_deactivation_hook(__FILE__, '{camelcasePrefix}PluginDeactivate');
+
+/*
+ * Hooks for testing capabilities provided by this add-on
+ */
+require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/permissions.php';
+
echo "This script MUST be run from the directory where it resides. - Exiting..."
fi
+# Make sure the current directory is not the standard sample add-on slug name
+THISDIR=${PWD##*/}
+if [ "$slugString" = "glm-member-db-sample" ] ; then
+ echo "
+The current directory name must not be 'glm-members-db-sample'!
+Please clone this add-on to a new directory name before running this script.
+"
+ exit
+fi
+
+# Default the slug string to the name of this directory (WordPress standard)
+slugString=$THISDIR
+
:'
Strings that are replaced
while [ "$okToProceed" != "Yes" ] ; do
- while [ "$descrName" = "" ] || \
+ while [ "$slugString" = "" ] || \
+ [ "$descrName" = "" ] || \
[ "$shortName" = "" ] || \
[ "$descrString" = "" ] || \
- [ "$slugString" = "" ] || \
[ "$definedPrefix" = "" ] || \
[ "$camelcasePrefix" = "" ] || \
[ "$databaseEnable" = "" ] || \
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
+ read -e -i "$slugString" -p "Slug string.................(eg glm-member-db-sample)....................: " slugString
+ 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 This is a sample add-on.)................: " descrString
+ 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 "
+ Slug string........................: $slugString
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
+
+ if [ "$slugString" != "$THISDIR" ] ; then
+ echo
+ read -p "The slug string does not match the name of this directory. Are you sure you want to continue? (Yes/No): " okToProceed
+ fi
done
# 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
+ sed -i "s/{databaseEnable}//g" SAMPLE_index.php
else
echo "Dissabling database support for this add-on ..."
- sed -i "s|{databaseEnable}|//|g" index.php
+ sed -i "s|{databaseEnable}|//|g" SAMPLE_index.php
fi
echo "Removing other sample code and extraneous files ..."
rm -Rf views/admin/members
rm -Rf views/admin/sample
+echo "Enabling Add-on ..."
+mv SAMPLE_index.php index.php
+
echo "Setup is complete, now removing this script ..."
rm SETUP_SCRIPT
+++ /dev/null
-<?php
-/**
- * Plugin Name: {descrName}
- * Plugin URI: http://www.gaslightmedia.com/
- * Description: {descrString}
- * Version: 0.0.1
- * Author: Gaslight Media
- * Author URI: http://www.gaslightmedia.com/
- * License: GPL2
- */
-
-/**
- * {descrName}
- * Index
- *
- * PHP version 5.5
- *
- * @category glmWordPressPluginChild
- * @package {camelcasePrefix}AddOn
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 0.0.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('{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('{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 ({definedPrefix}_PLUGIN_VERSION != get_option('{camelcasePrefix}PluginVersion')) {
- update_option('{camelcasePrefix}PluginVersion', {definedPrefix}_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';
-
-// Include defines to tell if a plugin is active
-include_once ABSPATH . 'wp-admin/includes/plugin.php';
-
-/*
- * Do some preliminary sanity checks
- */
-
-// Check if database version should be defined and it isn't - This would be a plugin/add-on setup issue
-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!');
-}
-
-/*
- * Check installation, activation, and version of main Member DB plugin
- */
-
-// Check for main plugin and that it's active
-function {camelcasePrefix}PluginRequired() {
- echo '
- <div class="error">
- <p>The '.{definedPrefix}_PLUGIN_NAME.' add-on requires the base GLM Member DB plugin to be installed and active!</p>
- <p>The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.</p>
- </div>
- ';
-}
-$plugin_name = 'glm-member-db/index.php';
-$is_active = is_plugin_active($plugin_name);
-if ($is_active != '1') {
- add_action( 'admin_notices', '{camelcasePrefix}PluginRequired' );
- deactivate_plugins('/'.{definedPrefix}_PLUGIN_SLUG.'/index.php');
-}
-
-// Check for Minimum DB version for main Member DB
-function {camelcasePrefix}MinVerRequired() {
- echo '
- <div class="error">
- <p>The '.{definedPrefix}_PLUGIN_NAME.' requires that the main GLM Member DB plugin version be no older than '
- .{definedPrefix}_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION.'!<br>
- '.{definedPrefix}_MIN_VERSION_NOTE.'</p>
- <p>The '.{definedPrefix}_PLUGIN_NAME.' plugin has been de-activated.</p>
- </div>
- ';
-}
-$glmMembersDatabasePluginVersion = get_option('glmMembersDatabasePluginVersion');
-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 {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 Add-On Management Settings data
-/* None - Need to figure out a smooth way to do this.
-${camelcasePrefix}ManagementSettings = $wpdb->get_row( "SELECT * FROM ".{definedPrefix}_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
-unset(${camelcasePrefix}ManagementSettings['id']);
-*/
-
-function {camelcasePrefix}RegisterAddOn($addOns) {
-
- // Add this add-on to the add-ons array
- $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['{camelcasePrefix}Shortcodes'],
- 'shortcodesDescription' => $GLOBALS['{camelcasePrefix}ShortcodesDescription']
- );
-
- // If we have database tables for this plugin/addon, provide that data also
- 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[{definedPrefix}_PLUGIN_SLUG]['database'] = false;
- }
-
- // Return the array with our data added
- return $addOns;
-}
-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 {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__,
- {definedPrefix}_PLUGIN_SLUG
-);
-
-${{definedPrefix}_PLUGIN_PREFIX."updateChecker"}->declareCredentials(array(
- 'license_key' => __('License Key:')
-));
-*/
-
-/*
- *
- * Activate and Deactivate hooks
- *
- */
-
- // Activate
- function {camelcasePrefix}PluginActivate ()
- {
- global $wpdb, $config;
- require_once {definedPrefix}_PLUGIN_PATH . '/activate.php';
- new {camelcasePrefix}PluginActivate($wpdb, $config);
- }
- register_activation_hook(__FILE__, '{camelcasePrefix}PluginActivate');
-
- // Deactivate
- function {camelcasePrefix}PluginDeactivate ()
- {
- global $wpdb, $config;
- require_once {definedPrefix}_PLUGIN_PATH . '/deactivate.php';
- $x = new {camelcasePrefix}PluginDeactivate($wpdb, $config);
- return false;
- }
- register_deactivation_hook(__FILE__, '{camelcasePrefix}PluginDeactivate');
-
-/*
- * Hooks for testing capabilities provided by this add-on
- */
-require_once {definedPrefix}_PLUGIN_SETUP_PATH.'/permissions.php';
-