Updating shortcode builder tool.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 12 May 2017 16:15:40 +0000 (12:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 12 May 2017 16:16:47 +0000 (12:16 -0400)
Don't show the shortcode builder if member aren't enabled.
Getting rid of an error because no count variable was set for the
shortcode. Now passing this into the template.

models/admin/pages/shortcode.php
setup/adminHooks.php

index 3d4dd01..675c105 100644 (file)
@@ -118,6 +118,9 @@ class GlmMembersAdmin_pages_shortcode
     {
         $success    = true;
         $categories = array();
+        $amenGroups = array();
+        $shortCodes = array();
+        $regions = array();
 
         // 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' ) ){
@@ -197,10 +200,11 @@ class GlmMembersAdmin_pages_shortcode
 
         // Compile template data
         $templateData = array(
-            'categories' => $categories,
-            'amenGroups' => $amenGroups,
-            'shortCodes' => $shortCodes,
-            'regions'    => $regions
+            'categories'      => $categories,
+            'amenGroups'      => $amenGroups,
+            'shortCodes'      => $shortCodes,
+            'regions'         => $regions,
+            'shortcode_count' => $this->get_shortcode_count()
         );
 
         // Return status, suggested view, and data to controller
index 26bc68c..6a7ad5f 100644 (file)
@@ -87,18 +87,21 @@ if(!empty($locations))
 }
 
 add_action( 'add_meta_boxes', function() {
-    function custom_js_css() {
-        wp_enqueue_script('your-meta-box', GLM_MEMBERS_PLUGIN_URL. '/js/shortcodeBuilder.js', array('jquery'), null, true);
+    global $config;
+    if ( isset( $config['settings']['enable_members'] ) && $config['settings']['enable_members'] ) {
+        function custom_js_css() {
+            wp_enqueue_script('your-meta-box', GLM_MEMBERS_PLUGIN_URL. '/js/shortcodeBuilder.js', array('jquery'), null, true);
+        }
+        add_action('admin_print_styles-post.php', 'custom_js_css' );
+        add_action('admin_print_styles-post-new.php', 'custom_js_css' );
+        add_meta_box("shortcode_builder",
+            "Associate Shortcode Builder",
+                function() {
+                    $this->controller( 'pages', 'shortcode' );
+                },
+            "page", 'normal', 'high'
+        );
     }
-    add_action('admin_print_styles-post.php', 'custom_js_css' );
-    add_action('admin_print_styles-post-new.php', 'custom_js_css' );
-    add_meta_box("shortcode_builder",
-        "Associate Shortcode Builder",
-            function() {
-                $this->controller( 'pages', 'shortcode' );
-            },
-        "page", 'normal', 'high'
-    );
 } );
 
 // Some menu related tests and changes