rework quicksite plugin
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 17:20:36 +0000 (12:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 17:20:36 +0000 (12:20 -0500)
create widget areas for the theme
this will allow the plugin itself to be a widget
and not have hard coded plugin stuff in the theme

footer.php
functions.php
sidebar.php

index 0f8b77c..5f7322a 100644 (file)
@@ -1,5 +1,7 @@
                     <footer class="small-6 show-for-small-only small-centered columns">
-                        <?php get_template_part('vcard');?>
+                        <?php if (is_active_sidebar('sidebar-f')) :?>
+                            <?php dynamic_sidebar('sidebar-f');?>
+                        <?php endif;?>
                     </footer>
                     <div id="copyright">
                         Copyright&copy;<?php echo date('Y');?> <?php bloginfo('name');?> - Produced by <a href="http://www.gaslightmedia.com">Gaslight Media</a>, All Rights Reserved.
index 9a303ab..f61b12d 100644 (file)
@@ -1,20 +1,30 @@
 <?php
-if (!function_exists('glmAddSubs')) {
-    $ancestorId   = null;
-    $includePages = array();
-    $frontPageId  = get_option('page_on_front');
-    function glm_get_quicksite_option($name)
+
+$ancestorId   = null;
+$includePages = array();
+$frontPageId  = get_option('page_on_front');
+add_action('widgets_init', 'glm_quicksite_widget_init');
+
+if (!function_exists('glm_quicksite_widget_init')) {
+
+    function glm_quicksite_widget_init()
     {
-        $settings = get_option('glmQuickSite_settings');
-        $states   = get_option('glmQuickSite_states');
-        if ($name == 'stateFull' && $settings['state']) {
-            return $states[$settings['state']];
-        }
-        if ($name == 'state2Full' && $settings['state2']) {
-            return $states[$settings['state2']];
-        }
-        return ($settings && $settings[$name]) ? $settings[$name]: null;
+        register_sidebar(array(
+            'name'        => __('Left Sidebar'),
+            'id'          => 'sidebar-l',
+            'description' => __('Appears in Left Sidebar')
+        ));
+        register_sidebar(array(
+            'name'        => __('Footer'),
+            'id'          => 'sidebar-f',
+            'description' => __('Appears in Footer Area')
+        ));
     }
+
+}
+
+if (!function_exists('glm_wp_list_pages')) {
+
     function glm_wp_list_pages()
     {
         global $ancestorId, $includePages, $post;
@@ -33,6 +43,10 @@ if (!function_exists('glmAddSubs')) {
             )
         );
     }
+
+}
+if (!function_exists('glmAddSubs')) {
+
     function glmAddSubs()
     {
         global $includePages, $post;
@@ -41,40 +55,52 @@ if (!function_exists('glmAddSubs')) {
             $includePages[] = $page->ID;
         }
     }
+
+}
+if (!function_exists('glmAddDescendants')) {
+
     function glmAddDescendants($glmPost)
     {
         global $includePages, $frontPageId, $ancestorId;
         if ($glmPost->ID != $frontPageId) {
             $includePages[] = "{$glmPost->ID}";
-            $ancestorId = $glmPost->ID;
-            $descendants = get_pages(array('child_of' => $ancestorId));
+            $ancestorId     = $glmPost->ID;
+            $descendants    = get_pages(array('child_of' => $ancestorId));
         } else {
             $ancestorId = $frontPageId;
         }
 
         if (isset($descendants) && $descendants) {
             foreach ($descendants as $page) {
-               if (($page->post_parent == $ancestorId) &&
-                   ($page->post_parent == $glmPost->ID))
-               {
+                if (($page->post_parent == $ancestorId) &&
+                    ($page->post_parent == $glmPost->ID)) {
                     $includePages[] = $page->ID;
                 }
             }
         }
     }
+
+}
+if (!function_exists('glmAddParent')) {
+
     function glmAddParent($glmPost)
     {
         global $includePages, $frontPageId, $ancestorId;
         $includePages[] = "{$glmPost->post_parent}";
-        $parents = get_post_ancestors($glmPost->ID);
+        $parents        = get_post_ancestors($glmPost->ID);
         foreach ($parents as $page) {
             $includePages[] = $page;
         }
     }
+
+}
+if (!function_exists('glmAddSiblings')) {
+
     function glmAddSiblings($glmPost)
     {
         global $includePages, $frontPageId, $ancestorId;
         glmAddDescendants(get_post($glmPost->post_parent));
     }
+
 }
 ?>
index 99284e4..7b94074 100644 (file)
                            <?php glm_wp_list_pages();?>
                         </ul>
                         </div>
-                        <?php get_template_part('vcard');?>
+                        <?php if (is_active_sidebar('sidebar-l')) :?>
+                            <?php dynamic_sidebar('sidebar-l');?>
+                        <?php endif;?>
                     </div><!-- /#column -->
                     <aside class="left-off-canvas-menu">
                         <ul class="off-canvas-list">
                             <?php wp_nav_menu(array('menu_class' => ''));?>
                         </ul>
-                        <?php get_template_part('vcard');?>
+                        <?php if (is_active_sidebar('sidebar-l')) :?>
+                            <?php dynamic_sidebar('sidebar-l');?>
+                        <?php endif;?>
                     </aside> <!-- left-off-canvas-menu -->