fixing blog setup page
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 18 Jun 2018 20:48:10 +0000 (16:48 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 18 Jun 2018 20:48:10 +0000 (16:48 -0400)
content-page.php
functions.php
home-page.php
inc/blog.php [deleted file]
inc/panel.php [new file with mode: 0644]
index-parallax.php
index.php

index 5ead1ec..31c7345 100644 (file)
@@ -5,7 +5,7 @@
  * @package accesspress_parallax
  */
 ?>
-
+LOLOL
 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header class="entry-header">
                <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
index cec3642..20abc00 100644 (file)
@@ -209,7 +209,7 @@ add_action( 'wp_enqueue_scripts', 'accesspress_parallax_scripts' );
  * Implement the rooms feature.
  */
 require get_template_directory() . '/inc/rooms.php';
-require get_template_directory() . '/inc/blog.php';
+require get_template_directory() . '/inc/panel.php';
 require get_template_directory() . '/inc/parallax.php';
 /**
  * Implement the Custom Header feature.
index 55074c6..bb029b3 100644 (file)
@@ -19,7 +19,6 @@ get_header();
                $category = $section['category']; 
                $googlemapclass = $layout == "googlemap_template" ? " google-map" : "";
        ?>
-  
        <?php if(!empty($section['page'])): ?>
                <section class="parallax-section clearfix<?php echo esc_attr($googlemapclass)." ".esc_attr($layout);  ?>" id="<?php echo "section-".absint($page->ID); ?>">
                <?php if(!empty($image) && $overlay!="overlay0") : ?>
diff --git a/inc/blog.php b/inc/blog.php
deleted file mode 100644 (file)
index 55eaaa6..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-<?php
-/**
- * Plugin Name: Panel Posts
- * Plugin URI:
- * Description: Gaslight Media Catalog Plugin
- * Version: 0.0.1
- * Author: Steve Sutton <steve@gaslightmedia.com>
- * Author URI:
- * License: GPLv2
- **/
-
-define( 'GLM_PANEL_POST_TYPE', 'glm-panel' );
-define( 'GLM_PANEL_SINGLE', 'Panel' );
-define( 'GLM_PANEL_PLURAL', 'Panel Posts' );
-define( 'GLM_PANEL_CATEGORY_NAME', 'panel_category' );
-define( 'GLM_PANEL_CATEGORY_SLUG', 'panel-posts-category' );
-define( 'GLM_PANEL_CATEGORY_SINGLE', 'Panel Type' );
-define( 'GLM_PANEL_CATEGORY_PLURAL', 'Panel Types' );
-
-// Register Custom Post Type.
-/**
- * Panel Posts_custom_post_type
- *
- * Setup of the Wordpress Custom Post Type
- *
- * @access public
- * @return void
- */
-function panels_custom_post_type() {
-
-    $labels = array(
-        'name'                  => _x( GLM_PANEL_PLURAL, 'Post Type General Name' ),
-        'singular_name'         => _x( GLM_PANEL_SINGLE, 'Post Type Singular Name' ),
-        'menu_name'             => __( GLM_PANEL_PLURAL ),
-        'name_admin_bar'        => __( GLM_PANEL_PLURAL ),
-        'archives'              => __( GLM_PANEL_SINGLE . ' Archives' ),
-        'parent_item_colon'     => __( 'Parent Panel Post:' ),
-        'all_items'             => __( 'All Panel Posts' ),
-        'add_new_item'          => __( 'Add New Panel Post' ),
-        'add_new'               => __( 'Add New' ),
-        'new_item'              => __( 'New Panel Post' ),
-        'edit_item'             => __( 'Edit Panel' ),
-        'update_item'           => __( 'Update Panel' ),
-        'view_item'             => __( 'View Panel Post' ),
-        'search_items'          => __( 'Search Panel Posts' ),
-        'not_found'             => __( 'Not found' ),
-        'not_found_in_trash'    => __( 'Not found in Trash' ),
-        'featured_image'        => __( 'Featured Image' ),
-        'set_featured_image'    => __( 'Set featured image' ),
-        'remove_featured_image' => __( 'Remove featured image' ),
-        'use_featured_image'    => __( 'Use as featured image' ),
-        'insert_into_item'      => __( 'Insert into item' ),
-        'uploaded_to_this_item' => __( 'Uploaded to this item' ),
-        'items_list'            => __( 'Panel Posts list' ),
-        'items_list_navigation' => __( 'Panel Posts list navigation' ),
-        'filter_items_list'     => __( 'Filter items list' ),
-    );
-
-    $rewrite = array(
-        'slug'                  => GLM_PANEL_POST_TYPE,
-        'with_front'            => false,
-        'pages'                 => false,
-        'feeds'                 => false,
-    );
-
-    $args = array(
-        'label'                 => __( GLM_PANEL_SINGLE ),
-        'description'           => __( 'Custom ' . GLM_PANEL_PLURAL ),
-        'labels'                => $labels,
-        'supports'              => array( 'title', 'thumbnail', 'revisions', 'editor', 'author'),
-        'hierarchical'          => true,
-        'public'                => true,
-        'show_ui'               => true,
-        'show_in_menu'          => true,
-        'menu_position'         => 5,
-        'menu_icon'             => 'dashicons-testimonial',
-        'show_in_admin_bar'     => true,
-        'show_in_nav_menus'     => true,
-        'can_export'            => true,
-        'has_archive'           => true,
-        'exclude_from_search'   => false,
-        'publicly_queryable'    => true,
-        'rewrite'               => $rewrite,
-        'capability_type'       => 'page',
-        'register_meta_box_cb'  => 'panels_add_metaboxes',
-    );
-
-    register_post_type( GLM_PANEL_POST_TYPE, $args );
-    register_taxonomy_for_object_type( GLM_PANEL_CATEGORY_NAME, GLM_PANEL_POST_TYPE );
-}
-
-/**
- * Panel Posts_add_metaboxes
- *
- * Add the meta fields
- *
- * @access public
- * @return void
- */
-function panels_add_metaboxes() {
-
-//    add_meta_box( 'panels_tents', 'Tents', 'panels_tents', GLM_PANEL_POST_TYPE, 'side', 'low' );
-}
-
-/**
- * Panel Posts_water
- *
- * Add field for the water availability
- *
- * @access public
- * @return void
- */
-function panels_water() {
-    global $post;
-    $checked = '';
-    // Get the features for the post.
-    $water = get_post_meta( $post->ID, 'panels_water', true );
-    
-    // Output field.
-    if ( 'yes' === $water ) {
-        $checked = 'checked="checked"';
-    }
-    ?>
-<input type="checkbox" name="panels_water" value="yes" <?php echo $checked; ?> />
-    <?php
-
-}
-/**
- * Panel Posts_tents
- *
- * Add field for the water availability
- *
- * @access public
- * @return void
- */
-//function panels_tents() {
-//    global $post;
-//
-//    // Get the features for the post.
-//    $tents = get_post_meta( $post->ID, 'panels_tents', true );
-//    
-//    // Output field.
-//    if ( 'yes' === $tents ) {
-//        $checked = 'checked="checked"';
-//    }
-//    
-
-   
-//
-//}
-/**
- * Panel Posts_loop
- *
- * Add field for the loop
- *
- * @access public
- * @return void
- */
-function panels_loop() {
-    global $post;
-    $value = '';
-    // Noncename needed to verify where the data originated.
-    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
-    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-loop" value="' . $nonce . '" />';
-
-    // Get the features for the post.
-    $loop = get_post_meta( $post->ID, 'panels_loop', true );
-    // Output field.
-    if ( !empty( $loop ) ) {
-        $value = "value=".'"'.$loop .'"';
-    }
-
-    ?>
-    <input type="text" name="panels_loop" <?php echo $value; ?> />
-    <?php
-
-}
-
-/**
- * Panel Posts_sewer
- *
- * Adds the field for sewer availibility
- *
- * @access public
- * @return void
- */
-function panels_sewer() {
-    global $post;
-    $checked = '';
-    // Noncename needed to verify where the data originated.
-    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
-    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-sewer" value="' . $nonce . '" />';
-    // Get the features for the post.
-    $sewer = get_post_meta( $post->ID, 'panels_sewer', true );
-
-    // Output field.
-    if ( "yes" === $sewer ) {
-        $checked = 'checked="checked"';
-    }
-
-    ?>
-    <input type="checkbox" name="panels_sewer" value="yes" <?php echo $checked; ?> />
-    <?php
-
-}
-/**
- * Panel Posts_campers
- *
- * Adds the field for camper types
- *
- * @access public
- * @return void
- */
-function panels_campers() {
-    global $post;
-
-    // Get the features for the post.
-    $campers = get_post_meta( $post->ID, 'panels_campers', true );
-    
-    // Output field.
-    if ( !empty( $campers ) ) {
-        $value = "value=".'"'.$campers .'"';
-    }
-    ?>
-    <input type="text" name="panels_campers" <?php echo $value; ?> />
-    <?php
-}
-/**
- * Panel Posts_power
- *
- * Adds the field for power availability
- * @access public
- * @return void
- */
-function panels_power() {
-    global $post;
-    $value = '';
-    // Noncename needed to verify where the data originated.
-    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
-    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-power" value="' . $nonce . '" />';
-
-    // Get the features for the post.
-    $power = get_post_meta( $post->ID, 'panels_power', true );
-    // Output field.
-    if ( !empty( $power ) ) {
-        $value = "value=".'"'.$power .'"';
-    }
-
-    ?>
-    <input type="text" name="panels_power" <?php echo $value; ?> />
-    <?php
-}
-
-/**
- * Panel Posts_save_meta
- *
- * Saves the meta fields for the product
- *
- * @access public
- * @return void
- */
-function panels_save_meta() {
-    global $post;
-    if ( ! wp_verify_nonce( $_POST['panelsmeta-meta-noncename'], 'panelsmeta-meta-noncename' ) ) {
-        return $post->ID;
-    }
-    if ( ! current_user_can( 'edit_post', $post->ID ) ) {
-        return $post->ID;
-    }
-    $water         = (isset($_POST['panels_water']) ? filter_var( $_POST['panels_water'] ) : '' );
-    $sewer         = (isset($_POST['panels_sewer']) ? filter_var( $_POST['panels_sewer'] ) : '' );
-    $power         = (isset($_POST['panels_power']) ? filter_var( $_POST['panels_power'] ) : '' );
-    $loop          = (isset($_POST['panels_loop']) ? filter_var( $_POST['panels_loop'] ) : '' );
-//    $tents          = filter_var( $_POST['panels_tents'] );
-    update_post_meta( $post->ID, 'panels_water', $water );
-    update_post_meta( $post->ID, 'panels_sewer', $sewer );
-    update_post_meta( $post->ID, 'panels_power', $power );
-    update_post_meta( $post->ID, 'panels_loop', $loop );
-//    update_post_meta( $post->ID, 'panels_tents', $tents );
-}
-/**
- * panels_taxonomies
- *
- * Setup of the Taxonomies for the post type
- *
- * @access public
- * @return void
- */
-function panels_taxonomies() {
-
-    // Experiences
-    $labels = array(
-        'name'              => _x( GLM_PANEL_CATEGORY_NAME, 'taxonomy general name' ),
-        'singular_name'     => _x( GLM_PANEL_CATEGORY_NAME, 'taxonomy singular name' ),
-        'search_items'      => __( 'Search ' . GLM_PANEL_CATEGORY_PLURAL ),
-        'all_items'         => __( 'All ' . GLM_PANEL_CATEGORY_PLURAL ),
-        'parent_item'       => __( 'Parent ' . GLM_PANEL_CATEGORY_SINGLE ),
-        'parent_item_colon' => __( 'Parent ' . GLM_PANEL_CATEGORY_SINGLE ),
-        'edit_item'         => __( 'Edit ' . GLM_PANEL_CATEGORY_SINGLE ),
-        'update_item'       => __( 'Update ' . GLM_PANEL_CATEGORY_SINGLE ),
-        'add_new_item'      => __( 'Add New ' . GLM_PANEL_CATEGORY_SINGLE ),
-        'new_item_name'     => __( 'New ' . GLM_PANEL_CATEGORY_SINGLE . ' Name' ),
-        'menu_name'         => __( 'Site ' . GLM_PANEL_CATEGORY_SINGLE ),
-    );
-
-    $capabilities = array(
-        'manage_terms' => 'manage_categories',
-        'edit_terms'   => 'manage_categories',
-        'delete_terms' => 'manage_categories',
-        'assign_terms' => 'edit_posts',
-    );
-
-    $args = array(
-        'label'                => __( GLM_PANEL_CATEGORY_PLURAL ),
-        'rewrite'              => array( 'slug' => GLM_PANEL_CATEGORY_SLUG ),
-        'capabilities'         => $capabilities,
-        'public '              => true,
-        'show_in_quick_edit'   => true,
-        'show_in_admin_column' => true,
-        'hierarchical'         => true
-    );
-
-     register_taxonomy(
-        GLM_PANEL_CATEGORY_NAME,
-        GLM_PANEL_POST_TYPE,
-        $args
-    );
-}
-
-/**
- * panels_taxonomy_filter_restrict_manage_posts
- *
- * This will setup the Filter for the Custom taxonomies.
- *
- * @access public
- * @return void
- */
-function panels_taxonomy_filter_restrict_manage_posts() {
-    global $typenow;
-
-    $post_types = get_post_types( array( '_builtin' => false ) );
-
-    if ( in_array( $typenow, $post_types ) ) {
-        $filters = get_object_taxonomies( $typenow );
-
-        foreach ( $filters as $tax_slug ) {
-            $tax_obj = get_taxonomy( $tax_slug );
-            wp_dropdown_categories( array(
-                'show_option_all' => __( 'Show All ' . $tax_obj->label ),
-                'taxonomy'        => $tax_slug,
-                'name'            => $tax_obj->name,
-                'orderby'         => 'menu_order', 
-                'selected'        => ( isset( $_GET[$tax_slug] ) ),
-                'hierarchical'    => $tax_obj->hierarchical,
-                'show_count'      => false,
-                'hide_empty'      => true,
-            ) );
-        }
-    }
-}
-
-add_action( 'restrict_manage_posts', 'panels_taxonomy_filter_restrict_manage_posts' );
-
-/**
- * Panel Posts_taxonomy_filter_post_type_request
- *
- * Filter the post request for the Taxonomy Filter
- *
- * @param mixed $query
- * @access public
- * @return void
- */
-function panels_taxonomy_filter_post_type_request( $query ) {
-    global $pagenow, $typenow;
-
-    if ( 'edit.php' === $pagenow ) {
-        $filters = get_object_taxonomies( $typenow );
-        foreach ( $filters as $tax_slug ) {
-            $var = &$query->query_vars[ $tax_slug ];
-
-            if ( isset( $var ) ) {
-                $term = get_term_by( 'id', $var, $tax_slug );
-
-                $var = $term->slug;
-            }
-        }
-    }
-}
-add_filter( 'parse_query', 'panels_taxonomy_filter_post_type_request' );
-add_action( 'init', 'panels_custom_post_type' );
-add_action( 'init', 'panels_taxonomies' );
-add_action( 'save_post', 'panels_save_meta' );
-
-/**
- * Panel Posts_set_admin_columns
- *
- * Setup of the list columns
- *
- * @access public
- * @return void
- */
-function panels_set_admin_columns() {
-    add_filter( 'manage_edit-panels_columns', 'panels_admin_edit_columns' );
-    add_action( 'manage_panels_posts_custom_column', 'panels_admin_custom_columns' );
-}
-
-add_action( 'admin_init', 'panels_set_admin_columns' );
-
-/**
- * Panel Posts_admin_edit_columns
- *
- * Setup of the edit columns. This will create the headers for each column.
- *
- * @param mixed $columns
- * @access public
- * @return void
- */
-function panels_admin_edit_columns( $columns ) {
-    $columns = array(
-        'cb'                  => '<input type="checkbox">',
-        'title'               => GLM_PANEL_SINGLE . ' Title',
-        'panels_col_cat'    => GLM_PANEL_CATEGORY_SINGLE,
-    );
-    return $columns;
-}
-
-/**
- * Panel Posts_admin_custom_columns
- *
- * This will generate the column data for eaoch record.
- *
- * @param mixed $column
- * @access public
- * @return void
- */
-function panels_admin_custom_columns( $column ) {
-    global $post;
-
-    switch ( $column ) {
-    case 'panels_col_cat':
-        $product_cats      = get_the_terms( $post->ID, 'panels_category' );
-        $product_cats_html = array();
-        if ( $product_cats ) {
-            foreach ( $product_cats as $product_cat ) {
-                array_push( $product_cats_html, $product_cat->name );
-            }
-            echo implode( $product_cats_html, ', ' );
-        } else {
-             _e( 'None', 'themeforce' );
-        }
-        break;
-    case 'panels_col_tag':
-        $product_tags      = get_the_terms( $post->ID, 'panels_tag' );
-        $product_tags_html = array();
-        if ( $product_tags ) {
-            foreach ( $product_tags as $product_tag ) {
-                array_push( $product_tags_html, $product_tag->name );
-            }
-            echo implode( $product_tags_html, ', ' );
-        } else {
-             _e( 'None', 'themeforce' );
-        }
-        break;
-    }
-}
-
-/**
- * Panel Posts_shortcode
- *
- * Add shortcode function. This will call the correct function based on the
- * front end search.
- *
- * @param mixed $atts
- * @access public
- * @return void
- */
-function panels_shortcode( $atts ) {
-    extract( shortcode_atts( array( 'limit' => '10' ), $atts ) );
-    ob_start();
-
-    if ( isset( $atts['cat']) ) {
-        if ( $prod_experience = get_term_by( 'slug', $atts['cat'], GLM_PANEL_CATEGORY_NAME ) ) {
-           if ( !isset($_REQUEST[ GLM_PANEL_CATEGORY_NAME ] )) {
-            $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] = $prod_experience->term_id;
-           }
-            $cat_id = $prod_experience->term_id;
-        }
-    }
-    $term = get_term_by( "id", $_REQUEST[ GLM_PANEL_CATEGORY_NAME ],"panels_category" );
-    $name = $term->name;   
-    if ( !$name ) {
-        $name = "ALL PRODUCTS";
-    }
-    global $wp;
-    echo '<form id="catSubmit" action=""><div class="row catSearch"><div id="viewBtns" class="12-small medium-3 columns"> <button id="grid" type="button">Grid</button> <button id="list"type=" button">list</button>
-    <span id="productSearch"><a href="' . get_permalink( 510 ) .   '"> Search Products </a></span></div><div id="catDropdown" class="small-12 medium-4 columns">';
-    echo panels_get_terms_dropdown( $cat_id );
-    echo '</div><div id="searchContainer" class="small-12 medium-3 columns"></form> <form class="searchform" role="search" method="post" action="">
-         <input id="filter" class="search-input" placeholder="SEARCH ' . strtoupper( $name ) . '" value="" autocomplete="off" name="tsearch" type="text">
-         <input id="input" class="search-button" name="searchButton" value="Search" type="submit">
-        
-         <a id="magnifying-glass" class="show-for-large-up" href="#">
-    </a>
-       </form></div></div>';
-
-    if ( $product_id = filter_var( $_REQUEST['product'], FILTER_VALIDATE_INT ) ) {
-        panels_show_product( $product_id );
-    } else if ( $cat_id = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
-        panels_list_categories( $cat_id );
-    } else if ( !$catid_id && !$product_id ) {
-
-        $text_query = filter_var( $_REQUEST['tsearch'], FILTER_SANITIZE_STRING );
-
-        if (isset( $_REQUEST[ 'tsearch' ] ) ) {
-            setcookie("search", "true",time()+2, "/" );
-        } else {
-            setcookie("search", "null",time()+2, "/" );
-        }
-        panels_list_products( $text_query );
-        panels_list_categories();
-    } 
-    
-    $output = ob_get_contents();
-    ob_end_clean();
-    return $output;
-}
-
-/**
- * Panel Posts_get_terms_dropdown
- *
- * Generate the taxonomy drop down select
- *
- * @access public
- * @return void
- */
-function panels_get_terms_dropdown( $cat_id ) {
-    
-    $taxonomy_name = GLM_PANEL_CATEGORY_NAME;
-    if ( $cat_id ) {
-        $main = get_term( $cat_id, GLM_PANEL_CATEGORY_NAME );
-        $cats_child = get_term_children( $cat_id, $taxonomy_name );
-        $output ="<select id='categoryDropdown' name=\"" . GLM_PANEL_CATEGORY_NAME . "\"><option value=\"\"> Select " . $main->name . " Sub-category" . "</option>";
-        foreach ( $cats_child as $cat ) {
-          $output .= '<option value="' . $cat . '"';
-           if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] == $cat ) {
-                $output .= ' selected';
-            }
-            $cat_name = get_term( $cat, GLM_PANEL_CATEGORY_NAME );
-             $output .= '>' . "&nbsp&nbsp&nbsp" . $cat_name->name. '</option>';
-        }
-        $output .="</select>";
-    } else {
-        
-    $parent_terms = get_terms( $taxonomy_name, array('parent' => 0, 'orderby' => 'name', 'hide_empty' => false ));
-    $terms = get_terms( $taxonomy_name, array('orderby' => 'name', 'hide_empty' => false ));
-    $output ="<select id='categoryDropdown' name=\"" . GLM_PANEL_CATEGORY_NAME . "\"><option value=\"\">Select " . GLM_PANEL_CATEGORY_SINGLE . "</option>";
-        // Get parent categories.
-        foreach ( $parent_terms as $parent ) {   
-            // Get children of each category.
-            $child_terms = get_terms( $taxonomy_name, array('parent'=> $parent->term_id, 'child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false));
-            $output .= '<option value="' . $parent->term_id . '"';
-            if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $parent->term_id ) {
-                $output .= ' selected';
-            }
-            $output .= '>' . $parent->name . '</option>';
-            foreach ($child_terms as $child ) {
-                $grandchildren = get_terms( $taxonomy_name, array('parent'=> $child->term_id, 'child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false ));
-                 $output .= '<option value="' . $child->term_id . '"';
-                if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $child->term_id ) {
-                    $output .= ' selected';
-                }
-                $output .= '>' . "&nbsp&nbsp&nbsp" .  $child->name . '</option>';
-                foreach ( $grandchildren as $grand_child) {
-                    $great_grandchildren = get_terms( $taxonomy_name, array( 'parent'=> $grand_child->term_id, 'child_of' => $grand_child->term_id, 'orderby' => 'name', 'hide_empty' => false ));
-                    $output .= '<option value="' . $grand_child->term_id . '"';
-                    if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $grand_child->term_id ) {
-                        $output .= ' selected';
-                    }
-                    $output .= '>' . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" .  $grand_child->name . '</option>';
-                    foreach ( $great_grandchildren as $great_grandchild ) {
-                        $output .= '<option value="' . $great_grandchild->term_id . '"';
-                    if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $great_grandchild->term_id ) {
-                        $output .= ' selected';
-                    }
-                    $output .= '>' . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" .  $great_grandchild->name . '</option>';
-                    }
-                }
-            }
-        }
-        $output .='</select>'; }
-        return $output;
-}
-
-
-/**
- * Panel Posts_list_products
- *
- * Create a list of products.
- *
- * @access public
- * @return void
- */
-function panels_list_products( $text_query ) {
-    global $wpdb, $wp;
-    $cat = get_term( $cat_id, GLM_PANEL_CATEGORY_NAME );
-    $args = array(
-        'posts_per_page' => -1,
-        'post_type'     => GLM_PANEL_POST_TYPE,
-        's' => $text_query,
-    );
-    $panels_category = ( isset( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] ) )
-        ? filter_var( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] )
-        : false;
-
-    if ( $panels_category ) {
-        $args['tax_query'] = array(
-            'relation' => 'AND',
-        );
-        $args['tax_query'][] = array(
-            'taxonomy' => GLM_PANEL_CATEGORY_NAME,
-            'field'    => 'id',
-            'terms'    => $panels_category, 
-        );
-    }
-
-    $products      = get_posts( $args );
-    $total_products = count( $products );
-    $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
-    $iterator      = 1;
-
-    foreach ( $products as $product ) {
-        $product_terms = wp_get_post_terms( $product->ID, GLM_PANEL_CATEGORY_NAME, 'name' );
-        $p_term = $product_terms[0];
-        $product->term = $p_term->name;
-        $product->end = false;
-        if ( $iterator == $total_products ) {
-            $product->end = true;
-        }
-        $cat->href =   "?panels_category="; 
-        $product->href = $current_url
-            . ( ( strpos( $current_url, '?' ) ) ? '&' : '?' )
-            . "product=" . $product->ID;
-        ++$iterator;
-    }
-
-    include 'views/list_products.php';
-    return;
-}
-/**
- * panels_list_categories
- *
- * Create a list of categories.
- *
- * @param bool $cat_id
- * @access public
- * @return void
- */
-function panels_list_categories( $cat_id = null ) {
-    global $wpdb, $wp;
-
-    $taxonomy = GLM_PANEL_CATEGORY_NAME;
-    $args = array(
-        'hide_empty' => false,
-        'pad_counts' => true
-    );
-    if ( $cat_id ) {
-        $args['child_of'] = $cat_id;
-    } else {
-        $args['parent'] = 0;
-    }
-    $taxonomy_terms = get_terms( $taxonomy, $args );
-
-
-    $total_terms = count( $taxonomy_terms );
-    $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
-    $iterator      = 1;
-
-    foreach ( $taxonomy_terms as $term ) {
-        $term->end = false;
-        if ( $iterator === $total_terms) {
-            $term->end = true;
-        }
-        $term->href .= //$current_url
-//             ( ( strpos( $current_url, '?' ) ) ? '&' : '?' ).
-            "?panels_category=" . $term->term_id;
-        ++$iterator;
-    }
-
-    include 'views/list_categories.php';
-    return;
-}
-
-/**
- * Panel Posts_show_product
- *
- * Create a product detail page.
- *
- * @param mixed $prod_id
- * @access public
- * @return void
- */
-function panels_show_product( $prod_id ) {
-    global $wpdb, $wp;
-    $product = get_post( $prod_id );
-    include 'views/product_detail.php';
-    return;
-}
-/**
- * Panel Posts_show_category
- *
- * Create a product detail page.
- *
- * @param mixed $cat_id
- * @access public
- * @return void
- */
-function panels_show_category( $cat_id ) {
-    global $wpdb, $wp;
-    $term = get_terms(
-        GLM_PANEL_CATEGORY_NAME,
-        array(
-            'child_of'     => $cat_id,
-            'hide_empty'   => true,
-            //'parent'       => $catid_id,
-            //'hierarchical' => false
-        )
-    );
-
-    include 'views/category_detail.php';
-    return;
-}
-add_shortcode( 'panels', 'panels_shortcode' );
-
-
diff --git a/inc/panel.php b/inc/panel.php
new file mode 100644 (file)
index 0000000..55eaaa6
--- /dev/null
@@ -0,0 +1,735 @@
+<?php
+/**
+ * Plugin Name: Panel Posts
+ * Plugin URI:
+ * Description: Gaslight Media Catalog Plugin
+ * Version: 0.0.1
+ * Author: Steve Sutton <steve@gaslightmedia.com>
+ * Author URI:
+ * License: GPLv2
+ **/
+
+define( 'GLM_PANEL_POST_TYPE', 'glm-panel' );
+define( 'GLM_PANEL_SINGLE', 'Panel' );
+define( 'GLM_PANEL_PLURAL', 'Panel Posts' );
+define( 'GLM_PANEL_CATEGORY_NAME', 'panel_category' );
+define( 'GLM_PANEL_CATEGORY_SLUG', 'panel-posts-category' );
+define( 'GLM_PANEL_CATEGORY_SINGLE', 'Panel Type' );
+define( 'GLM_PANEL_CATEGORY_PLURAL', 'Panel Types' );
+
+// Register Custom Post Type.
+/**
+ * Panel Posts_custom_post_type
+ *
+ * Setup of the Wordpress Custom Post Type
+ *
+ * @access public
+ * @return void
+ */
+function panels_custom_post_type() {
+
+    $labels = array(
+        'name'                  => _x( GLM_PANEL_PLURAL, 'Post Type General Name' ),
+        'singular_name'         => _x( GLM_PANEL_SINGLE, 'Post Type Singular Name' ),
+        'menu_name'             => __( GLM_PANEL_PLURAL ),
+        'name_admin_bar'        => __( GLM_PANEL_PLURAL ),
+        'archives'              => __( GLM_PANEL_SINGLE . ' Archives' ),
+        'parent_item_colon'     => __( 'Parent Panel Post:' ),
+        'all_items'             => __( 'All Panel Posts' ),
+        'add_new_item'          => __( 'Add New Panel Post' ),
+        'add_new'               => __( 'Add New' ),
+        'new_item'              => __( 'New Panel Post' ),
+        'edit_item'             => __( 'Edit Panel' ),
+        'update_item'           => __( 'Update Panel' ),
+        'view_item'             => __( 'View Panel Post' ),
+        'search_items'          => __( 'Search Panel Posts' ),
+        'not_found'             => __( 'Not found' ),
+        'not_found_in_trash'    => __( 'Not found in Trash' ),
+        'featured_image'        => __( 'Featured Image' ),
+        'set_featured_image'    => __( 'Set featured image' ),
+        'remove_featured_image' => __( 'Remove featured image' ),
+        'use_featured_image'    => __( 'Use as featured image' ),
+        'insert_into_item'      => __( 'Insert into item' ),
+        'uploaded_to_this_item' => __( 'Uploaded to this item' ),
+        'items_list'            => __( 'Panel Posts list' ),
+        'items_list_navigation' => __( 'Panel Posts list navigation' ),
+        'filter_items_list'     => __( 'Filter items list' ),
+    );
+
+    $rewrite = array(
+        'slug'                  => GLM_PANEL_POST_TYPE,
+        'with_front'            => false,
+        'pages'                 => false,
+        'feeds'                 => false,
+    );
+
+    $args = array(
+        'label'                 => __( GLM_PANEL_SINGLE ),
+        'description'           => __( 'Custom ' . GLM_PANEL_PLURAL ),
+        'labels'                => $labels,
+        'supports'              => array( 'title', 'thumbnail', 'revisions', 'editor', 'author'),
+        'hierarchical'          => true,
+        'public'                => true,
+        'show_ui'               => true,
+        'show_in_menu'          => true,
+        'menu_position'         => 5,
+        'menu_icon'             => 'dashicons-testimonial',
+        'show_in_admin_bar'     => true,
+        'show_in_nav_menus'     => true,
+        'can_export'            => true,
+        'has_archive'           => true,
+        'exclude_from_search'   => false,
+        'publicly_queryable'    => true,
+        'rewrite'               => $rewrite,
+        'capability_type'       => 'page',
+        'register_meta_box_cb'  => 'panels_add_metaboxes',
+    );
+
+    register_post_type( GLM_PANEL_POST_TYPE, $args );
+    register_taxonomy_for_object_type( GLM_PANEL_CATEGORY_NAME, GLM_PANEL_POST_TYPE );
+}
+
+/**
+ * Panel Posts_add_metaboxes
+ *
+ * Add the meta fields
+ *
+ * @access public
+ * @return void
+ */
+function panels_add_metaboxes() {
+
+//    add_meta_box( 'panels_tents', 'Tents', 'panels_tents', GLM_PANEL_POST_TYPE, 'side', 'low' );
+}
+
+/**
+ * Panel Posts_water
+ *
+ * Add field for the water availability
+ *
+ * @access public
+ * @return void
+ */
+function panels_water() {
+    global $post;
+    $checked = '';
+    // Get the features for the post.
+    $water = get_post_meta( $post->ID, 'panels_water', true );
+    
+    // Output field.
+    if ( 'yes' === $water ) {
+        $checked = 'checked="checked"';
+    }
+    ?>
+<input type="checkbox" name="panels_water" value="yes" <?php echo $checked; ?> />
+    <?php
+
+}
+/**
+ * Panel Posts_tents
+ *
+ * Add field for the water availability
+ *
+ * @access public
+ * @return void
+ */
+//function panels_tents() {
+//    global $post;
+//
+//    // Get the features for the post.
+//    $tents = get_post_meta( $post->ID, 'panels_tents', true );
+//    
+//    // Output field.
+//    if ( 'yes' === $tents ) {
+//        $checked = 'checked="checked"';
+//    }
+//    
+
+   
+//
+//}
+/**
+ * Panel Posts_loop
+ *
+ * Add field for the loop
+ *
+ * @access public
+ * @return void
+ */
+function panels_loop() {
+    global $post;
+    $value = '';
+    // Noncename needed to verify where the data originated.
+    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
+    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-loop" value="' . $nonce . '" />';
+
+    // Get the features for the post.
+    $loop = get_post_meta( $post->ID, 'panels_loop', true );
+    // Output field.
+    if ( !empty( $loop ) ) {
+        $value = "value=".'"'.$loop .'"';
+    }
+
+    ?>
+    <input type="text" name="panels_loop" <?php echo $value; ?> />
+    <?php
+
+}
+
+/**
+ * Panel Posts_sewer
+ *
+ * Adds the field for sewer availibility
+ *
+ * @access public
+ * @return void
+ */
+function panels_sewer() {
+    global $post;
+    $checked = '';
+    // Noncename needed to verify where the data originated.
+    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
+    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-sewer" value="' . $nonce . '" />';
+    // Get the features for the post.
+    $sewer = get_post_meta( $post->ID, 'panels_sewer', true );
+
+    // Output field.
+    if ( "yes" === $sewer ) {
+        $checked = 'checked="checked"';
+    }
+
+    ?>
+    <input type="checkbox" name="panels_sewer" value="yes" <?php echo $checked; ?> />
+    <?php
+
+}
+/**
+ * Panel Posts_campers
+ *
+ * Adds the field for camper types
+ *
+ * @access public
+ * @return void
+ */
+function panels_campers() {
+    global $post;
+
+    // Get the features for the post.
+    $campers = get_post_meta( $post->ID, 'panels_campers', true );
+    
+    // Output field.
+    if ( !empty( $campers ) ) {
+        $value = "value=".'"'.$campers .'"';
+    }
+    ?>
+    <input type="text" name="panels_campers" <?php echo $value; ?> />
+    <?php
+}
+/**
+ * Panel Posts_power
+ *
+ * Adds the field for power availability
+ * @access public
+ * @return void
+ */
+function panels_power() {
+    global $post;
+    $value = '';
+    // Noncename needed to verify where the data originated.
+    $nonce = wp_create_nonce( 'panelsmeta-meta-noncename' );
+    echo '<input type="hidden" name="panelsmeta-meta-noncename" id="panelsmeta-meta-noncename-power" value="' . $nonce . '" />';
+
+    // Get the features for the post.
+    $power = get_post_meta( $post->ID, 'panels_power', true );
+    // Output field.
+    if ( !empty( $power ) ) {
+        $value = "value=".'"'.$power .'"';
+    }
+
+    ?>
+    <input type="text" name="panels_power" <?php echo $value; ?> />
+    <?php
+}
+
+/**
+ * Panel Posts_save_meta
+ *
+ * Saves the meta fields for the product
+ *
+ * @access public
+ * @return void
+ */
+function panels_save_meta() {
+    global $post;
+    if ( ! wp_verify_nonce( $_POST['panelsmeta-meta-noncename'], 'panelsmeta-meta-noncename' ) ) {
+        return $post->ID;
+    }
+    if ( ! current_user_can( 'edit_post', $post->ID ) ) {
+        return $post->ID;
+    }
+    $water         = (isset($_POST['panels_water']) ? filter_var( $_POST['panels_water'] ) : '' );
+    $sewer         = (isset($_POST['panels_sewer']) ? filter_var( $_POST['panels_sewer'] ) : '' );
+    $power         = (isset($_POST['panels_power']) ? filter_var( $_POST['panels_power'] ) : '' );
+    $loop          = (isset($_POST['panels_loop']) ? filter_var( $_POST['panels_loop'] ) : '' );
+//    $tents          = filter_var( $_POST['panels_tents'] );
+    update_post_meta( $post->ID, 'panels_water', $water );
+    update_post_meta( $post->ID, 'panels_sewer', $sewer );
+    update_post_meta( $post->ID, 'panels_power', $power );
+    update_post_meta( $post->ID, 'panels_loop', $loop );
+//    update_post_meta( $post->ID, 'panels_tents', $tents );
+}
+/**
+ * panels_taxonomies
+ *
+ * Setup of the Taxonomies for the post type
+ *
+ * @access public
+ * @return void
+ */
+function panels_taxonomies() {
+
+    // Experiences
+    $labels = array(
+        'name'              => _x( GLM_PANEL_CATEGORY_NAME, 'taxonomy general name' ),
+        'singular_name'     => _x( GLM_PANEL_CATEGORY_NAME, 'taxonomy singular name' ),
+        'search_items'      => __( 'Search ' . GLM_PANEL_CATEGORY_PLURAL ),
+        'all_items'         => __( 'All ' . GLM_PANEL_CATEGORY_PLURAL ),
+        'parent_item'       => __( 'Parent ' . GLM_PANEL_CATEGORY_SINGLE ),
+        'parent_item_colon' => __( 'Parent ' . GLM_PANEL_CATEGORY_SINGLE ),
+        'edit_item'         => __( 'Edit ' . GLM_PANEL_CATEGORY_SINGLE ),
+        'update_item'       => __( 'Update ' . GLM_PANEL_CATEGORY_SINGLE ),
+        'add_new_item'      => __( 'Add New ' . GLM_PANEL_CATEGORY_SINGLE ),
+        'new_item_name'     => __( 'New ' . GLM_PANEL_CATEGORY_SINGLE . ' Name' ),
+        'menu_name'         => __( 'Site ' . GLM_PANEL_CATEGORY_SINGLE ),
+    );
+
+    $capabilities = array(
+        'manage_terms' => 'manage_categories',
+        'edit_terms'   => 'manage_categories',
+        'delete_terms' => 'manage_categories',
+        'assign_terms' => 'edit_posts',
+    );
+
+    $args = array(
+        'label'                => __( GLM_PANEL_CATEGORY_PLURAL ),
+        'rewrite'              => array( 'slug' => GLM_PANEL_CATEGORY_SLUG ),
+        'capabilities'         => $capabilities,
+        'public '              => true,
+        'show_in_quick_edit'   => true,
+        'show_in_admin_column' => true,
+        'hierarchical'         => true
+    );
+
+     register_taxonomy(
+        GLM_PANEL_CATEGORY_NAME,
+        GLM_PANEL_POST_TYPE,
+        $args
+    );
+}
+
+/**
+ * panels_taxonomy_filter_restrict_manage_posts
+ *
+ * This will setup the Filter for the Custom taxonomies.
+ *
+ * @access public
+ * @return void
+ */
+function panels_taxonomy_filter_restrict_manage_posts() {
+    global $typenow;
+
+    $post_types = get_post_types( array( '_builtin' => false ) );
+
+    if ( in_array( $typenow, $post_types ) ) {
+        $filters = get_object_taxonomies( $typenow );
+
+        foreach ( $filters as $tax_slug ) {
+            $tax_obj = get_taxonomy( $tax_slug );
+            wp_dropdown_categories( array(
+                'show_option_all' => __( 'Show All ' . $tax_obj->label ),
+                'taxonomy'        => $tax_slug,
+                'name'            => $tax_obj->name,
+                'orderby'         => 'menu_order', 
+                'selected'        => ( isset( $_GET[$tax_slug] ) ),
+                'hierarchical'    => $tax_obj->hierarchical,
+                'show_count'      => false,
+                'hide_empty'      => true,
+            ) );
+        }
+    }
+}
+
+add_action( 'restrict_manage_posts', 'panels_taxonomy_filter_restrict_manage_posts' );
+
+/**
+ * Panel Posts_taxonomy_filter_post_type_request
+ *
+ * Filter the post request for the Taxonomy Filter
+ *
+ * @param mixed $query
+ * @access public
+ * @return void
+ */
+function panels_taxonomy_filter_post_type_request( $query ) {
+    global $pagenow, $typenow;
+
+    if ( 'edit.php' === $pagenow ) {
+        $filters = get_object_taxonomies( $typenow );
+        foreach ( $filters as $tax_slug ) {
+            $var = &$query->query_vars[ $tax_slug ];
+
+            if ( isset( $var ) ) {
+                $term = get_term_by( 'id', $var, $tax_slug );
+
+                $var = $term->slug;
+            }
+        }
+    }
+}
+add_filter( 'parse_query', 'panels_taxonomy_filter_post_type_request' );
+add_action( 'init', 'panels_custom_post_type' );
+add_action( 'init', 'panels_taxonomies' );
+add_action( 'save_post', 'panels_save_meta' );
+
+/**
+ * Panel Posts_set_admin_columns
+ *
+ * Setup of the list columns
+ *
+ * @access public
+ * @return void
+ */
+function panels_set_admin_columns() {
+    add_filter( 'manage_edit-panels_columns', 'panels_admin_edit_columns' );
+    add_action( 'manage_panels_posts_custom_column', 'panels_admin_custom_columns' );
+}
+
+add_action( 'admin_init', 'panels_set_admin_columns' );
+
+/**
+ * Panel Posts_admin_edit_columns
+ *
+ * Setup of the edit columns. This will create the headers for each column.
+ *
+ * @param mixed $columns
+ * @access public
+ * @return void
+ */
+function panels_admin_edit_columns( $columns ) {
+    $columns = array(
+        'cb'                  => '<input type="checkbox">',
+        'title'               => GLM_PANEL_SINGLE . ' Title',
+        'panels_col_cat'    => GLM_PANEL_CATEGORY_SINGLE,
+    );
+    return $columns;
+}
+
+/**
+ * Panel Posts_admin_custom_columns
+ *
+ * This will generate the column data for eaoch record.
+ *
+ * @param mixed $column
+ * @access public
+ * @return void
+ */
+function panels_admin_custom_columns( $column ) {
+    global $post;
+
+    switch ( $column ) {
+    case 'panels_col_cat':
+        $product_cats      = get_the_terms( $post->ID, 'panels_category' );
+        $product_cats_html = array();
+        if ( $product_cats ) {
+            foreach ( $product_cats as $product_cat ) {
+                array_push( $product_cats_html, $product_cat->name );
+            }
+            echo implode( $product_cats_html, ', ' );
+        } else {
+             _e( 'None', 'themeforce' );
+        }
+        break;
+    case 'panels_col_tag':
+        $product_tags      = get_the_terms( $post->ID, 'panels_tag' );
+        $product_tags_html = array();
+        if ( $product_tags ) {
+            foreach ( $product_tags as $product_tag ) {
+                array_push( $product_tags_html, $product_tag->name );
+            }
+            echo implode( $product_tags_html, ', ' );
+        } else {
+             _e( 'None', 'themeforce' );
+        }
+        break;
+    }
+}
+
+/**
+ * Panel Posts_shortcode
+ *
+ * Add shortcode function. This will call the correct function based on the
+ * front end search.
+ *
+ * @param mixed $atts
+ * @access public
+ * @return void
+ */
+function panels_shortcode( $atts ) {
+    extract( shortcode_atts( array( 'limit' => '10' ), $atts ) );
+    ob_start();
+
+    if ( isset( $atts['cat']) ) {
+        if ( $prod_experience = get_term_by( 'slug', $atts['cat'], GLM_PANEL_CATEGORY_NAME ) ) {
+           if ( !isset($_REQUEST[ GLM_PANEL_CATEGORY_NAME ] )) {
+            $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] = $prod_experience->term_id;
+           }
+            $cat_id = $prod_experience->term_id;
+        }
+    }
+    $term = get_term_by( "id", $_REQUEST[ GLM_PANEL_CATEGORY_NAME ],"panels_category" );
+    $name = $term->name;   
+    if ( !$name ) {
+        $name = "ALL PRODUCTS";
+    }
+    global $wp;
+    echo '<form id="catSubmit" action=""><div class="row catSearch"><div id="viewBtns" class="12-small medium-3 columns"> <button id="grid" type="button">Grid</button> <button id="list"type=" button">list</button>
+    <span id="productSearch"><a href="' . get_permalink( 510 ) .   '"> Search Products </a></span></div><div id="catDropdown" class="small-12 medium-4 columns">';
+    echo panels_get_terms_dropdown( $cat_id );
+    echo '</div><div id="searchContainer" class="small-12 medium-3 columns"></form> <form class="searchform" role="search" method="post" action="">
+         <input id="filter" class="search-input" placeholder="SEARCH ' . strtoupper( $name ) . '" value="" autocomplete="off" name="tsearch" type="text">
+         <input id="input" class="search-button" name="searchButton" value="Search" type="submit">
+        
+         <a id="magnifying-glass" class="show-for-large-up" href="#">
+    </a>
+       </form></div></div>';
+
+    if ( $product_id = filter_var( $_REQUEST['product'], FILTER_VALIDATE_INT ) ) {
+        panels_show_product( $product_id );
+    } else if ( $cat_id = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
+        panels_list_categories( $cat_id );
+    } else if ( !$catid_id && !$product_id ) {
+
+        $text_query = filter_var( $_REQUEST['tsearch'], FILTER_SANITIZE_STRING );
+
+        if (isset( $_REQUEST[ 'tsearch' ] ) ) {
+            setcookie("search", "true",time()+2, "/" );
+        } else {
+            setcookie("search", "null",time()+2, "/" );
+        }
+        panels_list_products( $text_query );
+        panels_list_categories();
+    } 
+    
+    $output = ob_get_contents();
+    ob_end_clean();
+    return $output;
+}
+
+/**
+ * Panel Posts_get_terms_dropdown
+ *
+ * Generate the taxonomy drop down select
+ *
+ * @access public
+ * @return void
+ */
+function panels_get_terms_dropdown( $cat_id ) {
+    
+    $taxonomy_name = GLM_PANEL_CATEGORY_NAME;
+    if ( $cat_id ) {
+        $main = get_term( $cat_id, GLM_PANEL_CATEGORY_NAME );
+        $cats_child = get_term_children( $cat_id, $taxonomy_name );
+        $output ="<select id='categoryDropdown' name=\"" . GLM_PANEL_CATEGORY_NAME . "\"><option value=\"\"> Select " . $main->name . " Sub-category" . "</option>";
+        foreach ( $cats_child as $cat ) {
+          $output .= '<option value="' . $cat . '"';
+           if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] == $cat ) {
+                $output .= ' selected';
+            }
+            $cat_name = get_term( $cat, GLM_PANEL_CATEGORY_NAME );
+             $output .= '>' . "&nbsp&nbsp&nbsp" . $cat_name->name. '</option>';
+        }
+        $output .="</select>";
+    } else {
+        
+    $parent_terms = get_terms( $taxonomy_name, array('parent' => 0, 'orderby' => 'name', 'hide_empty' => false ));
+    $terms = get_terms( $taxonomy_name, array('orderby' => 'name', 'hide_empty' => false ));
+    $output ="<select id='categoryDropdown' name=\"" . GLM_PANEL_CATEGORY_NAME . "\"><option value=\"\">Select " . GLM_PANEL_CATEGORY_SINGLE . "</option>";
+        // Get parent categories.
+        foreach ( $parent_terms as $parent ) {   
+            // Get children of each category.
+            $child_terms = get_terms( $taxonomy_name, array('parent'=> $parent->term_id, 'child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false));
+            $output .= '<option value="' . $parent->term_id . '"';
+            if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $parent->term_id ) {
+                $output .= ' selected';
+            }
+            $output .= '>' . $parent->name . '</option>';
+            foreach ($child_terms as $child ) {
+                $grandchildren = get_terms( $taxonomy_name, array('parent'=> $child->term_id, 'child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false ));
+                 $output .= '<option value="' . $child->term_id . '"';
+                if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $child->term_id ) {
+                    $output .= ' selected';
+                }
+                $output .= '>' . "&nbsp&nbsp&nbsp" .  $child->name . '</option>';
+                foreach ( $grandchildren as $grand_child) {
+                    $great_grandchildren = get_terms( $taxonomy_name, array( 'parent'=> $grand_child->term_id, 'child_of' => $grand_child->term_id, 'orderby' => 'name', 'hide_empty' => false ));
+                    $output .= '<option value="' . $grand_child->term_id . '"';
+                    if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $grand_child->term_id ) {
+                        $output .= ' selected';
+                    }
+                    $output .= '>' . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" .  $grand_child->name . '</option>';
+                    foreach ( $great_grandchildren as $great_grandchild ) {
+                        $output .= '<option value="' . $great_grandchild->term_id . '"';
+                    if ( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] === $great_grandchild->term_id ) {
+                        $output .= ' selected';
+                    }
+                    $output .= '>' . "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp" .  $great_grandchild->name . '</option>';
+                    }
+                }
+            }
+        }
+        $output .='</select>'; }
+        return $output;
+}
+
+
+/**
+ * Panel Posts_list_products
+ *
+ * Create a list of products.
+ *
+ * @access public
+ * @return void
+ */
+function panels_list_products( $text_query ) {
+    global $wpdb, $wp;
+    $cat = get_term( $cat_id, GLM_PANEL_CATEGORY_NAME );
+    $args = array(
+        'posts_per_page' => -1,
+        'post_type'     => GLM_PANEL_POST_TYPE,
+        's' => $text_query,
+    );
+    $panels_category = ( isset( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] ) )
+        ? filter_var( $_REQUEST[ GLM_PANEL_CATEGORY_NAME ] )
+        : false;
+
+    if ( $panels_category ) {
+        $args['tax_query'] = array(
+            'relation' => 'AND',
+        );
+        $args['tax_query'][] = array(
+            'taxonomy' => GLM_PANEL_CATEGORY_NAME,
+            'field'    => 'id',
+            'terms'    => $panels_category, 
+        );
+    }
+
+    $products      = get_posts( $args );
+    $total_products = count( $products );
+    $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
+    $iterator      = 1;
+
+    foreach ( $products as $product ) {
+        $product_terms = wp_get_post_terms( $product->ID, GLM_PANEL_CATEGORY_NAME, 'name' );
+        $p_term = $product_terms[0];
+        $product->term = $p_term->name;
+        $product->end = false;
+        if ( $iterator == $total_products ) {
+            $product->end = true;
+        }
+        $cat->href =   "?panels_category="; 
+        $product->href = $current_url
+            . ( ( strpos( $current_url, '?' ) ) ? '&' : '?' )
+            . "product=" . $product->ID;
+        ++$iterator;
+    }
+
+    include 'views/list_products.php';
+    return;
+}
+/**
+ * panels_list_categories
+ *
+ * Create a list of categories.
+ *
+ * @param bool $cat_id
+ * @access public
+ * @return void
+ */
+function panels_list_categories( $cat_id = null ) {
+    global $wpdb, $wp;
+
+    $taxonomy = GLM_PANEL_CATEGORY_NAME;
+    $args = array(
+        'hide_empty' => false,
+        'pad_counts' => true
+    );
+    if ( $cat_id ) {
+        $args['child_of'] = $cat_id;
+    } else {
+        $args['parent'] = 0;
+    }
+    $taxonomy_terms = get_terms( $taxonomy, $args );
+
+
+    $total_terms = count( $taxonomy_terms );
+    $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
+    $iterator      = 1;
+
+    foreach ( $taxonomy_terms as $term ) {
+        $term->end = false;
+        if ( $iterator === $total_terms) {
+            $term->end = true;
+        }
+        $term->href .= //$current_url
+//             ( ( strpos( $current_url, '?' ) ) ? '&' : '?' ).
+            "?panels_category=" . $term->term_id;
+        ++$iterator;
+    }
+
+    include 'views/list_categories.php';
+    return;
+}
+
+/**
+ * Panel Posts_show_product
+ *
+ * Create a product detail page.
+ *
+ * @param mixed $prod_id
+ * @access public
+ * @return void
+ */
+function panels_show_product( $prod_id ) {
+    global $wpdb, $wp;
+    $product = get_post( $prod_id );
+    include 'views/product_detail.php';
+    return;
+}
+/**
+ * Panel Posts_show_category
+ *
+ * Create a product detail page.
+ *
+ * @param mixed $cat_id
+ * @access public
+ * @return void
+ */
+function panels_show_category( $cat_id ) {
+    global $wpdb, $wp;
+    $term = get_terms(
+        GLM_PANEL_CATEGORY_NAME,
+        array(
+            'child_of'     => $cat_id,
+            'hide_empty'   => true,
+            //'parent'       => $catid_id,
+            //'hierarchical' => false
+        )
+    );
+
+    include 'views/category_detail.php';
+    return;
+}
+add_shortcode( 'panels', 'panels_shortcode' );
+
+
index a091f9e..f548203 100644 (file)
@@ -12,7 +12,7 @@
  */
 
     $sections = of_get_option('parallax_section'); ?>
-    
+     
     <div class="front-page-blocks">
         <?php get_template_part('inc/glm-blocks'); ?>
     </div>
index 5f6c7dd..d404a4c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -12,7 +12,7 @@
  */
 
 get_header(); ?>
-<?php if(of_get_option('enable_parallax') == 1 || of_get_option('enable_parallax') == NUll): 
+<?php if( (of_get_option('enable_parallax') == 1 || of_get_option('enable_parallax') == NUll) && !is_home()): 
        get_template_part('index','parallax');
 else: 
 ?>