Update the blocks for theme
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Nov 2016 21:25:21 +0000 (17:25 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 1 Nov 2016 21:25:21 +0000 (17:25 -0400)
Updating the block section so it can be used to call as a function.

functions.php
parts/glm-blocks.php
sections/footer.php
sections/front-page.php

index 5b98ff4..9e27dc5 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 require_once 'lib/menu-walker.php';
 require_once 'lib/navigation.php';
+require_once 'parts/glm-blocks.php';
 
 $ancestorId   = null;
 $includePages = array();
index 2f8cd0c..369826a 100644 (file)
@@ -1,39 +1,34 @@
-<?php if(function_exists('fetch_all_glm_blocks')):?>
 <?php
-$post_id = ($post->ID);
-switch ($post_id) {
-case 'partners':
-    $defaultBlockGroup = PARTNERS_BLOCKS;
-    break;
-default:
-    $defaultBlockGroup = DEFAULT_BLOCKS;
-    break;
+if ( !function_exists( 'glm_blocks_per_section' ) ) {
+    function glm_blocks_per_section( $section ) {
+        if ( function_exists( 'fetch_all_glm_blocks' ) ) {
+            $blocks = fetch_all_glm_blocks( $section );
+            ?>
+            <div class="blocks">
+                <?php foreach ($blocks as $block):?>
+                <div class="text-center small-12 medium-4 columns large-text-left block">
+                        <?php if($block->url):?>
+                        <a href="<?php echo $block->url;?>"<?php if($block->externalUrl){echo ' target="_blank"';}?>>
+                        <?php endif;?>
+                        <?php echo get_the_post_thumbnail($block->ID, 'glm-block-image');?>
+                        <?php if($block->url):?>
+                        </a>
+                        <?php endif;?>
+                        <?php if($block->url):?>
+                        <a class="title-posts" href="<?php echo $block->url;?>"<?php if($block->externalUrl){echo ' target="_blank"';}?>>
+                        <?php endif;?>
+                            <h3><?php echo $block->post_title;?></h3>
+                        <?php if($block->url):?>
+                        </a>
+                         <?php endif;?>
+                    <p><?php echo apply_filters('the_content', $block->post_content) . $block->post_excerpt;?></p>
+                    <?php if($block->url):?>
+                    <a class="blocks-readmore" href="<?php echo $block->url;?>"></a>
+                    <?php endif;?>
+                </div>
+                <?php endforeach;?>
+            </div>
+            <?php
+        }
+    }
 }
-?>
-<?php $blocks = fetch_all_glm_blocks($defaultBlockGroup);?>
-<div class="blocks">
-    <?php foreach ($blocks as $block):?>
-    <div class="text-center small-12 medium-4 columns large-text-left block">
-            <?php if($block->url):?>
-            <a href="<?php echo $block->url;?>"<?php if($block->externalUrl){echo ' target="_blank"';}?>>
-            <?php endif;?>
-            <?php echo get_the_post_thumbnail($block->ID, 'glm-block-image');?>
-            <?php if($block->url):?>
-            </a>
-            <?php endif;?>
-            <?php if($block->url):?>
-            <a class="title-posts" href="<?php echo $block->url;?>"<?php if($block->externalUrl){echo ' target="_blank"';}?>>
-            <?php endif;?>
-                <h3><?php echo $block->post_title;?></h3>
-            <?php if($block->url):?>
-            </a>
-             <?php endif;?>
-        <p><?php echo apply_filters('the_content', $block->post_content) . $block->post_excerpt;?></p>
-        <?php if($block->url):?>
-        <a class="blocks-readmore" href="<?php echo $block->url;?>"></a>
-        <?php endif;?>
-    </div>
-    <?php endforeach;?>
-</div>
-<!--<div class="separator"><hr></div>-->
-<?php endif;?>
index 9607795..1594e78 100644 (file)
@@ -1,9 +1,7 @@
                         <div id="partners">
                             <div class="row">
                                 <h2>Discover The Possibilities</h2>
-                                <?php
-                                get_template_part('parts/glm-blocks');
-                                ?>
+                                <?php glm_blocks_per_section( PARTNERS_BLOCKS ); ?>
                             </div>
                         </div>
                         <div id="background-bottom">
@@ -75,7 +73,7 @@
                                                     <?php endif;?>
                                                 </div>
                                             </div>
-                                            
+
                                         </div>
                                         <div class="medium-2 columns show-for-medium-up">
                                             <ul class="social">
@@ -85,6 +83,6 @@
                                         </div>
                                     </div>
                                 </div>
-                                
+
                             </div>
-                        </footer>
\ No newline at end of file
+                        </footer>
index 5edadc3..dd48432 100644 (file)
@@ -3,9 +3,7 @@
                         <div id="content-wrapper">
                             <div id="blocks-row">
                                 <div class="row">
-                                    <?php
-                                    get_template_part('parts/glm-blocks');
-                                    ?>
+                                    <?php glm_blocks_per_section( DEFAULT_BLOCKS ); ?>
                                 </div>
                             </div>
                             <div class="row">
@@ -17,4 +15,4 @@
 
                             </div>
                         </div>
-                    </main>
\ No newline at end of file
+                    </main>