modifying the theme
authorIan Weller <ian@gaslightmedia.com>
Mon, 9 Jan 2017 14:17:53 +0000 (09:17 -0500)
committerIan Weller <ian@gaslightmedia.com>
Mon, 9 Jan 2017 14:17:53 +0000 (09:17 -0500)
I am trying to make the theme more generic.  I removed somethings and
added others.

functions.php
header.php
lib/navigation.php
page.php
parts/off-canvas-menu.php
parts/top-bar.php

index 2d12e7f..e1a7394 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-
+require_once 'lib/menu-walker.php';
+require_once 'lib/navigation.php';
 
 $ancestorId   = null;
 $includePages = array();
@@ -24,123 +25,6 @@ if (!function_exists('glm_quicksite_widget_init')) {
 
 }
 
-
-/**
- * get_menu_options
- *
- * Grab the menu options from the theme.ini file
- */
-function glm_get_menu_options()
-{
-    static $menu_options;
-    $themeConfig = get_template_directory() . '/theme.ini';
-
-    if (!$menu_options && is_file($themeConfig)) {
-        $menu_options = parse_ini_file($themeConfig, true);
-    }
-    return $menu_options;
-}
-
-
-register_nav_menus(array(
-  'top-bar' => 'Site Navigation',
-  //'mobile-off-canvas' => 'Mobile',
-//  'footer' => 'Footer'
-));
-
-if ( ! function_exists( 'michsci_top_bar' ) ) {
-  function michsci_top_bar() {
-      wp_nav_menu(array(
-          'container' => false,                           // remove nav container
-          'container_class' => '',   // class of container
-          
-          'items_wrap' => '<ul id="%1$s" class="%2$s"><li id="logo"><a href="' . get_bloginfo( 'url' ) . '"><img src="'.get_bloginfo('template_url').'/assets/michigan-scientific-logo.png"></a></li>%3$s</ul>',
-          
-          'menu' => '',                                   // menu name
-          'menu_class' => '',                             // adding custom nav class
-          'theme_location' => 'top-bar',                  // where it's located in the theme
-          'before' => '',                                 // before each link <a>
-          'after' => '',                                  // after each link </a>
-          'link_before' => '',                            // before each link text
-          'link_after' => '',                             // after each link text
-                                            // limit the depth of the nav
-          'fallback_cb' => false,                         // fallback function (see below)
-          'walker' => new MichiganSci_Top_Bar_Walker()
-      ));
-  }
-}
-if ( ! class_exists( 'MichiganSci_Top_Bar_Walker()' ) ) :
-class MichiganSci_Top_Bar_Walker extends Walker_Nav_Menu {
-
-       function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
-               $element->has_children = ! empty( $children_elements[ $element->ID ] );
-               $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : '';
-               $element->classes[] = ( $element->has_children && 1 !== $max_depth ) ? 'has-dropdown' : '';
-               $element->classes[] = ( $element->post_parent == 0 && $element->menu_order > 10 ) ? 'drop-right' : 'drop-left';
-               parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
-       }
-    function start_lvl( &$output, $depth = 0, $args = array() ) {
-               $output .= "\n<ul class=\"sub-menu dropdown\">\n";
-       }
-}
-endif;
-
-/**
- * glm_page_menu
- *
- * Grab the top level pages and their sub pages as the main navigation
- */
-function glm_page_menu($parent = 0, $class = '')
-{
-    $menuConfig   = glm_get_menu_options();
-    $frontPageId  = get_option('page_on_front');
-    $parents      = array();
-    $args         = array(
-        'post_type'   => 'page',
-        'parent'      => $parent,
-        'number'      => '',
-        'exclude'     => '',
-        'post_status' => 'publish',
-        'sort_order'  => 'asc',
-        'sort_column' => 'menu_order'
-    );
-    if ($parent == 0 && $menuConfig['menu_options']['main_level_pages']) {
-        $args['include'] = $menuConfig['menu_options']['main_level_pages'];
-    }
-    $pages = get_pages($args);
-    echo '<ul'.(($class)?' class="'.$class.'"':'').'><!-- begin -->'."\n";
-    foreach ($pages as $page) {
-        $childs = get_pages('child_of=' . $page->ID);
-        if (count($childs) > 0) {
-            echo '<li class="has-dropdown">'."\n";
-            echo '<a href="'.get_permalink($page->ID).'">'.$page->post_title.'</a>'."\n";
-            echo glm_page_menu($page->ID, 'sub-menu dropdown');
-            echo '</li>'."\n";
-        } else {
-            echo '<li';
-            if ($page->ID == $frontPageId) {
-                echo ' id="logo"';
-            }
-            echo '><a href="'.get_permalink($page->ID).'">';
-            echo ($page->ID == $frontPageId) ? '<img src="'.get_bloginfo('template_url').'/assets/michigan-scientific-logo.png">': $page->post_title;
-            echo '</a></li>'."\n";
-        }
-    }
-    if ($parent == 0) {
-        echo '<li ';
-        echo 'id="search-icon"';
-        echo '><a href="#">';
-        echo '<img src="'.get_bloginfo('template_url').'/assets/Untitled-2.png">';
-        echo '</a></li>'."\n";
-        echo '<li ';
-        echo  '<form role="search" method="get" action="http://michsci.gaslightmedia.com/">';
-        echo  '<input class="search-input" placeholder="SEARCH" value="" name="s" type="text">';
-        echo '</form>';
-        echo '</li> ';
-    }
-    echo '</ul><!-- end -->'."\n";
-}
-
 /**
  * Return the client info option for the given key
  *
@@ -165,20 +49,7 @@ if (!function_exists('glm_get_clientinfo_option')) {
     }
 }
 
-/**
- * glm_offcanvas_menu
- *
- * Generate the list of pages as nested ul li list
- */
-function glm_offcanvas_menu()
-{
-    wp_page_menu(array(
-        'depth' => 0,
-        'sort_column' => 'menu_order',
-        'menu_class' => 'left-off-canvas-list'
-    ));
-}
-
+add_theme_support('custom-fieldss');
 add_theme_support('post-thumbnails');
 set_post_thumbnail_size(120, 100, true);
 add_image_size('glm-block-thumb', 280, 186, true);
@@ -239,21 +110,7 @@ function glm_get_header() {
 //    echo '</div>';
 
 
-function glm_side_menu() {
-    global $post;
-    $parents = get_post_ancestors($post->ID);
-    $id = ($parents) ? $parents[count($parents)-1]: $post->ID;
-    $parent = get_page( $id );
-    if ($id == 0) {
-        $ID = $post->ID;
-    } else {
-        $ID = $parent->ID;
-    }
-    echo '<h1>'.get_the_title($ID).'</h1>';
-    echo '<ul class="sidebar"><!-- begin -->'."\n";
-    echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
-    echo '</ul><!-- end -->'."\n";
-}
+
 
 
 add_action('wp_enqueue_scripts', 'glm_site_scripts');
index 249bfa9..7afcfe4 100644 (file)
@@ -9,25 +9,25 @@
     <link href='http://fonts.googleapis.com/css?family=Crimson+Text:600italic' rel='stylesheet' type='text/css'>
     <?php wp_head(); ?>
   </head>
-  <body>
+  <body <?php  body_class(  ); ?>>
       <div class="off-canvas-wrap" data-offcanvas>
         <div class="inner-wrap">
                     <header id="top">
                         <div class="row">
-                            <div class="small-11 small-centered text-center columns show-for-medium-down">
-                                <a href="<?php bloginfo('url');?>"><img src="<?php echo get_template_directory_uri(); ?>/assets/michigan-scientific-logo.png"></a>
-                            </div>
-                        </div>
-                        <div class="row collapse sec-nav show-for-medium-up">
-                            <div class="medium-6 columns right">
-                                <ul>
-                                    <li><a href="<?php bloginfo('url'); ?>/jobs">Jobs</a></li>
-                                    <li><a href="<?php bloginfo('url'); ?>/faq">FAQ</a></li>
-                                    <li><a href="<?php bloginfo('url'); ?>/site-map">Site Map</a></li>
-                                    <li class="social"><a target="_blank" href="https://www.facebook.com/MichiganScientificCorporation"><img src="<?php echo get_template_directory_uri(); ?>/assets/facebook-icon.jpg"></a></li>
-                                    <li class="social"><a target="_blank" href="https://www.linkedin.com/company/michigan-scientific-corp"><img src="<?php echo get_template_directory_uri(); ?>/assets/linkedin-icon.jpg"></a></li>
-                                    <li class="social"><a target="_blank" href="https://twitter.com/michsci"><img src="<?php echo get_template_directory_uri(); ?>/assets/twitter-icon.jpg"></a></li>
-                                </ul>
+                            <div class="small-11 small-centered text-center columns">
+                                <?php get_custom_logo($blog_id = 0 );?>
+                                <?php the_custom_logo($blog_id = 0 );?>
+                                <?php
+                                if ( is_front_page() && is_home() ) : ?>
+                                    <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
+                                <?php else : ?>
+                                    <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
+                                <?php endif;
+                                $description = get_bloginfo( 'description', 'display' );
+                                if ( $description || is_customize_preview() ) : ?>
+                                    <h3 class="site-description"><?php echo $description; ?></h3>
+                                <?php endif;
+                                ?>
                             </div>
                         </div>
                         <div class="row collapse">
index c172e80..d18b3f9 100644 (file)
@@ -2,6 +2,7 @@
 
 register_nav_menus(array(
   'top-bar' => 'Site Navigation'
+    
 ));
 
 /**
@@ -71,6 +72,25 @@ if ( ! function_exists( 'glm_theme_footer' ) ) {
   }
 }
 
+/**
+ * Sidebar Nav
+ */
+function glm_side_menu() {
+    global $post;
+    $parents = get_post_ancestors($post->ID);
+    $id = ($parents) ? $parents[count($parents)-1]: $post->ID;
+    $parent = get_page( $id );
+    if ($id == 0) {
+        $ID = $post->ID;
+    } else {
+        $ID = $parent->ID;
+    }
+    echo '<h1>'.get_the_title($ID).'</h1>';
+    echo '<ul class="sidebar"><!-- begin -->'."\n";
+    echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
+    echo '</ul><!-- end -->'."\n";
+}
+
 /**
  * glm_page_menu
  *
@@ -139,19 +159,4 @@ function glm_get_menu_options()
     return $menu_options;
 }
 
-function glm_side_menu() {
-    global $post;
-    $parents = get_post_ancestors($post->ID);
-    $id = ($parents) ? $parents[count($parents)-1]: $post->ID;
-    $parent = get_page( $id );
-    if ($id == 0) {
-        $ID = $post->ID;
-    } else {
-        $ID = $parent->ID;
-    }
-    echo '<h1>'.get_the_title($ID).'</h1>';
-    echo '<ul class="sidebar"><!-- begin -->'."\n";
-    echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
-    echo '</ul><!-- end -->'."\n";
-}
 
index db77f80..88232bc 100644 (file)
--- a/page.php
+++ b/page.php
@@ -1,11 +1,5 @@
 <?php get_header(); ?>
 <main class="page-inside">
-        <?php if (is_page("kitchensink")) {
-    echo '<div class="content-wrapper"><div class="row">';
-    
-        get_template_part('parts/glm-kitchen-sink');
-    echo '</div></div>';
-        } else { ?>
         <div id="content-wrapper">
             <div class="row">
                 <?php
@@ -15,9 +9,9 @@
             <div class="row">
                 <?php echo glm_get_header(); ?>
                 <div id="page-title">
-<!--                    <h1><a href="<?php echo get_permalink(510) ?>"> <?php echo get_the_title(); ?></a></h1>-->
+<!--                    <h1><a href="<?php //echo get_permalink(510) ?>"> <?php //echo get_the_title(); ?></a></h1>-->
                 </div>
-   <div id="main-content" class="small-12 columns">   
+                <div id="main-content" class="small-12 columns">   
                                  
                         <?php if(have_posts()) : while(have_posts()): the_post();?>
       
@@ -30,5 +24,4 @@
                 </div>
             </div>
         </div>
-        <?php } ?> <!-- end kitchensink check - delete me before going live -->
 <?php get_footer(); ?>
index 2614219..c9f9451 100644 (file)
@@ -1,18 +1,4 @@
 <aside class="left-off-canvas-menu hide-for-large-up">
     <?php glm_offcanvas_menu(); ?>
-    <form role="search" method="get" id="formsearch" action="<?php echo home_url('/'); ?>">
-        <input class="search-input" type="search" placeholder="SEARCH" value="" name="s" id="off-search">
-        <input type="submit" class="button" name="submit" value="Search">
-    </form>
-    <ul class="off-nav-sec">
-        <li><a href="<?php bloginfo('url'); ?>/jobs">Jobs</a></li>
-        <li><a href="<?php bloginfo('url'); ?>/faq">FAQ</a></li>
-        <li><a href="<?php bloginfo('url'); ?>/site-map">Site Map</a></li>
-    </ul>
-    <ul class="offcavas-social-list">
-        <li class="social"><a target="_blank" href="https://www.facebook.com/MichiganScientificCorporation"><img src="<?php echo get_template_directory_uri(); ?>/assets/facebook-icon.jpg"></a></li>
-        <li class="social"><a target="_blank" href="https://www.linkedin.com/company/michigan-scientific-corp"><img src="<?php echo get_template_directory_uri(); ?>/assets/linkedin-icon.jpg"></a></li>
-        <li class="social"><a target="_blank" href="https://twitter.com/michsci"><img src="<?php echo get_template_directory_uri(); ?>/assets/twitter-icon.jpg"></a></li>
-    </ul>
     <?php get_template_part('parts/client-info-offcanvas');?>
 </aside>
index 21dff7b..c5ee3b1 100644 (file)
@@ -1,6 +1,6 @@
 <nav class="top-bar text-center show-for-large-up" data-topbar role="navigation">
     <section class="top-bar-section">
-        <?php michsci_top_bar(); 
+        <?php glm_theme_top_bar(); 
          ?>
     </section>
 </nav>