From 12dc3c033faad5763b3e17c97b5b6c2c72b34608 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 11 Jul 2012 11:23:31 +0100 Subject: [PATCH] Template changes - for coen approval --- readme.txt | 2 + shortcodes/shortcode-init.php | 20 +++-- templates/archive-product.php | 77 ++++++++++++++++-- templates/content-product.php | 64 +++++++++++++++ templates/single-product.php | 48 ++++++++++-- templates/taxonomy-product_cat.php | 19 +++-- templates/taxonomy-product_tag.php | 19 +++-- woocommerce-hooks.php | 12 +-- woocommerce-template.php | 120 +++++++++-------------------- 9 files changed, 257 insertions(+), 124 deletions(-) create mode 100644 templates/content-product.php diff --git a/readme.txt b/readme.txt index 19c13df84ee..c29711682a2 100644 --- a/readme.txt +++ b/readme.txt @@ -153,6 +153,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc = 1.xxxx - xx/xx/2012 = * Feature - Support for ounces * Feature - Restore coupon usage count after order cancellation +* Templating - Dumped woocommerce_single_product_content(), woocommerce_archive_product_content(), woocommerce_product_taxonomy_content() and introduced a content-product.php template for ease of customisation. +* Templating - Documented templates listing hooked in functions. * Tweak - Better WC_Product::get_image() function. Fixed instances where we were not echo'ing. * Tweak - Pass valuable object data to woocommerce_email_headers and woocommerce_email_attachments filters. * Tweak - Cart.php tweak: Disable hyperlinks for hidden products. diff --git a/shortcodes/shortcode-init.php b/shortcodes/shortcode-init.php index 66f05037d72..431a9f9b13f 100644 --- a/shortcodes/shortcode-init.php +++ b/shortcodes/shortcode-init.php @@ -392,7 +392,7 @@ function woocommerce_featured_products( $atts ) { /** * Show a single product page **/ -function woocommerce_product_page_shortcode($atts){ +function woocommerce_product_page_shortcode( $atts ) { if (empty($atts)) return; if (!$atts['id'] && !$atts['sku']) return; @@ -416,13 +416,23 @@ function woocommerce_product_page_shortcode($atts){ if(isset($atts['id'])){ $args['p'] = $atts['id']; } + + $single_product = new WP_Query( $args ); - $product_query = new WP_Query($args); ob_start(); - echo '
'; - woocommerce_single_product_content( $product_query ); - echo '
'; + + while ( $single_product->have_posts() ) : $single_product->the_post(); ?> + +
+ + + +
+ + + - + - +

+ + + + + + post_title ); + ?> + +

+ + + ' . wpautop( wptexturize( term_description() ) ) . ''; ?> + + ' . apply_filters( 'the_content', $shop_page->post_content ) . ''; ?> + + + + + - + - + \ No newline at end of file diff --git a/templates/content-product.php b/templates/content-product.php new file mode 100644 index 00000000000..180fe7ccc3e --- /dev/null +++ b/templates/content-product.php @@ -0,0 +1,64 @@ + + + + +
> + + + +
+ + + +
+ + + +
+ + \ No newline at end of file diff --git a/templates/single-product.php b/templates/single-product.php index bf4ab1ba641..ec3fa0bd489 100644 --- a/templates/single-product.php +++ b/templates/single-product.php @@ -1,11 +1,47 @@ - - - + +get_header('shop'); ?> - + - + + + + + + + + + \ No newline at end of file diff --git a/templates/taxonomy-product_cat.php b/templates/taxonomy-product_cat.php index 6ce784cfbca..cd12898398c 100644 --- a/templates/taxonomy-product_cat.php +++ b/templates/taxonomy-product_cat.php @@ -1,11 +1,10 @@ - + - - - - - - - - \ No newline at end of file +woocommerce_get_template( 'archive-product.php' ); \ No newline at end of file diff --git a/templates/taxonomy-product_tag.php b/templates/taxonomy-product_tag.php index 6ce784cfbca..42b08fbcb87 100644 --- a/templates/taxonomy-product_tag.php +++ b/templates/taxonomy-product_tag.php @@ -1,11 +1,10 @@ - + - - - - - - - - \ No newline at end of file +woocommerce_get_template( 'archive-product.php' ); \ No newline at end of file diff --git a/woocommerce-hooks.php b/woocommerce-hooks.php index 79859a6a3c5..a640971edbc 100644 --- a/woocommerce-hooks.php +++ b/woocommerce-hooks.php @@ -15,19 +15,19 @@ global $woocommerce; if ( !is_admin() || defined('DOING_AJAX') ) { /* Content Wrappers */ - add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); - add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); + add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); + add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); /* Sale flashes */ - add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); - add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10); + add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); + add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); /* Breadcrumbs */ - add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0); + add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); /* Sidebar */ add_action( 'get_sidebar', 'woocommerce_prevent_sidebar_cache' ); - add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10); + add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); /* Products Loop */ add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 ); diff --git a/woocommerce-template.php b/woocommerce-template.php index 08db84495e6..8627deb4dbd 100644 --- a/woocommerce-template.php +++ b/woocommerce-template.php @@ -13,93 +13,49 @@ if ( ! function_exists( 'woocommerce_content' ) ) { // This function is only used in the optional 'woocommerce.php' template - // people can add to their themes to add basic woocommerce support. + // people can add to their themes to add basic woocommerce support without + // using hooks or modifying core templates. function woocommerce_content() { - if ( is_singular( 'product' ) ) - woocommerce_single_product_content(); - elseif ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) - woocommerce_product_taxonomy_content(); - else - woocommerce_archive_product_content(); - } -} -if ( ! function_exists( 'woocommerce_archive_product_content' ) ) { - function woocommerce_archive_product_content() { - - if ( ! is_search() ) { - $shop_page = get_post( woocommerce_get_page_id( 'shop' ) ); - $shop_page_title = apply_filters( 'the_title', ( get_option( 'woocommerce_shop_page_title' ) ) ? get_option( 'woocommerce_shop_page_title' ) : $shop_page->post_title ); - if ( is_object( $shop_page ) ) - $shop_page_content = $shop_page->post_content; - } else { - $shop_page_title = __( 'Search Results:', 'woocommerce' ) . ' “' . get_search_query() . '”'; - if ( get_query_var( 'paged' ) ) $shop_page_title .= ' — ' . __( 'Page', 'woocommerce' ) . ' ' . get_query_var( 'paged' ); - $shop_page_content = ''; - } - - ?>

- - - - - - query_vars['taxonomy'] ) , $wp_query->query_vars['taxonomy'] ); - - ?>

name ); ?>

- - description ) : ?> - -
description ) ); ?>
- - - - - - have_posts() ) while ( $wc_query->have_posts() ) : $wc_query->the_post(); ?> - - - -
> - - - -
- - - -
- + if ( is_singular( 'product' ) ) { + + while ( have_posts() ) : the_post(); -
+ woocommerce_get_template_part( 'content', 'product' ); - - -

+ + + + + + post_title ); + ?> + + + + + +

+ + + ' . wpautop( wptexturize( term_description() ) ) . ''; ?> + + ' . apply_filters( 'the_content', $shop_page->post_content ) . ''; ?> + + + + +