From: Laury GvR Date: Thu, 28 Apr 2016 19:15:02 +0000 (-0400) Subject: Req. Page auto-creation config and function X-Git-Tag: v2.0.0^2~26^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=4f08b6d9ffbdddb97b7a7048763b34f1432feb8e;p=WP-Plugins%2Fglm-member-db.git Req. Page auto-creation config and function --- diff --git a/controllers/admin.php b/controllers/admin.php index 11695394..df662f6e 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -209,6 +209,30 @@ class glmMembersAdmin extends GlmPluginSupport } + /* + * Create new pages containing the member DB shortcodes + * @return void + */ + public function createPages($requiredPages) + { + foreach($requiredPages as $requiredPage => $requiredPageInfo) { + //foreach($requiredPageInfo as $key => $value) { + $trimmedName = 'glm_members_database_'.str_replace(' ','_',strtolower($requiredPage)).'_id'; + if ( !get_post(get_option($trimmedName))) { + $new_page = array( + 'post_title' => $requiredPage, + 'post_content' => $requiredPageInfo['content'], + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_author' => '1', + 'page_template' => isset($requiredPageInfo['template']) ? $requiredPageInfo['template'] : 'index.php' , + 'post_parent' => $requiredPageInfo['parent'] !== '0' ? get_option('glm_members_database_glm_associate_id') : '0' + ); + $new_id = wp_insert_post($new_page); + update_option($trimmedName, $new_id); + } + } + } /** @@ -684,6 +708,13 @@ class glmMembersAdmin extends GlmPluginSupport } } + foreach ($this->config['addOns'] as $a) { + // + if (isset($a['required_pages'])) { + $this->createPages($a['required_pages']); + } + } + // Loop till we have a final action $loopCheck = 0; $loopTracking = "

Menu: $menuItem, Action = $action

"; diff --git a/index.php b/index.php index 96431a99..3f53a723 100644 --- a/index.php +++ b/index.php @@ -213,7 +213,6 @@ require_once('config.php'); // Try to set the DB version option to false (new plugin) - If it's already set this won't do anything. add_option('glmMembersDatabaseDbVersion', false); -add_option('glm_members_database_first_activation', true); /* * * Hook in add-ons and integrate their actions @@ -289,6 +288,27 @@ $config['addOns'] = array( 'dbActiveVersionOption' => GLM_MEMBERS_PLUGIN_ACTIVE_DB_OPTION, 'dbScriptPath' => GLM_MEMBERS_PLUGIN_DB_SCRIPTS, 'dbVersions' => $glmMembersDbVersions + ), + 'required_pages' => array( + // These should be in GLM Associate + 'GLM Associate' => array( + 'content' => '', + 'parent' => '0' + ), + // These should be in GLM Members + 'Members Only' => array( + 'content' => 'This page and any child beneath it will automatically be locked to Members Only with the members-only-template.', + 'parent' => '0', + 'template' => 'glm-members-only-template.php' + ), + 'Members List' => array( + 'content' => '[glm-members-list]', + 'parent' => 'GLM Associate' + ), + 'Member Detail' => array( + 'content' => '[glm-member-detail]', + 'parent' => 'GLM Associate' + ) ) ) ); @@ -318,7 +338,7 @@ if (count($config['addOns']) > 0) { if (isset($a['config'])) { $config = array_merge_recursive($config, $a['config']); } - + // If the add-on has additional config parameters in a plugin.ini file $iniFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.'/'.$a['slug'].'/config/plugin.ini'; if (isset($iniFile)) {