Updating template names
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 21 Jun 2016 19:36:48 +0000 (15:36 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 21 Jun 2016 19:36:48 +0000 (15:36 -0400)
get the category form to work

index.php
views/list_categories.php [deleted file]
views/list_products.php [deleted file]
views/list_regions.php [new file with mode: 0644]
views/list_tours.php [new file with mode: 0644]
views/product_detail.php [deleted file]
views/tour_detail.php [new file with mode: 0644]

index e7afa2b..85179df 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,43 +1,43 @@
 <?php
 /*
- * Plugin Name: Michigan Scientific Products
+ * Plugin Name: France Tours Plugin
  * Plugin URI:
- * Description: Michigan Scientific Products
+ * Description: France Tours
  * Version: 0.0.1
  * Author: Steve Sutton <steve@gaslightmedia.com>
  * Author URI:
  * License: GPLv2
  */
 
-define( 'MICHSCI_POST_TYPE', 'miproduct' );
-define( 'MICHSCI_PRODUCT_SINGLE', 'Product' );
-define( 'MICHSCI_PRODUCT_PLURAL', 'Products' );
-define( 'MICHSCI_CATEGORY_NAME', 'michsci_category' );
-define( 'MICHSCI_CATEGORY_SLUG', 'michsci-category' );
-define( 'MICHSCI_CATEGORY_SINGLE', 'Category' );
-define( 'MICHSCI_CATEGORY_PLURAL', 'Categories' );
-define( 'MICHSCI_TAG_NAME', 'michsci_tag' );
-define( 'MICHSCI_TAG_SLUG', 'michsci-tag' );
-define( 'MICHSCI_TAG_SINGLE', 'Tag' );
-define( 'MICHSCI_TAG_PLURAL', 'Tags' );
+define( 'GLM_CUSTOM_POST_TYPE', 'france_tour' );
+define( 'GLM_CUSTOM_TOUR_SINGLE', 'Tour' );
+define( 'GLM_CUSTOM_TOUR_PLURAL', 'Tours' );
+define( 'GLM_CUSTOM_CATEGORY_NAME', 'glm_custom_category' );
+define( 'GLM_CUSTOM_CATEGORY_SLUG', 'glm-custom-category' );
+define( 'GLM_CUSTOM_CATEGORY_SINGLE', 'Region' );
+define( 'GLM_CUSTOM_CATEGORY_PLURAL', 'Regions' );
+define( 'GLM_CUSTOM_TAG_NAME', 'glm_custom_tag' );
+define( 'GLM_CUSTOM_TAG_SLUG', 'glm-custom-tag' );
+define( 'GLM_CUSTOM_TAG_SINGLE', 'Experience' );
+define( 'GLM_CUSTOM_TAG_PLURAL', 'Experiences' );
 
 // Register Custom Post Type
 /**
- * michsci_custom_post_type
+ * Function glm_custom_custom_post_type
  *
  * Setup of the Wordpress Custom Post Type
  *
  * @access public
  * @return void
  */
-function michsci_custom_post_type() {
+function glm_custom_custom_post_type() {
 
        $labels = array(
-               'name'                  => _x( MICHSCI_PRODUCT_PLURAL, 'Post Type General Name' ),
-               'singular_name'         => _x( MICHSCI_PRODUCT_SINGLE, 'Post Type Singular Name' ),
-               'menu_name'             => __( MICHSCI_PRODUCT_PLURAL ),
-               'name_admin_bar'        => __( MICHSCI_PRODUCT_PLURAL ),
-               'archives'              => __( MICHSCI_PRODUCT_SINGLE . ' Archives' ),
+               'name'                  => _x( GLM_CUSTOM_TOUR_PLURAL, 'Post Type General Name' ),
+               'singular_name'         => _x( GLM_CUSTOM_TOUR_SINGLE, 'Post Type Singular Name' ),
+               'menu_name'             => __( GLM_CUSTOM_TOUR_PLURAL ),
+               'name_admin_bar'        => __( GLM_CUSTOM_TOUR_PLURAL ),
+               'archives'              => __( GLM_CUSTOM_TOUR_SINGLE . ' Archives' ),
                'parent_item_colon'     => __( 'Parent Item:' ),
                'all_items'             => __( 'All Items' ),
                'add_new_item'          => __( 'Add New Item' ),
@@ -61,15 +61,15 @@ function michsci_custom_post_type() {
        );
 
        $rewrite = array(
-               'slug'                  => MICHSCI_POST_TYPE,
-               'with_front'            => false,
+               'slug'                  => GLM_CUSTOM_POST_TYPE,
+               'with_front'            => true,
                'pages'                 => false,
                'feeds'                 => false,
        );
 
        $args = array(
-               'label'                 => __( MICHSCI_PRODUCT_SINGLE ),
-               'description'           => __( 'Custom ' . MICHSCI_PRODUCT_PLURAL ),
+               'label'                 => __( GLM_CUSTOM_TOUR_SINGLE ),
+               'description'           => __( 'Custom ' . GLM_CUSTOM_TOUR_PLURAL ),
                'labels'                => $labels,
                'supports'              => array( 'title', 'editor', 'thumbnail', 'revisions' ),
                'hierarchical'          => true,
@@ -86,46 +86,46 @@ function michsci_custom_post_type() {
                'publicly_queryable'    => true,
                'rewrite'               => $rewrite,
                'capability_type'       => 'page',
-               'register_meta_box_cb'  => 'michsci_add_metaboxes',
+               'register_meta_box_cb'  => 'glm_custom_add_metaboxes',
        );
 
-       register_post_type( MICHSCI_POST_TYPE, $args );
-       register_taxonomy_for_object_type( MICHSCI_CATEGORY_NAME, MICHSCI_POST_TYPE );
-       register_taxonomy_for_object_type( MICHSCI_TAG_NAME, MICHSCI_POST_TYPE );
+       register_post_type( GLM_CUSTOM_POST_TYPE, $args );
+       register_taxonomy_for_object_type( GLM_CUSTOM_CATEGORY_NAME, GLM_CUSTOM_POST_TYPE );
+       register_taxonomy_for_object_type( GLM_CUSTOM_TAG_NAME, GLM_CUSTOM_POST_TYPE );
 
 }
 
 /**
- * michsci_add_metaboxes
+ * Function glm_custom_add_metaboxes
  *
  * Add the meta fields
  *
  * @access public
  * @return void
  */
-function michsci_add_metaboxes() {
-        add_meta_box( 'miproduct_features', 'Features', 'miproduct_features', MICHSCI_POST_TYPE, 'normal', 'high' );
-        add_meta_box( 'miproduct_related_products', 'Related Files', 'miproduct_related_products', MICHSCI_POST_TYPE, 'normal', 'high' );
+function glm_custom_add_metaboxes() {
+        add_meta_box( 'glm_custom_features', 'Features', 'glm_custom_features', GLM_CUSTOM_POST_TYPE, 'normal', 'high' );
+        add_meta_box( 'glm_custom_related_tours', 'Related Files', 'glm_custom_related_tours', GLM_CUSTOM_POST_TYPE, 'normal', 'high' );
 }
 
 /**
- * miproduct_features
+ * Function glm_custom_features
  *
  * Add field for the features
  *
  * @access public
  * @return void
  */
-function miproduct_features() {
+function glm_custom_features() {
        global $post;
 
        // get the features for the post
-       $features = get_post_meta( $post->ID, 'miproduct_features', true );
+       $features = get_post_meta( $post->ID, 'glm_custom_features', true );
        // output field
        wp_editor( $features, 'features', array(
                'wpautop'       => true,
                'media_buttons' => false,
-               'textarea_name' => 'miproduct_features',
+               'textarea_name' => 'glm_custom_features',
                'teeny'         => false,
                'editor_height' => 300,
                'quicktags'     => false,
@@ -134,26 +134,26 @@ function miproduct_features() {
 }
 
 /**
- * miproduct_related_products
+ * Function glm_custom_related_tours
  *
- * Adds the field for related product
+ * Adds the field for related tour
  *
  * @access public
  * @return void
  */
-function miproduct_related_products() {
+function glm_custom_related_tours() {
        global $post;
 
        // Noncename needed to verify where the data originated
-        $nonce = wp_create_nonce( 'miproductmeta-meta-noncename' );
-       echo '<input type="hidden" name="miproductmeta-meta-noncename" id="miproductmeta-meta-noncename" value="' . $nonce . '" />';
+        $nonce = wp_create_nonce( 'glm_custommeta-meta-noncename' );
+       echo '<input type="hidden" name="glm_custommeta-meta-noncename" id="glm_custommeta-meta-noncename" value="' . $nonce . '" />';
        // get the features for the post
-       $related_products = get_post_meta( $post->ID, 'miproduct_related_products', true );
+       $related_tours = get_post_meta( $post->ID, 'glm_custom_related_tours', true );
        // output field
-       wp_editor( $related_products, 'related_products', array(
+       wp_editor( $related_tours, 'related_tours', array(
                'wpautop'       => true,
                'media_buttons' => false,
-               'textarea_name' => 'miproduct_related_products',
+               'textarea_name' => 'glm_custom_related_tours',
                'teeny'         => false,
                'editor_height' => 300,
                'quicktags'     => false,
@@ -162,53 +162,53 @@ function miproduct_related_products() {
 }
 
 /**
- * miproduct_save_meta
+ * Function glm_custom_save_meta
  *
- * Saves the meta fields for the product
+ * Saves the meta fields for the tour
  *
  * @access public
  * @return void
  */
-function miproduct_save_meta() {
+function glm_custom_save_meta() {
        global $post;
-       if ( ! wp_verify_nonce( $_POST['miproductmeta-meta-noncename'], 'miproductmeta-meta-noncename' ) ) {
+       if ( ! wp_verify_nonce( $_POST['glm_custommeta-meta-noncename'], 'glm_custommeta-meta-noncename' ) ) {
                return $post->ID;
        }
        if ( ! current_user_can( 'edit_post', $post->ID ) ) {
                return $post->ID;
        }
-       $features         = filter_var( $_POST['miproduct_features'] );
-       $related_products = filter_var( $_POST['miproduct_related_products'] );
-       update_post_meta( $post->ID, 'miproduct_features', $features );
-       update_post_meta( $post->ID, 'miproduct_related_products', $related_products );
+       $features         = filter_var( $_POST['glm_custom_features'] );
+       $related_tours = filter_var( $_POST['glm_custom_related_tours'] );
+       update_post_meta( $post->ID, 'glm_custom_features', $features );
+       update_post_meta( $post->ID, 'glm_custom_related_tours', $related_tours );
 
 }
 
-add_action( 'save_post', 'miproduct_save_meta' );
+add_action( 'save_post', 'glm_custom_save_meta' );
 
 /**
- * michsci_taxonomies
+ * Function glm_custom_taxonomies
  *
  * Setup of the Taxonomies for the post type
  *
  * @access public
  * @return void
  */
-function michsci_taxonomies() {
+function glm_custom_taxonomies() {
 
        // Categories
        $labels = array(
-               'name'              => _x( MICHSCI_CATEGORY_NAME, 'taxonomy general name' ),
-               'singular_name'     => _x( MICHSCI_CATEGORY_NAME, 'taxonomy singular name' ),
-               'search_items'      => __( 'Search ' . MICHSCI_CATEGORY_PLURAL ),
-               'all_items'         => __( 'All ' . MICHSCI_CATEGORY_PLURAL ),
-               'parent_item'       => __( 'Parent ' . MICHSCI_CATEGORY_SINGLE ),
-               'parent_item_colon' => __( 'Parent ' . MICHSCI_CATEGORY_SINGLE ),
-               'edit_item'         => __( 'Edit ' . MICHSCI_CATEGORY_SINGLE ),
-               'update_item'       => __( 'Update ' . MICHSCI_CATEGORY_SINGLE ),
-               'add_new_item'      => __( 'Add New ' . MICHSCI_CATEGORY_SINGLE ),
-               'new_item_name'     => __( 'New ' . MICHSCI_CATEGORY_SINGLE . ' Name' ),
-               'menu_name'         => __( 'Product ' . MICHSCI_CATEGORY_SINGLE ),
+               'name'              => _x( GLM_CUSTOM_CATEGORY_NAME, 'taxonomy general name' ),
+               'singular_name'     => _x( GLM_CUSTOM_CATEGORY_NAME, 'taxonomy singular name' ),
+               'search_items'      => __( 'Search ' . GLM_CUSTOM_CATEGORY_PLURAL ),
+               'all_items'         => __( 'All ' . GLM_CUSTOM_CATEGORY_PLURAL ),
+               'parent_item'       => __( 'Parent ' . GLM_CUSTOM_CATEGORY_SINGLE ),
+               'parent_item_colon' => __( 'Parent ' . GLM_CUSTOM_CATEGORY_SINGLE ),
+               'edit_item'         => __( 'Edit ' . GLM_CUSTOM_CATEGORY_SINGLE ),
+               'update_item'       => __( 'Update ' . GLM_CUSTOM_CATEGORY_SINGLE ),
+               'add_new_item'      => __( 'Add New ' . GLM_CUSTOM_CATEGORY_SINGLE ),
+               'new_item_name'     => __( 'New ' . GLM_CUSTOM_CATEGORY_SINGLE . ' Name' ),
+               'menu_name'         => __( 'Tour ' . GLM_CUSTOM_CATEGORY_SINGLE ),
        );
 
        $capabilities = array(
@@ -219,8 +219,8 @@ function michsci_taxonomies() {
        );
 
        $args = array(
-               'label'                => __( MICHSCI_CATEGORY_PLURAL ),
-               'rewrite'              => array( 'slug' => MICHSCI_CATEGORY_SLUG ),
+               'label'                => __( GLM_CUSTOM_CATEGORY_PLURAL ),
+               'rewrite'              => array( 'slug' => GLM_CUSTOM_CATEGORY_SLUG ),
                'capabilities'         => $capabilities,
                'public '              => true,
                'show_in_quick_edit'   => true,
@@ -229,24 +229,24 @@ function michsci_taxonomies() {
        );
 
         register_taxonomy(
-                MICHSCI_CATEGORY_NAME,
-                MICHSCI_POST_TYPE,
+                GLM_CUSTOM_CATEGORY_NAME,
+                GLM_CUSTOM_POST_TYPE,
                 $args
         );
 
         // Tags
         $labels = array(
-               'name'              => _x( MICHSCI_TAG_SINGLE, 'taxonomy general name' ),
-               'singular_name'     => _x( MICHSCI_TAG_SINGLE, 'taxonomy singular name' ),
-               'search_items'      => __( 'Search ' . MICHSCI_TAG_PLURAL ),
-               'all_items'         => __( 'All ' . MICHSCI_TAG_PLURAL ),
-               'parent_item'       => __( 'Parent ' . MICHSCI_TAG_SINGLE ),
-               'parent_item_colon' => __( 'Parent ' . MICHSCI_TAG_SINGLE ),
-               'edit_item'         => __( 'Edit ' . MICHSCI_TAG_SINGLE ),
-               'update_item'       => __( 'Update ' . MICHSCI_TAG_SINGLE ),
-               'add_new_item'      => __( 'Add New ' . MICHSCI_TAG_SINGLE ),
-               'new_item_name'     => __( 'New ' . MICHSCI_TAG_SINGLE . ' Name' ),
-               'menu_name'         => __( 'Product ' . MICHSCI_TAG_SINGLE ),
+               'name'              => _x( GLM_CUSTOM_TAG_SINGLE, 'taxonomy general name' ),
+               'singular_name'     => _x( GLM_CUSTOM_TAG_SINGLE, 'taxonomy singular name' ),
+               'search_items'      => __( 'Search ' . GLM_CUSTOM_TAG_PLURAL ),
+               'all_items'         => __( 'All ' . GLM_CUSTOM_TAG_PLURAL ),
+               'parent_item'       => __( 'Parent ' . GLM_CUSTOM_TAG_SINGLE ),
+               'parent_item_colon' => __( 'Parent ' . GLM_CUSTOM_TAG_SINGLE ),
+               'edit_item'         => __( 'Edit ' . GLM_CUSTOM_TAG_SINGLE ),
+               'update_item'       => __( 'Update ' . GLM_CUSTOM_TAG_SINGLE ),
+               'add_new_item'      => __( 'Add New ' . GLM_CUSTOM_TAG_SINGLE ),
+               'new_item_name'     => __( 'New ' . GLM_CUSTOM_TAG_SINGLE . ' Name' ),
+               'menu_name'         => __( 'Tour ' . GLM_CUSTOM_TAG_SINGLE ),
         );
 
         $capabilities = array(
@@ -257,8 +257,8 @@ function michsci_taxonomies() {
         );
 
         $args = array(
-               'label'                => __( MICHSCI_TAG_PLURAL ),
-               'rewrite'              => array( 'slug' => MICHSCI_TAG_SLUG ),
+               'label'                => __( GLM_CUSTOM_TAG_PLURAL ),
+               'rewrite'              => array( 'slug' => GLM_CUSTOM_TAG_SLUG ),
                'capabilities'         => $capabilities,
                'public '              => true,
                'show_in_quick_edit'   => true,
@@ -267,21 +267,21 @@ function michsci_taxonomies() {
         );
 
         register_taxonomy(
-                MICHSCI_TAG_NAME,
-                MICHSCI_POST_TYPE,
+                GLM_CUSTOM_TAG_NAME,
+                GLM_CUSTOM_POST_TYPE,
                 $args
         );
 }
 
 /**
- * michsci_taxonomy_filter_restrict_manage_posts
+ * Function glm_custom_taxonomy_filter_restrict_manage_posts
  *
  * This will setup the Filter for the Custom taxonomies.
  *
  * @access public
  * @return void
  */
-function michsci_taxonomy_filter_restrict_manage_posts() {
+function glm_custom_taxonomy_filter_restrict_manage_posts() {
        global $typenow;
 
        $post_types = get_post_types( array( '_builtin' => false ) );
@@ -305,10 +305,10 @@ function michsci_taxonomy_filter_restrict_manage_posts() {
        }
 }
 
-add_action( 'restrict_manage_posts', 'michsci_taxonomy_filter_restrict_manage_posts' );
+add_action( 'restrict_manage_posts', 'glm_custom_taxonomy_filter_restrict_manage_posts' );
 
 /**
- * michsci_taxonomy_filter_post_type_request
+ * Function glm_custom_taxonomy_filter_post_type_request
  *
  * Filter the post request for the Taxonomy Filter
  *
@@ -316,42 +316,40 @@ add_action( 'restrict_manage_posts', 'michsci_taxonomy_filter_restrict_manage_po
  * @access public
  * @return void
  */
-function michsci_taxonomy_filter_post_type_request( $query ) {
+function glm_custom_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;
+                               $var  = $term->slug;
                        }
                }
        }
 }
-add_filter( 'parse_query', 'michsci_taxonomy_filter_post_type_request' );
-add_action( 'init', 'michsci_taxonomies' );
-add_action( 'init', 'michsci_custom_post_type' );
+add_filter( 'parse_query', 'glm_custom_taxonomy_filter_post_type_request' );
+add_action( 'init', 'glm_custom_taxonomies' );
+add_action( 'init', 'glm_custom_custom_post_type' );
 /**
- * michsci_set_admin_columns
+ * Function glm_custom_set_admin_columns
  *
  * Setup of the list columns
  *
  * @access public
  * @return void
  */
-function michsci_set_admin_columns() {
-       add_filter( 'manage_edit-miproduct_columns', 'michsci_admin_edit_columns' );
-       add_action( 'manage_miproduct_posts_custom_column', 'michsci_admin_custom_columns' );
+function glm_custom_set_admin_columns() {
+       add_filter( 'manage_edit-glm_custom_columns', 'glm_custom_admin_edit_columns' );
+       add_action( 'manage_glm_custom_posts_custom_column', 'glm_custom_admin_custom_columns' );
 }
 
-add_action( 'admin_init', 'michsci_set_admin_columns' );
+add_action( 'admin_init', 'glm_custom_set_admin_columns' );
 
 /**
- * michsci_admin_edit_columns
+ * Function glm_custom_admin_edit_columns
  *
  * Setup of the edit columns. This will create the headers for each column.
  *
@@ -359,18 +357,18 @@ add_action( 'admin_init', 'michsci_set_admin_columns' );
  * @access public
  * @return void
  */
-function michsci_admin_edit_columns( $columns ) {
+function glm_custom_admin_edit_columns( $columns ) {
        $columns = array(
-               'cb'                  => '<input type="checkbox">',
-               'title'               => MICHSCI_PRODUCT_SINGLE . ' Title',
-               'michproduct_col_cat' => MICHSCI_CATEGORY_SINGLE,
-               'michproduct_col_tag' => MICHSCI_TAG_SINGLE,
+               'cb'               => '<input type="checkbox">',
+               'title'            => GLM_CUSTOM_TOUR_SINGLE . ' Title',
+               'glm_customtour_col_cat' => GLM_CUSTOM_CATEGORY_SINGLE,
+               'glm_customtour_col_tag' => GLM_CUSTOM_TAG_SINGLE,
        );
        return $columns;
 }
 
 /**
- * michsci_admin_custom_columns
+ * Function glm_custom_admin_custom_columns
  *
  * This will generate the column data for eaoch record.
  *
@@ -378,30 +376,30 @@ function michsci_admin_edit_columns( $columns ) {
  * @access public
  * @return void
  */
-function michsci_admin_custom_columns( $column ) {
+function glm_custom_admin_custom_columns( $column ) {
        global $post;
 
        switch ( $column ) {
-               case 'michproduct_col_cat':
-                       $product_cats      = get_the_terms( $post->ID, 'michsci_category' );
-                       $product_cats_html = array();
-                       if ( $product_cats ) {
-                               foreach ( $product_cats as $product_cat ) {
-                                       array_push( $product_cats_html, $product_cat->name );
+               case 'glm_customtour_col_cat':
+                       $tour_cats      = get_the_terms( $post->ID, 'glm_custom_category' );
+                       $tour_cats_html = array();
+                       if ( $tour_cats ) {
+                               foreach ( $tour_cats as $tour_cat ) {
+                                       array_push( $tour_cats_html, $tour_cat->name );
                                }
-                               echo implode( $product_cats_html, ', ' );
+                               echo implode( $tour_cats_html, ', ' );
                        } else {
                                _e( 'None', 'themeforce' );
                        }
                break;
-               case 'michproduct_col_tag':
-                       $product_tags      = get_the_terms( $post->ID, 'michsci_tag' );
-                       $product_tags_html = array();
-                       if ( $product_tags ) {
-                               foreach ( $product_tags as $product_tag ) {
-                                       array_push( $product_tags_html, $product_tag->name );
+               case 'glm_customtour_col_tag':
+                       $tour_tags      = get_the_terms( $post->ID, 'glm_custom_tag' );
+                       $tour_tags_html = array();
+                       if ( $tour_tags ) {
+                               foreach ( $tour_tags as $tour_tag ) {
+                                       array_push( $tour_tags_html, $tour_tag->name );
                                }
-                               echo implode( $product_tags_html, ', ' );
+                               echo implode( $tour_tags_html, ', ' );
                        } else {
                                 _e( 'None', 'themeforce' );
                        }
@@ -410,7 +408,7 @@ function michsci_admin_custom_columns( $column ) {
 }
 
 /**
- * michsci_shortcode
+ * Function glm_custom_shortcode
  *
  * Add shortcode function. This will call the correct function based on the
  * front end search.
@@ -419,29 +417,43 @@ function michsci_admin_custom_columns( $column ) {
  * @access public
  * @return void
  */
-function michsci_shortcode( $atts ) {
+function glm_custom_shortcode( $atts ) {
+    global $post;
        extract( shortcode_atts( array( 'limit' => '10' ), $atts ) );
        ob_start();
 
        if ( isset( $atts['cat'] ) ) {
-               if ( $prodCategory = get_term_by( 'slug', $atts['cat'], MICHSCI_CATEGORY_NAME ) ) {
-                       if ( ! isset( $_REQUEST[ MICHSCI_CATEGORY_NAME ] ) ) {
-                               $_REQUEST[ MICHSCI_CATEGORY_NAME ] = $prodCategory->term_id;
+               if ( $prodCategory = get_term_by( 'slug', $atts['cat'], GLM_CUSTOM_CATEGORY_NAME ) ) {
+                       if ( ! isset( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] ) ) {
+                               $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] = $prodCategory->term_id;
                        }
                        $cat_id = $prodCategory->term_id;
                }
        }
-       $term = get_term_by( 'id', $_REQUEST[ MICHSCI_CATEGORY_NAME ],'michsci_category' );
+       $term = get_term_by( 'id', $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ], 'glm_custom_category' );
        $name = $term->name;
 
        if ( ! $name ) {
-               $name = 'ALL PRODUCTS';
+               $name = 'ALL TOURS';
        }
        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 michsci_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="">
+    $action = site_url( '/' . $post->post_name . '/' );
+    echo '<form id="catSubmit" action="' . $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="tourSearch">
+                    <a href="' . get_permalink( 510 ) .   '"> Search Tours </a>
+                </span>
+            </div>
+            <div id="catDropdown" class="small-12 medium-4 columns">';
+       echo glm_custom_get_terms_dropdown( $cat_id );
+    echo '</div>
+         <input id="input" class="search-button" name="searchButton" value="Search" type="submit">
+        </form>
+        <div id="searchContainer" class="small-12 medium-3 columns">
+        <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">
         
@@ -449,21 +461,21 @@ function michsci_shortcode( $atts ) {
     </a>
        </form></div></div>';
 
-       if ( $product_id = filter_var( $_REQUEST['product'], FILTER_VALIDATE_INT ) ) {
-               michsci_show_product( $product_id );
+       if ( $tour_id = filter_var( $_REQUEST['tour'], FILTER_VALIDATE_INT ) ) {
+        echo '<pre>$tour_id: ' . print_r($tour_id, true) . '</pre>';
+               glm_custom_show_tour( $tour_id );
        } else if ( $cat_id = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
-               michsci_list_categories( $cat_id );
-       } else if ( ! $catid_id && ! $product_id ) {
-               // $text_query = $_REQUEST['tsearch'];
+        echo '<pre>$cat_id: ' . print_r($cat_id, true) . '</pre>';
+               glm_custom_list_categories( $cat_id );
+       } else if ( ! $catid_id && ! $tour_id ) {
                $text_query = filter_var( $_REQUEST['tsearch'], FILTER_SANITIZE_STRING );
-               // strip_tags($text_query);
                if ( isset( $_REQUEST['tsearch'] ) ) {
-                       setcookie( 'search', 'true',time() + 2, '/' );
+                       //setcookie( 'search', 'true',time() + 2, '/' );
                } else {
-                       setcookie( 'search', 'null',time() + 2, '/' );
+                       //setcookie( 'search', 'null',time() + 2, '/' );
                }
-               michsci_list_products( $text_query );
-               michsci_list_categories();
+               glm_custom_list_tours( $text_query );
+               //glm_custom_list_categories();
        }
 
        $output = ob_get_contents();
@@ -472,66 +484,66 @@ function michsci_shortcode( $atts ) {
 }
 
 /**
- * michsci_get_terms_dropdown
+ * Function glm_custom_get_terms_dropdown
  *
  * Generate the taxonomy drop down select
  *
  * @access public
  * @return void
  */
-function michsci_get_terms_dropdown( $cat_id ) {
+function glm_custom_get_terms_dropdown( $cat_id ) {
        // $test = $_REQUEST['tsearch'];
        // $filterTest = filter_var($test, FILTER_SANITIZE_STRING);
        // echo $filterTest;
-       $taxonomyName = MICHSCI_CATEGORY_NAME;
+       $taxonomy_name = GLM_CUSTOM_CATEGORY_NAME;
        if ( $cat_id ) {
-               $main = get_term( $cat_id, MICHSCI_CATEGORY_NAME );
-               $cats_child = get_term_children( $cat_id, $taxonomyName );
-               $output = "<select id='categoryDropdown' name=\"" . MICHSCI_CATEGORY_NAME . '"><option value=""> Select ' . $main->name . ' Sub-category' . '</option>';
+               $main = get_term( $cat_id, GLM_CUSTOM_CATEGORY_NAME );
+               $cats_child = get_term_children( $cat_id, $taxonomy_name );
+               $output = "<select id='categoryDropdown' name=\"" . GLM_CUSTOM_CATEGORY_NAME . '"><option value=""> Select ' . $main->name . ' Sub-category' . '</option>';
                foreach ( $cats_child as $cat ) {
                        $output .= '<option value="' . $cat . '"';
-                       if ( $_REQUEST[ MICHSCI_CATEGORY_NAME ] == $cat ) {
+                       if ( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] == $cat ) {
                                $output .= ' selected';
                        }
-                       $catName = get_term( $cat, MICHSCI_CATEGORY_NAME );
-                        $output .= '>' . '&nbsp&nbsp&nbsp' . $catName->name. '</option>';
+                       $cat_name = get_term( $cat, GLM_CUSTOM_CATEGORY_NAME );
+                        $output .= '>' . '&nbsp&nbsp&nbsp' . $cat_name->name. '</option>';
                }
                $output .= '</select>';
        } else {
 
-               $parent_terms = get_terms( $taxonomyName, array( 'parent' => 0, 'orderby' => 'name', 'hide_empty' => false ) );
-               $terms = get_terms( $taxonomyName, array( 'orderby' => 'name', 'hide_empty' => false ) );
+               $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=\"" . MICHSCI_CATEGORY_NAME . '"><option value="">Select ' . MICHSCI_CATEGORY_SINGLE . '</option>';
+               $output = "<select id='categoryDropdown' name=\"" . GLM_CUSTOM_CATEGORY_NAME . '"><option value="">Select ' . GLM_CUSTOM_CATEGORY_SINGLE . '</option>';
                // get parent categories
                foreach ( $parent_terms as $parent ) {
                        // get children of each category
-                       $child_terms = get_terms( $taxonomyName, array( 'parent' => $parent->term_id, 'child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false ) );
+                       $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[ MICHSCI_CATEGORY_NAME ] == $parent->term_id ) {
+                       if ( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] == $parent->term_id ) {
                                $output .= ' selected';
                        }
                        $output .= '>' . $parent->name . '</option>';
                        foreach ( $child_terms as $child ) {
-                               $grandchildren = get_terms( $taxonomyName, array( 'parent' => $child->term_id, 'child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false ) );
+                               $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[ MICHSCI_CATEGORY_NAME ] == $child->term_id ) {
+                               if ( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] == $child->term_id ) {
                                        $output .= ' selected';
                                }
-                               $output .= '>' . '&nbsp&nbsp&nbsp' .  $child->name . '</option>';
+                               $output .= '>&nbsp&nbsp&nbsp' .  $child->name . '</option>';
                                foreach ( $grandchildren as $gchild ) {
-                                       $ggrandchildren = get_terms( $taxonomyName, array( 'parent' => $gchild->term_id, 'child_of' => $gchild->term_id, 'orderby' => 'name', 'hide_empty' => false ) );
+                                       $ggrandchildren = get_terms( $taxonomy_name, array( 'parent' => $gchild->term_id, 'child_of' => $gchild->term_id, 'orderby' => 'name', 'hide_empty' => false ) );
                                        $output .= '<option value="' . $gchild->term_id . '"';
-                                       if ( $_REQUEST[ MICHSCI_CATEGORY_NAME ] == $gchild->term_id ) {
+                                       if ( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] == $gchild->term_id ) {
                                                $output .= ' selected';
                                        }
-                                       $output .= '>' . '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' .  $gchild->name . '</option>';
+                                       $output .= '>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' .  $gchild->name . '</option>';
                                        foreach ( $ggrandchildren as $ggchild ) {
                                                 $output .= '<option value="' . $ggchild->term_id . '"';
-                                               if ( $_REQUEST[ MICHSCI_CATEGORY_NAME ] == $ggchild->term_id ) {
+                                               if ( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] == $ggchild->term_id ) {
                                                        $output .= ' selected';
                                                }
-                                               $output .= '>' . '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' .  $ggchild->name . '</option>';
+                                               $output .= '>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' .  $ggchild->name . '</option>';
                                        }
                                }
                        }
@@ -542,70 +554,58 @@ function michsci_get_terms_dropdown( $cat_id ) {
 
 
 /**
- * michsci_list_products
+ * Function glm_custom_list_tours
  *
- * Create a list of products.
+ * Create a list of tours.
  *
  * @access public
  * @return void
  */
-function michsci_list_products( $text_query ) {
+function glm_custom_list_tours( $text_query ) {
        global $wpdb, $wp;
 
-       $cat = get_term( $cat_id, MICHSCI_CATEGORY_NAME );
+       //$cat = get_term( $cat_id, GLM_CUSTOM_CATEGORY_NAME );
        $args = array(
                'posts_per_page' => -1,
-               'post_type'     => 'miproduct',
-               's' => $text_query,
-       // 'meta_query' => array(
-       // array(
-       // 'key' => 'post_title',
-       // 'value' => $text_query,
-       // 'compare' => 'LIKE'
-       // )
-       // )
-          // add meta query here
+               'post_type'      => GLM_CUSTOM_POST_TYPE,
+               's'              => $text_query,
        );
-       $misch_category = ( isset( $_REQUEST[ MICHSCI_CATEGORY_NAME ] ) )
-               ? filter_var( $_REQUEST[ MICHSCI_CATEGORY_NAME ] )
+       $glm_category = ( isset( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] ) )
+               ? filter_var( $_REQUEST[ GLM_CUSTOM_CATEGORY_NAME ] )
                : false;
 
-       if ( $misch_category ) {
+       if ( $glm_category ) {
                $args['tax_query'] = array(
                        'relation' => 'AND',
                );
-               $args['tax_query'][] = array(
-                       'taxonomy' => MICHSCI_CATEGORY_NAME,
-                       'field'    => 'id',
-                       'terms'    => $misch_category,
-               );
-       }
-
-       $products      = get_posts( $args );
-       $totalProducts = count( $products );
-       $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
-       $iterator      = 1;
-
-       foreach ( $products as $product ) {
-               $productTerms = wp_get_post_terms( $product->ID, MICHSCI_CATEGORY_NAME, 'name' );
-               $pTerm = $productTerms[0];
-               $product->term = $pTerm->name;
-               $product->end = false;
-               if ( $iterator == $totalProducts ) {
-                       $product->end = true;
-               }
-               $cat->href = '?michsci_category=';
-               $product->href = $current_url
-                       . ( ( strpos( $current_url, '?' ) ) ? '&' : '?' )
-                       . 'product=' . $product->ID;
-               ++$iterator;
-       }
-       // echo '<pre>' . print_r($products, true) . '</pre>';
-       include 'views/list_products.php';
-       return;
+        $args['tax_query'][] = array(
+            'taxonomy' => GLM_CUSTOM_CATEGORY_NAME,
+            'field'    => 'id',
+            'terms'    => $glm_category,
+        );
+    }
+
+    $tours      = get_posts( $args );
+    $totalTours = count( $tours );
+    $iterator      = 1;
+
+    foreach ( $tours as $tour ) {
+        $tourTerms = wp_get_post_terms( $tour->ID, GLM_CUSTOM_CATEGORY_NAME, 'name' );
+        $pTerm = $tourTerms[0];
+        $tour->term = $pTerm->name;
+        $tour->end = false;
+        if ( $iterator == $totalTours ) {
+            $tour->end = true;
+        }
+        //$cat->href  = '?glm_custom_category=';
+        $tour->href = site_url( '/' . GLM_CUSTOM_POST_TYPE . '/' . $tour->post_name .'/' );
+        ++$iterator;
+    }
+    include 'views/list_tours.php';
+    return;
 }
 /**
- * michsci_list_categories
+ * Function glm_custom_list_categories
  *
  * Create a list of categories.
  *
@@ -613,10 +613,10 @@ function michsci_list_products( $text_query ) {
  * @access public
  * @return void
  */
-function michsci_list_categories( $cat_id = null ) {
+function glm_custom_list_categories( $cat_id = null ) {
        global $wpdb, $wp;
 
-       $taxonomy = MICHSCI_CATEGORY_NAME;
+       $taxonomy = GLM_CUSTOM_CATEGORY_NAME;
        $args = array(
                'hide_empty' => false,
                'pad_counts' => true,
@@ -629,7 +629,6 @@ function michsci_list_categories( $cat_id = null ) {
        $taxonomy_terms = get_terms( $taxonomy, $args );
 
        $totalTerms = count( $taxonomy_terms );
-       $current_url   = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
        $iterator      = 1;
 
        foreach ( $taxonomy_terms as $term ) {
@@ -637,55 +636,65 @@ function michsci_list_categories( $cat_id = null ) {
                if ( $iterator == $totalTerms ) {
                        $term->end = true;
                }
-               $term->href .= // $current_url
-               // ( ( strpos( $current_url, '?' ) ) ? '&' : '?' )
-                       '?michsci_category=' . $term->term_id;
+               $term->href .= '?glm_custom_category=' . $term->term_id;
                ++$iterator;
        }
 
-       include 'views/list_categories.php';
+       include 'views/list_regions.php';
        return;
 }
 
 /**
- * michsci_show_product
+ * Function glm_custom_show_tour
  *
- * Create a product detail page.
+ * Create a tour detail page.
  *
  * @param mixed $prod_id
  * @access public
  * @return void
  */
-function michsci_show_product( $prod_id ) {
+function glm_custom_show_tour( $prod_id ) {
        global $wpdb, $wp;
-       $product = get_post( $prod_id );
-       include 'views/product_detail.php';
+       $tour = get_post( $prod_id );
+       include 'views/tour_detail.php';
        return;
 }
 /**
- * michsci_show_category
+ * Function glm_custom_show_category
  *
- * Create a product detail page.
+ * Create a tour detail page.
  *
  * @param mixed $cat_id
  * @access public
  * @return void
  */
-function michsci_show_category( $cat_id ) {
+function glm_custom_show_category( $cat_id ) {
        global $wpdb, $wp;
        $term = get_terms(
-               MICHSCI_CATEGORY_NAME,
+               GLM_CUSTOM_CATEGORY_NAME,
                array(
                        'child_of'     => $cat_id,
                        'hide_empty'   => true,
-                       // 'parent'       => $catid_id,
-                       // 'hierarchical' => false
                )
        );
-       echo '<pre>' . print_r( $term, true ) . '</pre>';
        include 'views/category_detail.php';
        return;
 }
-add_shortcode( 'michproducts', 'michsci_shortcode' );
-
-
+add_shortcode( GLM_CUSTOM_POST_TYPE, 'glm_custom_shortcode' );
+$rules = get_option( 'rewrite_rules' );
+if ( ! isset( $rules['(' . GLM_CUSTOM_POST_TYPE . ')/([^/]*)$'] ) ) {
+    add_filter( 'rewrite_rules_array', function( $rules ){
+        $newrules = array();
+        $newrules[''] = 'index.php?pagename=$matches[1]&tour=$matches[2]';
+        return $newrules + $rules;
+    } );
+
+    add_filter( 'init', function(){
+        global $wp_rewrite;
+        $wp_rewrite->flush_rules();
+    } );
+}
+add_filter( 'query_vars', function( $vars ) {
+    array_push( $vars, 'glm_custom_id' );
+    return $vars;
+} );
diff --git a/views/list_categories.php b/views/list_categories.php
deleted file mode 100644 (file)
index 4a4d801..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "grid"){ ?>
- <?php $cat_id = $_REQUEST['michsci_category']; 
- $test = get_ancestors($cat_id, "michsci_category");
- if($cat_id){ ?>
-      <?php $ancestors = get_category_parents($cat_id, false, " > "); ?>
-<div class="small-12 medium-6" id="productBreadcrumbs">
- <?php echo '<a href="'. get_permalink(510) .  '">' . Products . '</a>'." > "; ?>
-    <?php echo '<a href="'.  '?michsci_category=' . $cat_id . '" >' . print_r($ancestors, true) . "<br>"; ?>
-</div>
- <?php } ?>
-<div id="categoriesGridView" class="row">
-<?php get_template_part('parts/sidebar-l'); ?>
-<?php
-    if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
-        foreach ( $taxonomy_terms  as $term ) : ?>
-
-    <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>
-        <div class="small-12 medium-4 columns<?php if ($term->end){ echo ' end';}?>">
-          <div class="row">
-         <div class="catContainer small-12 columns"><a href="<?php echo $term->href; ?>">
-                          <img id="catImg" src="<?php echo z_taxonomy_image_url($term->term_id, array(320, 285)); ?>" class="image wp-post-image no-display" alt="<?php echo $term->name; ?>" title="<?php echo $term->name; ?>" itemprop="image">
-        
-             <div id="catTitleGrid" class="small-12 columns">
-                 <a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
-             </div>
-        </div>
-            </div>
-        </div>
-    <?php
-        endforeach;
-    endif; ?>
-</div>
-<?php } ?>
-<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "list"){ ?>
-<div id="categoriesListView" class="row">
-    <?php get_template_part('parts/sidebar-l'); ?>
-<?php
-    if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
-        foreach ( $taxonomy_terms  as $term ) : ?>
-    <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>
-    <pre><?php  //echo print_r( $term, true ) ?></pre>
-    
-      <div class="small-12 columns<?php if ($term->end){ echo ' end';}?>">
-       <div class="row">
-         <div id="catContainer" class= "small-12 columns"><a href="<?php echo $term->href; ?>">
-            <div id="catImgContainer" class="small-12 medium-4 columns">
-               <img id="catImg" src="<?php echo z_taxonomy_image_url($term->term_id, 'thumbnail'); ?>" class="image wp-post-image no-display" alt="<?php echo $term->name; ?>" title="<?php echo $term->name; ?>" itemprop="image">
-            </div>
-          
-             <div id="catTitleList" class="small-12 medium-4 columns">
-                <a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
-             </div>
-             <div id="padding" class="small-12 medium-4 columns">
-               
-             </div>
-         </div>
-               
-            </div>
-        </div>
-    <?php
-        endforeach;
-    endif; ?>
-
-</div>
-<?php } 
\ No newline at end of file
diff --git a/views/list_products.php b/views/list_products.php
deleted file mode 100644 (file)
index 321abd5..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
- <?php $cat_id = $_REQUEST[MICHSCI_CATEGORY_NAME]; ?>
-<?php $term = get_term($cat_id, MICHSCI_CATEGORY_NAME); ?>
-<?php if(!isset($_COOKIE['view']) || $_COOKIE['view'] == "grid"){ ?>
-<?php echo '<h1 id="catTitleOutput">' . $term->name . '</h1>'; ?>
-<?php //get_template_part('parts/sidebar-l'); ?>
-    <div id="gridView" class="row">
-    <?php 
-       echo category_description($cat_id);
-       $cat_children = get_term_children($cat_id, MICHSCI_CATEGORY_NAME);
-    ?>
-          <?php $term = get_term($cat_id, MICHSCI_CATEGORY_NAME); ?>
-     <?php if($_COOKIE['subcat'] == "subcat"){ ?>
-    
-        <?php foreach($cat_children as $cats){
-            $term = get_term($cats, MICHSCI_CATEGORY_NAME); ?>
-            <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
-            <div class="subcat <?php echo $term->slug;?> grid small-12 medium-4 columns<?php if ($product->end){ echo ' end';}?>">
-                <div class="prodImgGrid small-12 columns"><a href="<?php echo $cat->href . $term->term_id; ?>">
-                     <img id="catImg" src="<?php echo z_taxonomy_image_url($cats, array(320, 285)); ?>" class="image wp-post-image no-display" alt=" "  title="<?php echo $term->name; ?>" itemprop="image">
-                </div>
-
-                <div class="prodTitleGrid small-12 columns">
-                    <a href="<?php echo $cat->href . $term->term_id; ?>"><strong><?php echo $term->name; ?></strong></a>
-                </div>
-        </div>
-        <?php  } ?>
-     <?php } else { ?>
-   <?php if ( isset( $products ) && is_array( $products ) ) : foreach ( $products as $product ) : ?>
-   <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
-        <div class="<?php foreach ($tags as $tag)echo $tag->slug . " ";?> product grid small-12 medium-4 columns<?php if ($product->end){ echo ' end';}?>">
-                <div class="prodImgGrid small-12 columns"><a href="<?php echo $product->href; ?>">
-                    <?php echo get_the_post_thumbnail( $product->ID, array(320, 285)); ?></a>
-                </div>
-                <div class="subCatGrid small-12 columns">
-                    <a href="<?php echo $product->href; ?>"><?php echo $product->term; ?></a>
-                </div>
-                <div class="prodTitleGrid small-12 columns">
-                    <a href="<?php echo $product->href; ?>"><strong><?php echo $product->post_title; ?></strong></a>
-                </div>
-            
-        </div>
-    <?php endforeach; endif; ?>
-    </div>
-     <?php } ?>
-<?php } ?>
-
-
-<?php if($_COOKIE['view'] == "list"){ ?>
-<?php echo '<h1 id="catTitleOutput">' . $term->name . '</h1>'; ?>
-   <div id="listView" class="row">
-         <?php 
-       echo category_description($cat_id);
-       $cat_children = get_term_children($cat_id, MICHSCI_CATEGORY_NAME);
-    ?>
-          <?php $term = get_term($cat_id, MICHSCI_CATEGORY_NAME); ?>
-     <?php if($_COOKIE['subcat'] == "subcat"){ ?>
-    
-        <?php foreach($cat_children as $cats){
-            $term = get_term($cats, MICHSCI_CATEGORY_NAME); ?>
-            <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
-            <div class="subcat <?php echo $term->slug;?> list small-12 columns<?php if ($product->end){ echo ' end';}?>">
-                <div class="prodImgList small-12 medium-3 columns"><a href="<?php echo $cat->href . $term->term_id; ?>">
-                     <img id="catImg" src="<?php echo z_taxonomy_image_url($cats, array(320, 285)); ?>" class="image wp-post-image no-display" alt=" "  title="<?php echo $term->name; ?>" itemprop="image">
-                </div>
-
-                <div class="prodTitleList small-12 medium-3 columns">
-                    <a href="<?php echo $cat->href . $term->term_id; ?>"><strong><?php echo $term->name; ?></strong></a>
-                </div>
-        </div>
-        <?php  } ?>
-     <?php } else { ?>
-        
-    <?php if ( isset( $products ) && is_array( $products ) ) : foreach ( $products as $product ) : ?>
-<!--    <div class="row view">-->
-<?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
- <div class="<?php foreach ($tags as $tag)echo $tag->slug . " ";?>product list small-12 columns<?php if ($product->end){ echo ' end';}?>">
-           
-                <div class="prodImgList small-12 large-3 columns"><a href="<?php echo $product->href; ?>">
-            <?php echo get_the_post_thumbnail( $product->ID, 'post-thumbnail'); ?></a>
-                </div>
-                <div class="prodTitleList small-12 large-3 columns">
-                    <a href="<?php echo $product->href; ?>"><strong><?php echo $product->post_title; ?></strong></a>
-                </div>
-                <div class="subCatList small-12 large-3 columns">
-                    <a href="<?php echo $product->href; ?>"><?php echo $product->term; ?></a>
-                </div>
-       </div>
-<!--        </div>-->
-    <?php endforeach; endif; ?>
-   </div>
- <?php } ?>
-   <?php } ?>
-
-
-
diff --git a/views/list_regions.php b/views/list_regions.php
new file mode 100644 (file)
index 0000000..40ddfc2
--- /dev/null
@@ -0,0 +1,65 @@
+<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "grid"){ ?>
+ <?php $cat_id = $_REQUEST['glm_custom_category']; 
+ $test = get_ancestors($cat_id, "glm_custom_category");
+ if($cat_id){ ?>
+      <?php $ancestors = get_category_parents($cat_id, false, " > "); ?>
+<div class="small-12 medium-6" id="productBreadcrumbs">
+ <?php echo '<a href="'. get_permalink(510) .  '">' . Products . '</a>'." > "; ?>
+    <?php echo '<a href="'.  '?glm_custom_category=' . $cat_id . '" >' . print_r($ancestors, true) . "<br>"; ?>
+</div>
+ <?php } ?>
+<div id="categoriesGridView" class="row">
+<?php get_template_part('parts/sidebar-l'); ?>
+<?php
+    if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
+        foreach ( $taxonomy_terms  as $term ) : ?>
+
+    <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>
+        <div class="small-12 medium-4 columns<?php if ($term->end){ echo ' end';}?>">
+          <div class="row">
+         <div class="catContainer small-12 columns"><a href="<?php echo $term->href; ?>">
+                          <img id="catImg" src="<?php echo z_taxonomy_image_url($term->term_id, array(320, 285)); ?>" class="image wp-post-image no-display" alt="<?php echo $term->name; ?>" title="<?php echo $term->name; ?>" itemprop="image">
+        
+             <div id="catTitleGrid" class="small-12 columns">
+                 <a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
+             </div>
+        </div>
+            </div>
+        </div>
+    <?php
+        endforeach;
+    endif; ?>
+</div>
+<?php } ?>
+<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "list"){ ?>
+<div id="categoriesListView" class="row">
+    <?php get_template_part('parts/sidebar-l'); ?>
+<?php
+    if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
+        foreach ( $taxonomy_terms  as $term ) : ?>
+    <?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>
+    <pre><?php  //echo print_r( $term, true ) ?></pre>
+    
+      <div class="small-12 columns<?php if ($term->end){ echo ' end';}?>">
+       <div class="row">
+         <div id="catContainer" class= "small-12 columns"><a href="<?php echo $term->href; ?>">
+            <div id="catImgContainer" class="small-12 medium-4 columns">
+               <img id="catImg" src="<?php echo z_taxonomy_image_url($term->term_id, 'thumbnail'); ?>" class="image wp-post-image no-display" alt="<?php echo $term->name; ?>" title="<?php echo $term->name; ?>" itemprop="image">
+            </div>
+          
+             <div id="catTitleList" class="small-12 medium-4 columns">
+                <a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
+             </div>
+             <div id="padding" class="small-12 medium-4 columns">
+               
+             </div>
+         </div>
+               
+            </div>
+        </div>
+    <?php
+        endforeach;
+    endif; ?>
+
+</div>
+<?php } 
diff --git a/views/list_tours.php b/views/list_tours.php
new file mode 100644 (file)
index 0000000..e7abfc9
--- /dev/null
@@ -0,0 +1,95 @@
+ <?php $cat_id = $_REQUEST[GLM_CUSTOM_CATEGORY_NAME]; ?>
+<?php $term = get_term($cat_id, GLM_CUSTOM_CATEGORY_NAME); ?>
+<?php if(!isset($_COOKIE['view']) || $_COOKIE['view'] == "grid"){ ?>
+<?php echo '<h1 id="catTitleOutput">' . $term->name . '</h1>'; ?>
+<?php //get_template_part('parts/sidebar-l'); ?>
+    <div id="gridView" class="row">
+    <?php 
+       echo category_description($cat_id);
+       $cat_children = get_term_children($cat_id, GLM_CUSTOM_CATEGORY_NAME);
+    ?>
+          <?php $term = get_term($cat_id, GLM_CUSTOM_CATEGORY_NAME); ?>
+     <?php if($_COOKIE['subcat'] == "subcat"){ ?>
+    
+        <?php foreach($cat_children as $cats){
+            $term = get_term($cats, GLM_CUSTOM_CATEGORY_NAME); ?>
+            <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
+            <div class="subcat <?php echo $term->slug;?> grid small-12 medium-4 columns<?php if ($product->end){ echo ' end';}?>">
+                <div class="prodImgGrid small-12 columns"><a href="<?php echo $cat->href . $term->term_id; ?>">
+                     <img id="catImg" src="<?php echo z_taxonomy_image_url($cats, array(320, 285)); ?>" class="image wp-post-image no-display" alt=" "  title="<?php echo $term->name; ?>" itemprop="image">
+                </div>
+
+                <div class="prodTitleGrid small-12 columns">
+                    <a href="<?php echo $cat->href . $term->term_id; ?>"><strong><?php echo $term->name; ?></strong></a>
+                </div>
+        </div>
+        <?php  } ?>
+     <?php } else { ?>
+   <?php if ( isset( $tours ) && is_array( $tours ) ) : foreach ( $tours as $product ) : ?>
+   <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
+        <div class="<?php foreach ($tags as $tag)echo $tag->slug . " ";?> product grid small-12 medium-4 columns<?php if ($product->end){ echo ' end';}?>">
+                <div class="prodImgGrid small-12 columns"><a href="<?php echo $product->href; ?>">
+                    <?php echo get_the_post_thumbnail( $product->ID, array(320, 285)); ?></a>
+                </div>
+                <div class="subCatGrid small-12 columns">
+                    <a href="<?php echo $product->href; ?>"><?php echo $product->term; ?></a>
+                </div>
+                <div class="prodTitleGrid small-12 columns">
+                    <a href="<?php echo $product->href; ?>"><strong><?php echo $product->post_title; ?></strong></a>
+                </div>
+            
+        </div>
+    <?php endforeach; endif; ?>
+    </div>
+     <?php } ?>
+<?php } ?>
+
+
+<?php if($_COOKIE['view'] == "list"){ ?>
+<?php echo '<h1 id="catTitleOutput">' . $term->name . '</h1>'; ?>
+   <div id="listView" class="row">
+         <?php 
+       echo category_description($cat_id);
+       $cat_children = get_term_children($cat_id, GLM_CUSTOM_CATEGORY_NAME);
+    ?>
+          <?php $term = get_term($cat_id, GLM_CUSTOM_CATEGORY_NAME); ?>
+     <?php if($_COOKIE['subcat'] == "subcat"){ ?>
+    
+        <?php foreach($cat_children as $cats){
+            $term = get_term($cats, GLM_CUSTOM_CATEGORY_NAME); ?>
+            <?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
+            <div class="subcat <?php echo $term->slug;?> list small-12 columns<?php if ($product->end){ echo ' end';}?>">
+                <div class="prodImgList small-12 medium-3 columns"><a href="<?php echo $cat->href . $term->term_id; ?>">
+                     <img id="catImg" src="<?php echo z_taxonomy_image_url($cats, array(320, 285)); ?>" class="image wp-post-image no-display" alt=" "  title="<?php echo $term->name; ?>" itemprop="image">
+                </div>
+
+                <div class="prodTitleList small-12 medium-3 columns">
+                    <a href="<?php echo $cat->href . $term->term_id; ?>"><strong><?php echo $term->name; ?></strong></a>
+                </div>
+        </div>
+        <?php  } ?>
+     <?php } else { ?>
+        
+    <?php if ( isset( $tours ) && is_array( $tours ) ) : foreach ( $tours as $product ) : ?>
+<!--    <div class="row view">-->
+<?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
+ <div class="<?php foreach ($tags as $tag)echo $tag->slug . " ";?>product list small-12 columns<?php if ($product->end){ echo ' end';}?>">
+           
+                <div class="prodImgList small-12 large-3 columns"><a href="<?php echo $product->href; ?>">
+            <?php echo get_the_post_thumbnail( $product->ID, 'post-thumbnail'); ?></a>
+                </div>
+                <div class="prodTitleList small-12 large-3 columns">
+                    <a href="<?php echo $product->href; ?>"><strong><?php echo $product->post_title; ?></strong></a>
+                </div>
+                <div class="subCatList small-12 large-3 columns">
+                    <a href="<?php echo $product->href; ?>"><?php echo $product->term; ?></a>
+                </div>
+       </div>
+<!--        </div>-->
+    <?php endforeach; endif; ?>
+   </div>
+ <?php } ?>
+   <?php } ?>
+
+
+
diff --git a/views/product_detail.php b/views/product_detail.php
deleted file mode 100644 (file)
index 278712f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-
-<?php
-$args = array(
-    'orderby' => 'parent',
-    'hierarchical'=> true,
-);
-$relatives = wp_get_post_terms($product->ID, 'michsci_category', $args);
-?>
-<div class="small-12 medium-6" id="productBreadcrumbs">
- <?php echo '<a href="'. get_permalink(510) .  '">' . Products . '</a>'." > "; ?>
-<?php foreach($relatives as $relative){
-    echo '<a href="'.  '?michsci_category=' . $relative->term_id . '" >' . $relative->name . "</a>" . " > ";
-} ?>
-    <?php echo $product->post_title . "<br>"; ?>
-</div>
-<h2><?php echo $product->post_title; ?></h2>
-
-<div class="row">
-    <div class="productImage small-12 medium-4 columns">
-           <?php echo get_the_post_thumbnail($product->ID, 'large'); ?>
-    </div>
-    <div class="features small-12 medium-4 columns">
-         <?php
-         echo '<h2> Features </h2>';
-            $key_value = get_post_custom_values('miproduct_features', $product->ID); 
-            foreach($key_value as $key=>$value){
-                $shortcode_output = do_shortcode($value);
-                print $shortcode_output;
-        }?>
-    </div>
-    <div id="relatedFiles" class='small-12 medium-4 columns'>
-        <h3> Related Files </h3>
-        <?php
-            $key_value = get_post_custom_values('miproduct_related_products', $product->ID); 
-            foreach($key_value as $key=>$value){
-                $shortcode_output = do_shortcode($value);
-                print $shortcode_output;
-        }?>
-         <div class="gallery ">
-          <?php echo '<h4><a class="galleryLink" href="#glm_gallery"> Product Gallery </a></h4>'; ?>
-          <div class="tags">
-          <?php echo "<h4 class='tagsTitle'> Related Products </h4><br>"; 
-                $args = array(
-                "hide_empty"=>false
-            );
-            $tags = wp_get_post_terms($product->ID,'michsci_tag', $args);
-            foreach ($tags as $tag){ ?>
-                <?php echo '<a id="' . $tag->slug . '"href="'.  get_permalink(510) . '">'. $tag->name . '</a>' . "<br>"; ?> 
-            <?php }?>
-        </div>
-</div>
-        
-    </div>
-    <div class="description small-12 medium-7 columns">
-        <?php
-            setup_postdata( $product );
-            the_content(); 
-        ?>
-    </div>
-        
-    </div>
-
-</div>
diff --git a/views/tour_detail.php b/views/tour_detail.php
new file mode 100644 (file)
index 0000000..278712f
--- /dev/null
@@ -0,0 +1,64 @@
+
+<?php
+$args = array(
+    'orderby' => 'parent',
+    'hierarchical'=> true,
+);
+$relatives = wp_get_post_terms($product->ID, 'michsci_category', $args);
+?>
+<div class="small-12 medium-6" id="productBreadcrumbs">
+ <?php echo '<a href="'. get_permalink(510) .  '">' . Products . '</a>'." > "; ?>
+<?php foreach($relatives as $relative){
+    echo '<a href="'.  '?michsci_category=' . $relative->term_id . '" >' . $relative->name . "</a>" . " > ";
+} ?>
+    <?php echo $product->post_title . "<br>"; ?>
+</div>
+<h2><?php echo $product->post_title; ?></h2>
+
+<div class="row">
+    <div class="productImage small-12 medium-4 columns">
+           <?php echo get_the_post_thumbnail($product->ID, 'large'); ?>
+    </div>
+    <div class="features small-12 medium-4 columns">
+         <?php
+         echo '<h2> Features </h2>';
+            $key_value = get_post_custom_values('miproduct_features', $product->ID); 
+            foreach($key_value as $key=>$value){
+                $shortcode_output = do_shortcode($value);
+                print $shortcode_output;
+        }?>
+    </div>
+    <div id="relatedFiles" class='small-12 medium-4 columns'>
+        <h3> Related Files </h3>
+        <?php
+            $key_value = get_post_custom_values('miproduct_related_products', $product->ID); 
+            foreach($key_value as $key=>$value){
+                $shortcode_output = do_shortcode($value);
+                print $shortcode_output;
+        }?>
+         <div class="gallery ">
+          <?php echo '<h4><a class="galleryLink" href="#glm_gallery"> Product Gallery </a></h4>'; ?>
+          <div class="tags">
+          <?php echo "<h4 class='tagsTitle'> Related Products </h4><br>"; 
+                $args = array(
+                "hide_empty"=>false
+            );
+            $tags = wp_get_post_terms($product->ID,'michsci_tag', $args);
+            foreach ($tags as $tag){ ?>
+                <?php echo '<a id="' . $tag->slug . '"href="'.  get_permalink(510) . '">'. $tag->name . '</a>' . "<br>"; ?> 
+            <?php }?>
+        </div>
+</div>
+        
+    </div>
+    <div class="description small-12 medium-7 columns">
+        <?php
+            setup_postdata( $product );
+            the_content(); 
+        ?>
+    </div>
+        
+    </div>
+
+</div>