From: Laury GvR Date: Fri, 22 Apr 2016 19:21:34 +0000 (-0400) Subject: Auto page-creation on first activate X-Git-Tag: v2.0.0^2~28^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c888571e72f55319d727151d2968636abd13761a;p=WP-Plugins%2Fglm-member-db.git Auto page-creation on first activate --- diff --git a/activate.php b/activate.php index a9d8ed76..4d0e1bad 100644 --- a/activate.php +++ b/activate.php @@ -75,7 +75,7 @@ class glmMembersPluginActivate extends glmPluginSupport // Save plugin configuration object $this->config = $config; - + if (!$noDatabaseCheck) { // Check the database - allow installation of tables for a new add-on @@ -93,6 +93,12 @@ class glmMembersPluginActivate extends glmPluginSupport update_option('glmMembersDatabasePluginVersion', GLM_MEMBERS_PLUGIN_VERSION); } + + if (get_option('glm_members_database_first_activation') == true) { + //update_option('glm_members_database_first_activation',false); + $this->createPages(); + } + } /* @@ -196,5 +202,33 @@ class glmMembersPluginActivate extends glmPluginSupport } } - + + /* + * Create new pages containing the member DB shortcodes + * + * + * @return void + * @access private + */ + private function createPages() + { + $member_pages = array( + 'Members Page' => '[glm-members-list]', + 'Member Detail' => '[glm-member-detail]' + ); + foreach($member_pages as $pageName => $shortCode) { + $trimmedName = 'glm_members_database_'.str_replace(' ','_',strtolower($pageName)); + if ( !get_post(get_option($trimmedName))) { + $new_page = array( + 'post_title' => $pageName, + 'post_content' => $shortCode, + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_author' => '1' + ); + $new_id = wp_insert_post($new_page); + update_option($trimmedName, $new_id); + } + } + } } diff --git a/index.php b/index.php index b9ccc3da..96431a99 100644 --- a/index.php +++ b/index.php @@ -213,6 +213,7 @@ 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