additional forms?
authorLaury GvR <laury@gaslightmedia.com>
Wed, 15 Jun 2016 16:42:30 +0000 (12:42 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 15 Jun 2016 16:42:30 +0000 (12:42 -0400)
classes/glmPluginSupport.php

index deae9f9..461a67d 100644 (file)
@@ -350,15 +350,25 @@ return; // Off for now ** Need to make this switchable in management
         $value = $this->wpdb->get_var("SELECT ID FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
         return $value;
     }
-
+    
+    public function nicePrint($array){
+        echo '<pre>', print_r($array), '</pre>';
+    }
+    
     /**
      *
      * Shortcode Builder Functions
      *
      */
-
+    private $shortcodeCounter = 0;
+    private function get_shortcode_count() {
+        return $this->shortcodeCounter;
+    }
+    private function increase_shortcode_count() {
+        $this->shortcodeCounter += 1;
+    }
     public function glmMembersShortcode(){
-
+        
         // load shortcodeBuilder.js when the shortcode function has been fired if it hasn't been enqueued yet
         if( ! wp_script_is( 'jquery-ui-dialog', 'enqueued' ) ){
             wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
@@ -394,40 +404,10 @@ return; // Off for now ** Need to make this switchable in management
 
     }
 
-    // metabox content
-    public function shortcode_builder_markup(){
-
-        require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
-        
-        $listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes'];
-        $detailAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-member-detail']['attributes'];
-
-        $glmcat = new GlmDataCategories($this->wpdb, $this->config);
-        $list = $glmcat->getListSortedParentChild();
-        // get the each addOn slugs to pass to the config array later
-        $addOns = $this->config['addOns'];
-        foreach($addOns as $addOn){
-            if(!is_array($addOn['slug'])){
-                $addOnSlugs[] = $addOn['slug'];
-            }
-        }
-
-        // use the addOn slugs to access each of the shortcodes
-        foreach($addOnSlugs as $addOn){
-            $shortCodeList[] = $this->config['addOns'][$addOn]['shortcodes'];
-        }
-
-        // loop through the shortcodes to pull out the shortcode names
-        foreach($shortCodeList as $addonInfo) {
-            foreach($addonInfo as $shortCode=>$value){
-//            echo "<pre>".print_r($value, true)."</pre>";
-                if(!is_array($shortCode)){
-                    $shortCodes[] = $shortCode;
-                }
-            }
-        }
+    public function shortcode_builder_markup_template($shortCodes, $list) {
         //dropdown for shortcode names
-        echo '<div id="categoryContainer" style="overflow: auto">';
+        $this->increase_shortcode_count();
+        echo '<div id="categoryContainer" class="'.$this->get_shortcode_count().'" style="overflow: auto">';
         echo '<div id="shortcodeBuilder">';
         echo '<select id="shortcodeDropdown">
         <option value=""> Select Shortcode </option>';
@@ -513,7 +493,7 @@ return; // Off for now ** Need to make this switchable in management
         
 //      echo '<button id="detailBtn" class="glm-button" type="button"> Show Detail Options </button>';
 
-        echo '<button id="generate" class="button" type="button"> Insert Shortcode </button>';
+        echo '<button id="generate" class="right button" type="button"> Insert Shortcode </button>';
         echo '</div>';
         
         
@@ -521,9 +501,53 @@ return; // Off for now ** Need to make this switchable in management
 
 //        echo '<div id="shortcode_preview_box" style="overflow: auto; clear: both;"><div id="shortcodesTitle">Shortcodes</div></div>';
         echo '</div>';
-
     }
+    // metabox content
+    public function shortcode_builder_markup(){
+
+        require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+        
+        $listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes'];
+        $detailAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-member-detail']['attributes'];
+
+        $glmcat = new GlmDataCategories($this->wpdb, $this->config);
+        $list = $glmcat->getListSortedParentChild();
+        // get the each addOn slugs to pass to the config array later
+        $addOns = $this->config['addOns'];
+        foreach($addOns as $addOn){
+            if(!is_array($addOn['slug'])){
+                $addOnSlugs[] = $addOn['slug'];
+            }
+        }
 
+        // use the addOn slugs to access each of the shortcodes
+        foreach($addOnSlugs as $addOn){
+            if ($this->config['addOns'][$addOn]['shortcodes']) {
+                $shortCodeList[] = $this->config['addOns'][$addOn]['shortcodes'];
+            }
+        }
+
+        // loop through the shortcodes to pull out the shortcode names
+        foreach($shortCodeList as $addonInfo) {
+            foreach($addonInfo as $shortCode=>$value){
+//            echo "<pre>".print_r($value, true)."</pre>";
+                if(!is_array($shortCode)){
+                    $shortCodes[] = $shortCode;
+                }
+            }
+        }
+        
+        // This function when called will auto-increment the shortcode ID
+        $this->shortcode_builder_markup_template($shortCodes, $list);
+        
+        // It should be able to be called several times (once every time the 
+        // additionalShortcode button is clicked), but there are still some 
+        // issues with that. Nice-print conflict..
+        $this->shortcode_builder_markup_template($shortCodes, $list);
+        
+        // This button will add another shortcode editor
+        echo '<button id="additionalShortcode" class="button" type="button"> Configure Additional Shortcode </button>';
+    }
 }
 
 /*