updating to meet the new standard
authorIan Weller <ian@gaslightmedia.com>
Wed, 22 Feb 2017 15:11:29 +0000 (10:11 -0500)
committerIan Weller <ian@gaslightmedia.com>
Wed, 22 Feb 2017 15:11:29 +0000 (10:11 -0500)
I am updating bits and pieces of the theme to be up to date with how we
are doing it now.  It's expected since it was one of our first WordPress
sites.

functions.php
header.php
lib/menu-walker.php [new file with mode: 0644]
lib/navigation.php [new file with mode: 0644]
parts/slide-show.php [new file with mode: 0644]
style.css

index ab2f4e6..4a51681 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-
+require_once 'lib/menu-walker.php';
+require_once 'lib/navigation.php';
 
 $ancestorId   = null;
 $includePages = array();
@@ -15,6 +16,11 @@ if (!function_exists('glm_quicksite_widget_init')) {
             'id'          => 'sidebar-l',
             'description' => __('Appears in Left Sidebar')
         ));
+        register_sidebar(array(
+            'name'        => __('Slideshow'),
+            'id'          => 'slideshow',
+            'description' => __('Slideshow/Meta Slider')
+        ));
         register_sidebar(array(
             'name'        => __('Footer'),
             'id'          => 'sidebar-f',
index 73716c4..8035179 100644 (file)
@@ -4,8 +4,8 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title><?php wp_title(); ?></title>
-    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/app.css?v=1.2.34">
-      <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico">
+    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/app.css">
+<!--      <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico">-->
     <link href='//fonts.googleapis.com/css?family=Balthazar' rel='stylesheet' type='text/css'>
        <?php wp_head();?>
   </head>
                 <header id="page-header">
                     <div class="row">
                         <div class="small-12 medium-4 columns text-center">
-                            <a id="logo" class="text-center" href="<?php bloginfo('url');?>"><img src="<?php bloginfo('template_url'); ?>/assets/logo.png"></a>
+                            <a id="logo" class="text-center" href="<?php bloginfo('url');?>"></a>
                         </div>
                         <div class="small-12 medium-8 columns right">
+<!--
                             <div class="small-12 large-8 columns show-for-medium-up">
                                 <nav class="sec-nav">
                                     <ul>
-                                        <li><a href="<?php echo esc_url( get_permalink( '39' ) ); ?>">Volunteer/Careers</a></li>
-                                        <li><a href="<?php echo esc_url( get_permalink( '41' ) ); ?>">Donate</a></li>
-                                        <li><a href="<?php echo esc_url( get_permalink( '43' ) ); ?>">Media</a></li>
-                                        <li><a href="<?php echo esc_url( get_permalink( '45' ) ); ?>">Contact</a></li>
+                                        <li><a href="<?php echo esc_url( //get_permalink( '39' ) ); ?>">Volunteer/Careers</a></li>
+                                        <li><a href="<?php echo esc_url( //get_permalink( '41' ) ); ?>">Donate</a></li>
+                                        <li><a href="<?php echo esc_url( //get_permalink( '43' ) ); ?>">Media</a></li>
+                                        <li><a href="<?php echo esc_url( //get_permalink( '45' ) ); ?>">Contact</a></li>
                                     </ul>
                                 </nav>
                             </div>
+-->
                             <div class="small-4 columns show-for-large-up social-top">
+<!--
                                 <div id="soc-top">
-                                    <?php get_template_part('parts/social');?>
+                                    <?php //get_template_part('parts/social');?>
                                 </div>
+-->
                                 <div class="search-top">
                                     <?php get_template_part('parts/search');?>
                                 </div>
diff --git a/lib/menu-walker.php b/lib/menu-walker.php
new file mode 100644 (file)
index 0000000..c9773bb
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/**
+ * Customize the output of menus for Foundation top bar
+ */
+if ( ! class_exists( 'Glm_Theme_Top_Bar_Walker' ) ) :
+class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu {
+    function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
+        static $mainLevelCounter;
+        if ($depth == 0) {
+            ++$mainLevelCounter;
+        }
+        $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 && $mainLevelCounter < 5 ) ? '' : 'drop-left parent';
+        parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+    }
+
+    function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
+        $item_html = '';
+        parent::start_el( $item_html, $object, $depth, $args );
+
+        // Insert style to display page's thumbnail $depth == 0 && has_post_thumbnail((int)$object->object_id
+        $item_style = '';
+//        echo "<pre>", print_r($object), "</pre>";
+        /*if ( $depth !== 0 && has_post_thumbnail( (int)$object->object_id ) ) {
+             $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( (int)$object->object_id ), 'large' );
+            
+            $item_style .= "<style>
+            #menu-item-".$object->ID.":before { 
+            display: inline-block;
+            width: 200px; 
+            height: 100px; 
+            content: ' '; 
+            background-image: url('".$thumbnail[0]."');
+            background-size: cover;
+            </style>";
+            
+        } else if( $depth !== 0 && $object->type == "taxonomy") { 
+            
+            //$thumbnail = z_taxonomy_image_url( (int)$object->object_id );
+
+            $item_style .= "<style>
+            #menu-item-".$object->ID.":before { 
+            display: inline-block;
+            width: 200px; 
+            height: 100px; 
+            content: ' '; 
+            background-image: url('".$thumbnail."');
+            background-size: cover;
+            </style>";
+            
+        } else if( $depth !== 0 && ! has_post_thumbnail( (int)$object->object_id ) ){
+            
+            $thumbnail = get_template_directory_uri() . '/assets/header-images-2.jpg';
+            $item_style .= "<style>
+            #menu-item-".$object->ID.":before { 
+            display: inline-block;
+            width: 200px; 
+            height: 100px; 
+            content: ' '; 
+            background-image: url('".$thumbnail."');
+            background-size: cover;
+            </style>";
+        }
+        */
+        //$output .= ( 0 == $depth ) ? '<li class="divider"></li>' : '';
+        $classes = empty( $object->classes ) ? array() : (array) $object->classes;
+        if ( in_array( 'label', $classes ) ) {
+            //$output .= '<li class="divider"></li>';
+            $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '<label>$1</label>', $item_html );
+        }
+        if ( in_array( 'divider', $classes ) ) {
+            $item_html = preg_replace( '/<a[^>]*>( .* )<\/a>/iU', '', $item_html );
+        }
+        if ($item_style)
+            $output .= $item_style;
+        $output .= $item_html;
+    }
+
+    function start_lvl( &$output, $depth = 0, $args = array() ) {
+        $output .= "\n<ul class=\"sub-menu dropdown\">\n";
+    }
+}
+endif;
+if ( ! class_exists( 'Glm_Theme_Off_Canvas_Walker' ) ) :
+class Glm_Theme_Off_Canvas_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 ) ? 'page_item_has_children' : '';
+        $element->classes[] = 'page_item';
+
+        parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+    }
+
+    function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
+        $item_html = '';
+        parent::start_el( $item_html, $object, $depth, $args );
+
+        $classes = empty( $object->classes ) ? array() : (array) $object->classes;
+
+        if ( in_array( 'label', $classes ) ) {
+            $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '<label>$1</label>', $item_html );
+        }
+
+        $output .= $item_html;
+    }
+
+    function start_lvl( &$output, $depth = 0, $args = array() ) {
+        $output .= "\n<ul class=\"children\">\n";
+    }
+
+    function end_lvl(&$output, $depth = 0, $args = array()){
+        $output .= '</ul>';
+    }
+}
+endif;
+?>
diff --git a/lib/navigation.php b/lib/navigation.php
new file mode 100644 (file)
index 0000000..0f60bfc
--- /dev/null
@@ -0,0 +1,167 @@
+<?php
+
+register_nav_menus(array(
+  'top-bar' => 'Site Navigation',
+  'footer'  => 'Footer Navigation',
+  'second-header' => 'Secondary Header Navigation'     
+));
+
+/**
+ * Top Bar
+ */
+if ( ! function_exists( 'glm_theme_top_bar' ) ) {
+  function glm_theme_top_bar() {
+      wp_nav_menu(array(
+          'container' => false,                           // remove nav container
+          'container_class' => '',                        // class of container
+          '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
+          'depth' => 3,                                   // limit the depth of the nav
+          'fallback_cb' => false,                         // fallback function (see below)
+          'walker' => new Glm_Theme_Top_Bar_Walker()
+      ));
+  }
+}
+
+/**
+ * Mobile off-canvas
+ */
+if ( ! function_exists( 'glm_theme_mobile_off_canvas' ) ) {
+    function glm_theme_mobile_off_canvas() {
+        echo '<div class="left-off-canvas-list">';
+        echo '<ul><li class="page_item"><a href="' . home_url() . '">Home</a></li>';
+        echo glm_get_mobile_nav_menu( 'top-bar' );
+        echo '</ul></div>';
+    }
+}
+
+function glm_get_mobile_nav_menu( $theme_location )
+{
+    $menu = wp_nav_menu(array(
+        'echo'            => false,             // don't echo
+        'container'       => false,             // remove nav container
+        'container_class' => '',                // class of container
+        'menu'            => '',                // menu name
+        'menu_class'      => 'off-canvas-list', // adding custom nav class
+        'theme_location'  => $theme_location,       // 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
+        'depth'           => 5,                 // limit the depth of the nav
+        'fallback_cb'     => false,             // fallback function (see below)
+        'walker'          => new Glm_Theme_Off_Canvas_Walker()
+    ));
+    return preg_replace( array( '%^<ul[^>]*>%', '%</ul>$%' ), '', $menu );
+}
+
+/**
+ * Footer
+ */
+if ( ! function_exists( 'glm_theme_footer' ) ) {
+  function glm_theme_footer() {
+      wp_nav_menu(array(
+          'container' => false,                           // remove nav container
+          'container_class' => '',                        // class of container
+          'menu' => '',                                   // menu name
+          'menu_class' => '',                             // adding custom nav class
+          'theme_location' => 'footer',                   // 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
+          'depth' => 1,                                   // limit the depth of the nav
+          'fallback_cb' => false,                         // fallback function (see below)
+      ));
+  }
+}
+
+/**
+ * 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'     => $frontPageId,
+        '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><a href="'.get_permalink($page->ID).'">'.$page->post_title.'</a></li>'."\n";
+        }
+    }
+    echo '</ul><!-- end -->'."\n";
+}
+
+/**
+ * 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'
+    ));
+}
+
+/**
+ * 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;
+}
+
+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";
+}
+
diff --git a/parts/slide-show.php b/parts/slide-show.php
new file mode 100644 (file)
index 0000000..e6cc3b0
--- /dev/null
@@ -0,0 +1,9 @@
+<?php if (is_front_page()) : ?>
+       <div class="slider">
+        <?php echo do_shortcode("[metaslider id=638]") ?>
+        <?php echo do_shortcode("[metaslider id=609]") ?>
+            <?php if ( is_active_sidebar( 'slideshow' ) ) : ?>
+               <?php dynamic_sidebar( 'slideshow' ); ?>
+            <?php endif; ?>
+       </div>
+<?php endif; ?>
\ No newline at end of file
index c66ead5..7e0b1d9 100644 (file)
--- a/style.css
+++ b/style.css
@@ -1,7 +1,7 @@
 /*
-Theme Name: Gilmore Car Museum
+Theme Name: Generic Gilmore Car Museum
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
-Description: A theme created for Gilmore Car Museum.
-Version: 1.2.37
+Description: A generic theme based off of Gilmore Car Museum.
+Version: 1.0
 */