PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/jigoshop_template_functions.php

https://github.com/scottpoulin/jigoshop
PHP | 1187 lines | 860 code | 211 blank | 116 comment | 207 complexity | 7793a165edb9a418ec999a6329a3eb32 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Functions used in template files
  4. *
  5. * DISCLAIMER
  6. *
  7. * Do not edit or add directly to this file if you wish to upgrade Jigoshop to newer
  8. * versions in the future. If you wish to customise Jigoshop core for your needs,
  9. * please use our GitHub repository to publish essential changes for consideration.
  10. *
  11. * @package Jigoshop
  12. * @category Core
  13. * @author Jigoshop
  14. * @copyright Copyright Š 2011-2013 Jigoshop.
  15. * @license http://jigoshop.com/license/commercial-edition
  16. */
  17. /**
  18. * Front page archive/shop template
  19. */
  20. if (!function_exists('jigoshop_front_page_archive')) {
  21. function jigoshop_front_page_archive() {
  22. global $paged;
  23. // TODO: broken
  24. // is_page() fails for this - still testing -JAP-
  25. // is_shop() works, but only with a [recent_products] shortcode on the Shop page
  26. // however, if shortcode is used when not front page, double product listings appear
  27. //
  28. if ( is_front_page() && is_page( jigoshop_get_page_id('shop') )) :
  29. // if ( is_front_page() && is_shop() ) :
  30. if ( get_query_var('paged') ) {
  31. $paged = get_query_var('paged');
  32. } else if ( get_query_var('page') ) {
  33. $paged = get_query_var('page');
  34. } else {
  35. $paged = 1;
  36. }
  37. query_posts( array( 'page_id' => '', 'post_type' => 'product', 'paged' => $paged ) );
  38. define('SHOP_IS_ON_FRONT', true);
  39. endif;
  40. }
  41. }
  42. add_action('wp_head', 'jigoshop_front_page_archive', 0);
  43. /**
  44. * Content Wrappers
  45. **/
  46. if (!function_exists('jigoshop_output_content_wrapper')) {
  47. function jigoshop_output_content_wrapper() {
  48. if ( get_option('template') === 'twentytwelve' ) echo '<div id="primary" class="site-content"><div id="content" role="main">';
  49. elseif ( get_option('template') === 'twentyeleven' ) echo '<section id="primary"><div id="content" role="main">';
  50. else echo '<div id="container"><div id="content" role="main">'; /* twenty-ten */
  51. }
  52. }
  53. if (!function_exists('jigoshop_output_content_wrapper_end')) {
  54. function jigoshop_output_content_wrapper_end() {
  55. if ( get_option('template') === 'twentytwelve' ) echo '</div></div>';
  56. elseif ( get_option('template') === 'twentyeleven' ) echo '</div></section>';
  57. else echo '</div></div>'; /* twenty-ten */
  58. }
  59. }
  60. /**
  61. * Sale Flash
  62. **/
  63. if (!function_exists('jigoshop_show_product_sale_flash')) {
  64. function jigoshop_show_product_sale_flash( $post, $_product ) {
  65. if ($_product->is_on_sale()) echo '<span class="onsale">'.__('Sale!', 'jigoshop').'</span>';
  66. }
  67. }
  68. /**
  69. * Sidebar
  70. **/
  71. if (!function_exists('jigoshop_get_sidebar')) {
  72. function jigoshop_get_sidebar() {
  73. get_sidebar('shop');
  74. }
  75. }
  76. /**
  77. * Products Loop
  78. **/
  79. if (!function_exists('jigoshop_template_loop_add_to_cart')) {
  80. function jigoshop_template_loop_add_to_cart( $post, $_product ) {
  81. do_action('jigoshop_before_add_to_cart_button');
  82. // do not show "add to cart" button if product's price isn't announced
  83. if ( $_product->get_price() === '' AND ! ($_product->is_type(array('variable', 'grouped', 'external'))) ) return;
  84. if ( $_product->is_in_stock() OR $_product->is_type('external') ) {
  85. $button_type = Jigoshop_Base::get_options()->get_option('jigoshop_catalog_product_button');
  86. if ( $button_type === false ) $button_type = 'add';
  87. if ( $_product->is_type(array('variable', 'grouped')) ) {
  88. if ( $button_type != 'none' ) {
  89. if ( $button_type == 'view' ) {
  90. $output = '<a href="'.esc_url(get_permalink($_product->id)).'" class="button">'.__('View Product', 'jigoshop').'</a>';
  91. } else {
  92. $output = '<a href="'.esc_url(get_permalink($_product->id)).'" class="button">'._x('Select', 'verb', 'jigoshop').'</a>';
  93. }
  94. } else {
  95. $output = '';
  96. }
  97. } else if ( $_product->is_type('external') ) {
  98. if ( $button_type != 'none' ) {
  99. if ( $button_type == 'view' ) {
  100. $output = '<a href="'.esc_url(get_permalink($_product->id)).'" class="button">'.__('View Product', 'jigoshop').'</a>';
  101. } else {
  102. $output = '<a href="'.esc_url(get_post_meta( $_product->id, 'external_url', true )).'" class="button" rel="nofollow">'.__('Buy product', 'jigoshop').'</a>';
  103. }
  104. } else {
  105. $output = '';
  106. }
  107. } else if ( $button_type == 'add' ) {
  108. $output = '<a href="'.esc_url($_product->add_to_cart_url()).'" class="button" rel="nofollow">'.__('Add to cart', 'jigoshop').'</a>';
  109. } else if ( $button_type == 'view' ) {
  110. $output = '<a href="'.esc_url(get_permalink($_product->id)).'" class="button">'.__('View Product', 'jigoshop').'</a>';
  111. } else {
  112. $output = '';
  113. }
  114. } else if ( ($_product->is_type(array('grouped')) ) ) {
  115. $output = '';
  116. } else {
  117. $output = '<span class="nostock">'.__('Out of Stock', 'jigoshop').'</span>';
  118. }
  119. echo apply_filters( 'jigoshop_loop_add_to_cart_output', $output, $post, $_product );
  120. do_action('jigoshop_after_add_to_cart_button');
  121. }
  122. }
  123. if (!function_exists('jigoshop_template_loop_product_thumbnail')) {
  124. function jigoshop_template_loop_product_thumbnail( $post, $_product ) {
  125. echo jigoshop_get_product_thumbnail();
  126. }
  127. }
  128. if (!function_exists('jigoshop_template_loop_price')) {
  129. function jigoshop_template_loop_price( $post, $_product ) {
  130. ?><span class="price"><?php echo $_product->get_price_html(); ?></span><?php
  131. }
  132. }
  133. /**
  134. * Before Single Products Summary Div
  135. **/
  136. if (!function_exists('jigoshop_show_product_images')) {
  137. function jigoshop_show_product_images() {
  138. global $_product, $post;
  139. echo '<div class="images">';
  140. do_action( 'jigoshop_before_single_product_summary_thumbnails', $post, $_product );
  141. $thumb_id = 0;
  142. if (has_post_thumbnail()) :
  143. $thumb_id = get_post_thumbnail_id();
  144. // since there are now user settings for sizes, shouldn't need filters -JAP-
  145. //$large_thumbnail_size = apply_filters('single_product_large_thumbnail_size', 'shop_large');
  146. $large_thumbnail_size = jigoshop_get_image_size( 'shop_large' );
  147. $image_classes = apply_filters( 'jigoshop_product_image_classes', array(), $_product );
  148. array_unshift( $image_classes, 'zoom' );
  149. $image_classes = implode( ' ', $image_classes );
  150. echo '<a href="'.wp_get_attachment_url($thumb_id).'" class="'.$image_classes.'" rel="thumbnails">';
  151. the_post_thumbnail($large_thumbnail_size);
  152. echo '</a>';
  153. else :
  154. echo jigoshop_get_image_placeholder( 'shop_large' );
  155. endif;
  156. do_action('jigoshop_product_thumbnails');
  157. echo '</div>';
  158. }
  159. }
  160. if (!function_exists('jigoshop_show_product_thumbnails')) {
  161. function jigoshop_show_product_thumbnails() {
  162. global $_product, $post;
  163. echo '<div class="thumbnails">';
  164. $thumb_id = get_post_thumbnail_id();
  165. $small_thumbnail_size = jigoshop_get_image_size( 'shop_thumbnail' );
  166. $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => 'asc' );
  167. $attachments = get_posts($args);
  168. if ($attachments) :
  169. $loop = 0;
  170. $columns = Jigoshop_Base::get_options()->get_option( 'jigoshop_product_thumbnail_columns', '3' );
  171. $columns = apply_filters( 'single_thumbnail_columns', $columns );
  172. foreach ( $attachments as $attachment ) :
  173. if ($thumb_id==$attachment->ID) continue;
  174. $loop++;
  175. $_post = get_post( $attachment->ID );
  176. $url = wp_get_attachment_url($_post->ID);
  177. $post_title = esc_attr($_post->post_title);
  178. $image = wp_get_attachment_image($attachment->ID, $small_thumbnail_size);
  179. if ( ! $image || $url == get_post_meta($post->ID, 'file_path', true) )
  180. continue;
  181. echo '<a href="'.esc_url($url).'" title="'.esc_attr($post_title).'" rel="thumbnails" class="zoom ';
  182. if ($loop==1 || ($loop-1)%$columns==0) echo 'first';
  183. if ($loop%$columns==0) echo 'last';
  184. echo '">'.$image.'</a>';
  185. endforeach;
  186. endif;
  187. wp_reset_query();
  188. echo '</div>';
  189. }
  190. }
  191. /**
  192. * After Single Products Summary Div
  193. **/
  194. if (!function_exists('jigoshop_output_product_data_tabs')) {
  195. function jigoshop_output_product_data_tabs() {
  196. if (isset($_COOKIE["current_tab"])) $current_tab = $_COOKIE["current_tab"]; else $current_tab = '#tab-description';
  197. ?>
  198. <div id="tabs">
  199. <ul class="tabs">
  200. <?php do_action('jigoshop_product_tabs', $current_tab); ?>
  201. </ul>
  202. <?php do_action('jigoshop_product_tab_panels'); ?>
  203. </div>
  204. <?php
  205. }
  206. }
  207. /**
  208. * Product summary box
  209. **/
  210. if (!function_exists('jigoshop_template_single_title')) {
  211. function jigoshop_template_single_title( $post, $_product ) {
  212. ?><h1 class="product_title page-title"><?php echo apply_filters( 'jigoshop_single_product_title', the_title( '', '', false ) ); ?></h1><?php
  213. }
  214. }
  215. if (!function_exists('jigoshop_template_single_price')) {
  216. function jigoshop_template_single_price( $post, $_product ) {
  217. ?><p class="price"><?php echo apply_filters( 'jigoshop_single_product_price', $_product->get_price_html() ); ?></p><?php
  218. }
  219. }
  220. if (!function_exists('jigoshop_template_single_excerpt')) {
  221. function jigoshop_template_single_excerpt( $post, $_product ) {
  222. if ($post->post_excerpt) echo apply_filters( 'jigoshop_single_product_excerpt', wpautop(wptexturize($post->post_excerpt)) );
  223. }
  224. }
  225. if (!function_exists('jigoshop_template_single_meta')) {
  226. function jigoshop_template_single_meta( $post, $_product ) {
  227. $jigoshop_options = Jigoshop_Base::get_options();
  228. echo '<div class="product_meta">';
  229. if ($jigoshop_options->get_option('jigoshop_enable_sku')=='yes' && !empty($_product->sku)) :
  230. echo '<div class="sku">'.__('SKU','jigoshop').': ' . $_product->sku . '</div>';
  231. endif;
  232. echo $_product->get_categories( ', ', ' <div class="posted_in">' . __( 'Posted in ', 'jigoshop' ) . '', '.</div>');
  233. echo $_product->get_tags( ', ', ' <div class="tagged_as">' . __( 'Tagged as ', 'jigoshop' ) . '', '.</div>');
  234. echo '</div>';
  235. }
  236. }
  237. if (!function_exists('jigoshop_template_single_sharing')) {
  238. function jigoshop_template_single_sharing( $post, $_product ) {
  239. $jigoshop_options = Jigoshop_Base::get_options();
  240. if ($jigoshop_options->get_option('jigoshop_sharethis')) :
  241. echo '<div class="social">
  242. <iframe src="https://www.facebook.com/plugins/like.php?href='.urlencode(get_permalink($post->ID)).'&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
  243. <span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis"></span><span class="st_plusone_button"></span>
  244. </div>';
  245. endif;
  246. }
  247. }
  248. /**
  249. * Product Add to cart buttons
  250. **/
  251. if (!function_exists('jigoshop_template_single_add_to_cart')) {
  252. function jigoshop_template_single_add_to_cart( $post, $_product ) {
  253. $availability = $_product->get_availability();
  254. if ( $availability <> '' ) {
  255. ?>
  256. <p class="stock <?php echo $availability['class'] ?>"><?php echo $availability['availability']; ?></p>
  257. <?php
  258. }
  259. if ( $_product->is_in_stock() ) {
  260. do_action( $_product->product_type . '_add_to_cart' );
  261. }
  262. }
  263. }
  264. if (!function_exists('jigoshop_simple_add_to_cart')) {
  265. function jigoshop_simple_add_to_cart() {
  266. global $_product; $availability = $_product->get_availability();
  267. // do not show "add to cart" button if product's price isn't announced
  268. if( $_product->get_price() === '') return;
  269. ?>
  270. <form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post">
  271. <?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
  272. <div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
  273. <button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
  274. <?php do_action('jigoshop_add_to_cart_form'); ?>
  275. </form>
  276. <?php
  277. }
  278. }
  279. if (!function_exists('jigoshop_virtual_add_to_cart')) {
  280. function jigoshop_virtual_add_to_cart() {
  281. jigoshop_simple_add_to_cart();
  282. }
  283. }
  284. if (!function_exists('jigoshop_downloadable_add_to_cart')) {
  285. function jigoshop_downloadable_add_to_cart() {
  286. global $_product; $availability = $_product->get_availability();
  287. // do not show "add to cart" button if product's price isn't announced
  288. if( $_product->get_price() === '') return;
  289. ?>
  290. <form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post">
  291. <?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
  292. <button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
  293. <?php do_action('jigoshop_add_to_cart_form'); ?>
  294. </form>
  295. <?php
  296. }
  297. }
  298. if (!function_exists('jigoshop_grouped_add_to_cart')) {
  299. function jigoshop_grouped_add_to_cart() {
  300. global $_product;
  301. if(!$_product->get_children()) return;
  302. ?>
  303. <form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="cart" method="post">
  304. <table>
  305. <tbody>
  306. <?php foreach ($_product->get_children() as $child_ID) : $child = $_product->get_child($child_ID); $cavailability = $child->get_availability(); ?>
  307. <tr>
  308. <td><div class="quantity"><input name="quantity[<?php echo $child->ID; ?>]" value="0" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div></td>
  309. <td><label for="product-<?php echo $child->id; ?>"><?php
  310. if ($child->is_visible()) echo '<a href="'.get_permalink($child->ID).'">';
  311. echo $child->get_title();
  312. if ($child->is_visible()) echo '</a>';
  313. ?></label></td>
  314. <td class="price"><?php echo $child->get_price_html(); ?><small class="stock <?php echo $cavailability['class'] ?>"><?php echo $cavailability['availability']; ?></small></td>
  315. </tr>
  316. <?php endforeach; ?>
  317. </tbody>
  318. </table>
  319. <?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
  320. <button type="submit" class="button-alt"><?php _e('Add to cart', 'jigoshop'); ?></button>
  321. <?php do_action('jigoshop_add_to_cart_form'); ?>
  322. </form>
  323. <?php
  324. }
  325. }
  326. if (!function_exists('jigoshop_variable_add_to_cart')) {
  327. function jigoshop_variable_add_to_cart() {
  328. global $post, $_product;
  329. $jigoshop_options = Jigoshop_Base::get_options();
  330. $attributes = $_product->get_available_attributes_variations();
  331. //get all variations available as an array for easy usage by javascript
  332. $variationsAvailable = array();
  333. $children = $_product->get_children();
  334. foreach($children as $child) {
  335. /* @var $variation jigoshop_product_variation */
  336. $variation = $_product->get_child( $child );
  337. if($variation instanceof jigoshop_product_variation) {
  338. $vattrs = $variation->get_variation_attributes();
  339. $availability = $variation->get_availability();
  340. //@todo needs to be moved to jigoshop_product_variation class
  341. if (has_post_thumbnail($variation->get_variation_id())) {
  342. $attachment_id = get_post_thumbnail_id( $variation->get_variation_id() );
  343. $large_thumbnail_size = apply_filters('single_product_large_thumbnail_size', 'shop_large');
  344. $image = wp_get_attachment_image_src( $attachment_id, $large_thumbnail_size);
  345. if ( ! empty( $image ) ) $image = $image[0];
  346. $image_link = wp_get_attachment_image_src( $attachment_id, 'full');
  347. if ( ! empty( $image_link ) ) $image_link = $image_link[0];
  348. } else {
  349. $image = '';
  350. $image_link = '';
  351. }
  352. $a_weight = $a_length = $a_width = $a_height = '';
  353. if ( $variation->get_weight() ) {
  354. $a_weight = '
  355. <tr class="weight">
  356. <th>Weight</th>
  357. <td>'.$variation->get_weight().$jigoshop_options->get_option('jigoshop_weight_unit').'</td>
  358. </tr>';
  359. }
  360. if ( $variation->get_length() ) {
  361. $a_length = '
  362. <tr class="length">
  363. <th>Length</th>
  364. <td>'.$variation->get_length().$jigoshop_options->get_option('jigoshop_dimension_unit').'</td>
  365. </tr>';
  366. }
  367. if ( $variation->get_width() ) {
  368. $a_width = '
  369. <tr class="width">
  370. <th>Width</th>
  371. <td>'.$variation->get_width().$jigoshop_options->get_option('jigoshop_dimension_unit').'</td>
  372. </tr>';
  373. }
  374. if ( $variation->get_height() ) {
  375. $a_height = '
  376. <tr class="height">
  377. <th>Height</th>
  378. <td>'.$variation->get_height().$jigoshop_options->get_option('jigoshop_dimension_unit').'</td>
  379. </tr>
  380. ';
  381. }
  382. $variationsAvailable[] = array(
  383. 'variation_id' => $variation->get_variation_id(),
  384. 'sku' => '<div class="sku">'.__('SKU','jigoshop').': ' . $variation->get_sku() . '</div>',
  385. 'attributes' => $vattrs,
  386. 'in_stock' => $variation->is_in_stock(),
  387. 'image_src' => $image,
  388. 'image_link' => $image_link,
  389. 'price_html' => '<span class="price">'.$variation->get_price_html().'</span>',
  390. 'availability_html'=> '<p class="stock ' . esc_attr( $availability['class'] ) . '">'. $availability['availability'].'</p>',
  391. 'a_weight' => $a_weight,
  392. 'a_length' => $a_length,
  393. 'a_width' => $a_width,
  394. 'a_height' => $a_height,
  395. );
  396. }
  397. }
  398. ?>
  399. <script type="text/javascript">
  400. var product_variations = <?php echo json_encode($variationsAvailable) ?>;
  401. </script>
  402. <?php $default_attributes = $_product->get_default_attributes() ?>
  403. <form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="variations_form cart" method="post">
  404. <fieldset class="variations">
  405. <?php foreach ( $attributes as $name => $options ): ?>
  406. <?php $sanitized_name = sanitize_title( $name ); ?>
  407. <div>
  408. <span class="select_label"><?php echo jigoshop_product::attribute_label('pa_'.$name); ?></span>
  409. <select id="<?php echo esc_attr( $sanitized_name ); ?>" name="tax_<?php echo $sanitized_name; ?>">
  410. <option value=""><?php echo __('Choose an option ', 'jigoshop') ?>&hellip;</option>
  411. <?php if ( empty( $_POST ) ): ?>
  412. <?php $selected_value = ( isset( $default_attributes[ $sanitized_name ] ) ) ? $default_attributes[ $sanitized_name ] : ''; ?>
  413. <?php else: ?>
  414. <?php $selected_value = isset( $_POST[ 'tax_' . $sanitized_name ] ) ? $_POST[ 'tax_' . $sanitized_name ] : ''; ?>
  415. <?php endif; ?>
  416. <?php foreach ( $options as $value ) : ?>
  417. <?php if ( taxonomy_exists( 'pa_'.$sanitized_name )) : ?>
  418. <?php $term = get_term_by( 'slug', $value, 'pa_'.$sanitized_name ); ?>
  419. <option value="<?php echo esc_attr( $term->slug ); ?>" <?php selected( $selected_value, $term->slug) ?>><?php echo $term->name; ?></option>
  420. <?php else : ?>
  421. <option value="<?php echo esc_attr( sanitize_title( $value ) ); ?>"<?php selected( $selected_value, sanitize_title( $value )) ?> ><?php echo $value; ?></option>
  422. <?php endif;?>
  423. <?php endforeach; ?>
  424. </select>
  425. </div>
  426. <?php endforeach;?>
  427. </fieldset>
  428. <div class="single_variation"></div>
  429. <?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
  430. <div class="variations_button" style="display:none;">
  431. <input type="hidden" name="variation_id" value="" />
  432. <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
  433. <div class="quantity"><input name="quantity" value="1" size="4" title="Qty" class="input-text qty text" maxlength="12" /></div>
  434. <input type="submit" class="button-alt" value="<?php esc_html_e('Add to cart', 'jigoshop'); ?>" />
  435. </div>
  436. <?php do_action('jigoshop_add_to_cart_form'); ?>
  437. </form>
  438. <?php
  439. }
  440. }
  441. if (!function_exists('jigoshop_external_add_to_cart')) {
  442. function jigoshop_external_add_to_cart() {
  443. global $_product;
  444. $external_url = get_post_meta( $_product->ID, 'external_url', true );
  445. if ( ! $external_url ) return false;
  446. ?>
  447. <form action="" class="cart" method="">
  448. <?php do_action('jigoshop_before_add_to_cart_form_button'); ?>
  449. <p>
  450. <a href="<?php echo esc_url( $external_url ); ?>" rel="nofollow" class="button"><?php _e('Buy product', 'jigoshop'); ?></a>
  451. </p>
  452. <?php do_action('jigoshop_add_to_cart_form'); ?>
  453. </form>
  454. <?php
  455. }
  456. }
  457. /**
  458. * Product Add to Cart forms
  459. **/
  460. if (!function_exists('jigoshop_add_to_cart_form_nonce')) {
  461. function jigoshop_add_to_cart_form_nonce() {
  462. jigoshop::nonce_field('add_to_cart');
  463. }
  464. }
  465. /**
  466. * Pagination
  467. **/
  468. if (!function_exists('jigoshop_pagination')) {
  469. function jigoshop_pagination() {
  470. global $wp_query;
  471. if ( $wp_query->max_num_pages > 1 ) :
  472. ?>
  473. <div class="navigation">
  474. <?php if ( function_exists( 'wp_pagenavi' )) : ?>
  475. <?php wp_pagenavi(); ?>
  476. <?php else : ?>
  477. <div class="nav-next"><?php next_posts_link( __( 'Next <span class="meta-nav">&rarr;</span>', 'jigoshop' ) ); ?></div>
  478. <div class="nav-previous"><?php previous_posts_link( __( '<span class="meta-nav">&larr;</span> Previous', 'jigoshop' ) ); ?></div>
  479. <?php endif; ?>
  480. </div>
  481. <?php
  482. endif;
  483. }
  484. }
  485. /**
  486. * Product page tabs
  487. **/
  488. if (!function_exists('jigoshop_product_description_tab')) {
  489. function jigoshop_product_description_tab( $current_tab ) {
  490. global $post;
  491. if( ! $post->post_content )
  492. return false;
  493. ?>
  494. <li <?php if ($current_tab=='#tab-description') echo 'class="active"'; ?>><a href="#tab-description"><?php _e('Description', 'jigoshop'); ?></a></li>
  495. <?php
  496. }
  497. }
  498. if (!function_exists('jigoshop_product_attributes_tab')) {
  499. function jigoshop_product_attributes_tab( $current_tab ) {
  500. global $_product;
  501. if( ( $_product->has_attributes() || $_product->has_dimensions() || $_product->has_weight() ) ):
  502. ?>
  503. <li <?php if ($current_tab=='#tab-attributes') echo 'class="active"'; ?>><a href="#tab-attributes"><?php _e('Additional Information', 'jigoshop'); ?></a></li><?php endif;
  504. }
  505. }
  506. if (!function_exists('jigoshop_product_reviews_tab')) {
  507. function jigoshop_product_reviews_tab( $current_tab ) {
  508. if ( comments_open() ) : ?><li <?php if ($current_tab=='#tab-reviews') echo 'class="active"'; ?>><a href="#tab-reviews"><?php _e('Reviews', 'jigoshop'); ?><?php echo comments_number(' (0)', ' (1)', ' (%)'); ?></a></li><?php endif;
  509. }
  510. }
  511. if (!function_exists('jigoshop_product_customize_tab')) {
  512. function jigoshop_product_customize_tab( $current_tab ) {
  513. global $_product;
  514. if ( get_post_meta( $_product->ID , 'customizable', true ) == 'yes' ) {
  515. ?>
  516. <li <?php if ($current_tab=='#tab-customize') echo 'class="active"'; ?>><a href="#tab-customize"><?php _e('Personalize', 'jigoshop'); ?></a></li>
  517. <?php
  518. }
  519. }
  520. }
  521. /**
  522. * Product page tab panels
  523. **/
  524. if (!function_exists('jigoshop_product_description_panel')) {
  525. function jigoshop_product_description_panel() {
  526. $content = get_the_content();
  527. $content = apply_filters( 'the_content', $content );
  528. $content = str_replace( ']]>', ']]&gt;', $content );
  529. $content = apply_filters( 'jigoshop_single_product_content', $content );
  530. if ( $content <> '' ) {
  531. echo '<div class="panel" id="tab-description">';
  532. echo '<h2>' . apply_filters('jigoshop_product_description_heading', __('Product Description', 'jigoshop')) . '</h2>';
  533. // the following 3 lines replicate the behavior of 'the_content()'
  534. // non echoed so Rich Snippets can be applied via a filter
  535. echo $content;
  536. echo '</div>';
  537. }
  538. }
  539. }
  540. if (!function_exists('jigoshop_product_attributes_panel')) {
  541. function jigoshop_product_attributes_panel() {
  542. global $_product;
  543. $content = apply_filters( 'jigoshop_single_product_attributes', $_product->list_attributes() );
  544. if ( $content <> '' ) {
  545. echo '<div class="panel" id="tab-attributes">';
  546. echo '<h2>' . apply_filters('jigoshop_product_attributes_heading', __('Additional Information', 'jigoshop')) . '</h2>';
  547. echo $content;
  548. echo '</div>';
  549. }
  550. }
  551. }
  552. if (!function_exists('jigoshop_product_reviews_panel')) {
  553. function jigoshop_product_reviews_panel() {
  554. echo '<div class="panel" id="tab-reviews">';
  555. comments_template();
  556. echo '</div>';
  557. }
  558. }
  559. if (!function_exists('jigoshop_product_customize_panel')) {
  560. function jigoshop_product_customize_panel() {
  561. global $_product;
  562. if ( isset( $_POST['Submit'] ) && $_POST['Submit'] == __('Save Personalization', 'jigoshop') ) {
  563. $custom_products = (array) jigoshop_session::instance()->customized_products;
  564. $custom_products[$_POST['customized_id']] = trim( wptexturize( $_POST['jigoshop_customized_product'] ));
  565. jigoshop_session::instance()->customized_products = $custom_products;
  566. }
  567. if ( get_post_meta( $_product->ID , 'customizable', true ) == 'yes' ) :
  568. $custom_products = (array) jigoshop_session::instance()->customized_products;
  569. $custom = isset( $custom_products[$_product->ID] ) ? $custom_products[$_product->ID] : '';
  570. $custom_length = get_post_meta( $_product->ID , 'customized_length', true );
  571. $length_str = $custom_length == '' ? '' : sprintf( __( 'You may enter a maximum of %s characters.', 'jigoshop' ), $custom_length );
  572. echo '<div class="panel" id="tab-customize">';
  573. echo '<p>' . apply_filters('jigoshop_product_customize_heading', __('Enter your personal information as you want it to appear on the product.<br />', 'jigoshop').$length_str) . '</p>';
  574. ?>
  575. <form action="" method="post">
  576. <input type="hidden" name="customized_id" value="<?php echo esc_attr( $_product->ID ); ?>" />
  577. <?php
  578. if ( $custom_length == '' ) :
  579. ?>
  580. <textarea
  581. id="jigoshop_customized_product"
  582. name="jigoshop_customized_product"
  583. cols="60"
  584. rows="4"><?php echo esc_textarea( $custom ); ?></textarea>
  585. <?php else : ?>
  586. <input
  587. type="text"
  588. id="jigoshop_customized_product"
  589. name="jigoshop_customized_product"
  590. size="<?php echo $custom_length; ?>"
  591. maxlength="<?php echo $custom_length; ?>"
  592. value="<?php echo esc_attr( $custom ); ?>" />
  593. <?php endif; ?>
  594. <p class="submit"><input name="Submit" type="submit" class="button-alt add_personalization" value="<?php _e( "Save Personalization", 'jigoshop' ); ?>" /></p>
  595. </form>
  596. <?php
  597. echo '</div>';
  598. endif;
  599. }
  600. }
  601. /**
  602. * Jigoshop Product Thumbnail
  603. **/
  604. if (!function_exists('jigoshop_get_product_thumbnail')) {
  605. function jigoshop_get_product_thumbnail( $size = 'shop_small' ) {
  606. global $post;
  607. if ( has_post_thumbnail() )
  608. return get_the_post_thumbnail($post->ID, $size);
  609. else
  610. return jigoshop_get_image_placeholder( $size );
  611. }
  612. }
  613. /**
  614. * Jigoshop Product Category Image
  615. **/
  616. if (!function_exists('jigoshop_product_cat_image')) {
  617. function jigoshop_product_cat_image($id) {
  618. if( empty($id) )
  619. return false;
  620. $thumbnail_id = get_metadata('jigoshop_term', $id, 'thumbnail_id', true);
  621. $category_image = $thumbnail_id ? wp_get_attachment_url( $thumbnail_id )
  622. : jigoshop::assets_url().'/assets/images/placeholder.png';
  623. return array('image' => $category_image, 'thumb_id' => $thumbnail_id);
  624. }
  625. }
  626. /**
  627. * Jigoshop Product Image Placeholder
  628. * @since 0.9.9
  629. **/
  630. if (!function_exists('jigoshop_get_image_placeholder')) {
  631. function jigoshop_get_image_placeholder( $size = 'shop_small' ) {
  632. $image_size = jigoshop_get_image_size( $size );
  633. return '<img src="'.jigoshop::assets_url().'/assets/images/placeholder.png" alt="Placeholder" width="'.$image_size[0].'" height="'.$image_size[1].'" />';
  634. }
  635. }
  636. /**
  637. * Jigoshop Related Products
  638. **/
  639. if (!function_exists('jigoshop_output_related_products')) {
  640. function jigoshop_output_related_products() {
  641. $jigoshop_options = Jigoshop_Base::get_options();
  642. if ($jigoshop_options->get_option ('jigoshop_enable_related_products') != 'no')
  643. // 2 Related Products in 2 columns
  644. jigoshop_related_products( 2, 2 );
  645. }
  646. }
  647. if (!function_exists('jigoshop_related_products')) {
  648. function jigoshop_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) {
  649. global $_product, $columns, $per_page;
  650. // Pass vars to loop
  651. $per_page = $posts_per_page;
  652. $columns = $post_columns;
  653. $related = $_product->get_related( $posts_per_page );
  654. if (sizeof($related)>0) :
  655. echo '<div class="related products"><h2>'.__('Related Products', 'jigoshop').'</h2>';
  656. $args = array(
  657. 'post_type' => 'product',
  658. 'ignore_sticky_posts' => 1,
  659. 'posts_per_page' => $per_page,
  660. 'orderby' => $orderby,
  661. 'post__in' => $related
  662. );
  663. $args = apply_filters('jigoshop_related_products_args', $args);
  664. query_posts($args);
  665. jigoshop_get_template_part( 'loop', 'shop' );
  666. echo '</div>';
  667. wp_reset_query();
  668. endif;
  669. $per_page = null; // reset for cross sells if enabled
  670. $columns = null;
  671. }
  672. }
  673. /**
  674. * Jigoshop Shipping Calculator
  675. **/
  676. if (!function_exists('jigoshop_shipping_calculator')) {
  677. function jigoshop_shipping_calculator() {
  678. if (jigoshop_shipping::show_shipping_calculator()) :
  679. ?>
  680. <form class="shipping_calculator" action="<?php echo esc_url( jigoshop_cart::get_cart_url() ); ?>" method="post">
  681. <h2><a href="#" class="shipping-calculator-button"><?php _e('Calculate Shipping', 'jigoshop'); ?> <span>&darr;</span></a></h2>
  682. <section class="shipping-calculator-form">
  683. <p class="form-row">
  684. <select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state">
  685. <?php
  686. foreach(jigoshop_countries::get_allowed_countries() as $key=>$value) :
  687. echo '<option value="'.esc_attr($key).'"';
  688. if (jigoshop_customer::get_shipping_country()==$key) echo ' selected="selected"';
  689. echo '>'.$value.'</option>';
  690. endforeach;
  691. ?>
  692. </select>
  693. </p>
  694. <div class="col2-set">
  695. <p class="form-row col-1">
  696. <?php
  697. $current_cc = jigoshop_customer::get_shipping_country();
  698. $current_r = jigoshop_customer::get_shipping_state();
  699. $states = jigoshop_countries::$states;
  700. if (jigoshop_countries::country_has_states($current_cc)) :
  701. // Dropdown
  702. ?>
  703. <span>
  704. <select name="calc_shipping_state" id="calc_shipping_state"><option value=""><?php _e('Select a state&hellip;', 'jigoshop'); ?></option><?php
  705. foreach($states[$current_cc] as $key=>$value) :
  706. echo '<option value="'.esc_attr($key).'"';
  707. if ($current_r==$key) echo 'selected="selected"';
  708. echo '>'.$value.'</option>';
  709. endforeach;
  710. ?></select>
  711. </span>
  712. <?php
  713. else :
  714. // Input
  715. ?>
  716. <input type="text" class="input-text" value="<?php echo esc_attr( $current_r ); ?>" placeholder="<?php _e('state', 'jigoshop'); ?>" name="calc_shipping_state" id="calc_shipping_state" />
  717. <?php
  718. endif;
  719. ?>
  720. </p>
  721. <p class="form-row col-2">
  722. <input type="text" class="input-text" value="<?php echo esc_attr( jigoshop_customer::get_shipping_postcode() ); ?>" placeholder="<?php _e('Postcode/Zip', 'jigoshop'); ?>" title="<?php _e('Postcode', 'jigoshop'); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
  723. </p>
  724. <?php do_action('jigoshop_after_shipping_calculator_fields');?>
  725. </div>
  726. <p><button type="submit" name="calc_shipping" value="1" class="button"><?php _e('Update Totals', 'jigoshop'); ?></button></p>
  727. <p>
  728. <?php
  729. $available_methods = jigoshop_shipping::get_available_shipping_methods();
  730. foreach ( $available_methods as $method ) :
  731. for ($i = 0; $i < $method->get_rates_amount(); $i++) {
  732. ?>
  733. <div class="col2-set">
  734. <p class="form-row col-1">
  735. <?php
  736. echo '<input type="radio" name="shipping_rates" value="' . esc_attr( $method->id . ':' . $i ) . '"' . ' class="shipping_select"';
  737. if ( $method->get_cheapest_service() == $method->get_selected_service($i) && $method->is_chosen() ) echo ' checked>'; else echo '>';
  738. echo $method->get_selected_service($i);
  739. ?>
  740. <p class="form-row col-2"><?php
  741. if ($method->get_selected_price($i) > 0) :
  742. echo jigoshop_price($method->get_selected_price($i));
  743. echo __(' (ex. tax)', 'jigoshop');
  744. else :
  745. echo __('Free', 'jigoshop');
  746. endif;
  747. ?>
  748. </div>
  749. <?php
  750. }
  751. endforeach;
  752. ?>
  753. <input type="hidden" name="cart-url" value="<?php echo esc_attr( jigoshop_cart::get_cart_url() ); ?>">
  754. <?php jigoshop::nonce_field('cart') ?>
  755. </section>
  756. </form>
  757. <?php
  758. endif;
  759. }
  760. }
  761. /**
  762. * Jigoshop Login Form
  763. **/
  764. if (!function_exists('jigoshop_login_form')) {
  765. function jigoshop_login_form() {
  766. if (is_user_logged_in()) return;
  767. ?>
  768. <form method="post" class="login">
  769. <p class="form-row form-row-first">
  770. <label for="username"><?php _e('Username', 'jigoshop'); ?> <span class="required">*</span></label>
  771. <input type="text" class="input-text" name="username" id="username" />
  772. </p>
  773. <p class="form-row form-row-last">
  774. <label for="password"><?php _e('Password', 'jigoshop'); ?> <span class="required">*</span></label>
  775. <input class="input-text" type="password" name="password" id="password" />
  776. </p>
  777. <div class="clear"></div>
  778. <p class="form-row">
  779. <?php jigoshop::nonce_field('login', 'login') ?>
  780. <input type="submit" class="button" name="login" value="<?php esc_html_e('Login', 'jigoshop'); ?>" />
  781. <a class="lost_password" href="<?php echo esc_url( wp_lostpassword_url( get_permalink() ) ); ?>"><?php _e('Lost Password?', 'jigoshop'); ?></a>
  782. </p>
  783. </form>
  784. <?php
  785. }
  786. }
  787. /**
  788. * Jigoshop Login Form
  789. **/
  790. if (!function_exists('jigoshop_checkout_login_form')) {
  791. function jigoshop_checkout_login_form() {
  792. $jigoshop_options = Jigoshop_Base::get_options();
  793. if (is_user_logged_in() || $jigoshop_options->get_option('jigoshop_enable_guest_login') != 'yes') return;
  794. ?><p class="info"><?php _e('Already registered?', 'jigoshop'); ?> <a href="#" class="showlogin"><?php _e('Click here to login', 'jigoshop'); ?></a></p><?php
  795. jigoshop_login_form();
  796. }
  797. }
  798. /**
  799. * Jigoshop Verify Checkout States Message
  800. **/
  801. if (!function_exists('jigoshop_verify_checkout_states_for_countries_message')) {
  802. function jigoshop_verify_checkout_states_for_countries_message() {
  803. if ( Jigoshop_Base::get_options()->get_option( 'jigoshop_verify_checkout_info_message' ) == 'yes' ) {
  804. // the following will return true or false if a country requires states
  805. if ( ! jigoshop_customer::has_valid_shipping_state() ) {
  806. echo '<div class="clear"></div><div class="payment_message">' . __('You may have already established your Billing and Shipping state, but please verify it is correctly set for your location as well as all the rest of your information before placing your Order.','jigoshop') . '</div>';
  807. } else {
  808. echo '<div class="clear"></div><div class="payment_message">' . __('Please verify that all your information is correctly entered before placing your Order.','jigoshop') . '</div>';
  809. }
  810. }
  811. }
  812. }
  813. /**
  814. * Jigoshop EU B2B VAT Message
  815. **/
  816. if (!function_exists('jigoshop_eu_b2b_vat_message')) {
  817. function jigoshop_eu_b2b_vat_message() {
  818. if ( jigoshop_countries::is_eu_country( jigoshop_customer::get_country() )
  819. && Jigoshop_Base::get_options()->get_option( 'jigoshop_eu_vat_reduction_message' ) == 'yes' ) {
  820. echo '<div class="clear"></div><div class="payment_message">' . __('If you have entered an EU VAT Number, it will be looked up when you <strong>Place</strong> your Order and verified. At that time <strong><em>Only</em></strong>, will VAT then be removed from the final Order and totals adjusted. You may enter your EU VAT Number either with, or without, the 2 character EU country code in front.','jigoshop') . '</div>';
  821. }
  822. }
  823. }
  824. /**
  825. * Jigoshop Breadcrumb
  826. **/
  827. if (!function_exists('jigoshop_breadcrumb')) {
  828. function jigoshop_breadcrumb( $delimiter = ' &rsaquo; ', $wrap_before = '<div id="breadcrumb">', $wrap_after = '</div>', $before = '', $after = '', $home = null ) {
  829. global $post, $wp_query, $author, $paged;
  830. $jigoshop_options = Jigoshop_Base::get_options();
  831. if( !$home ) $home = _x('Home', 'breadcrumb', 'jigoshop');
  832. $home_link = home_url();
  833. $prepend = '';
  834. if ( $jigoshop_options->get_option('jigoshop_prepend_shop_page_to_urls')=="yes" && jigoshop_get_page_id('shop') && get_option('page_on_front') !== jigoshop_get_page_id('shop') )
  835. $prepend = $before . '<a href="' . esc_url( jigoshop_cart::get_shop_url() ). '">' . get_the_title( jigoshop_get_page_id('shop') ) . '</a> ' . $after . $delimiter;
  836. if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==jigoshop_get_page_id('shop'))) || is_paged() ) :
  837. echo $wrap_before;
  838. echo $before . '<a class="home" href="' . $home_link . '">' . $home . '</a> ' . $after . $delimiter ;
  839. if ( is_category() ) :
  840. $cat_obj = $wp_query->get_queried_object();
  841. $this_category = $cat_obj->term_id;
  842. $this_category = get_category( $this_category );
  843. if ($thisCat->parent != 0) :
  844. $parent_category = get_category( $this_category->parent );
  845. echo get_category_parents($parent_category, TRUE, $delimiter );
  846. endif;
  847. echo $before . single_cat_title('', false) . $after;
  848. elseif ( is_tax('product_cat') ) :
  849. //echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . ucwords($jigoshop_options->get_option('jigoshop_shop_slug')) . '</a>' . $after . $delimiter;
  850. $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  851. $parents = array();
  852. $parent = $term->parent;
  853. while ($parent):
  854. $parents[] = $parent;
  855. $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
  856. $parent = $new_parent->parent;
  857. endwhile;
  858. if(!empty($parents)):
  859. $parents = array_reverse($parents);
  860. foreach ($parents as $parent):
  861. $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
  862. echo $before . '<a href="' . get_term_link( $item->slug, 'product_cat' ) . '">' . $item->name . '</a>' . $after . $delimiter;
  863. endforeach;
  864. endif;
  865. $queried_object = $wp_query->get_queried_object();
  866. echo $prepend . $before . $queried_object->name . $after;
  867. elseif ( is_tax('product_tag') ) :
  868. $queried_object = $wp_query->get_queried_object();
  869. echo $prepend . $before . __('Products tagged &ldquo;', 'jigoshop') . $queried_object->name . '&rdquo;' . $after;
  870. elseif ( is_day() ) :
  871. echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
  872. echo $before . '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $after . $delimiter;
  873. echo $before . get_the_time('d') . $after;
  874. elseif ( is_month() ) :
  875. echo $before . '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $after . $delimiter;
  876. echo $before . get_the_time('F') . $after;
  877. elseif ( is_year() ) :
  878. echo $before . get_the_time('Y') . $after;
  879. elseif ( is_post_type_archive('product') && get_option('page_on_front') !== jigoshop_get_page_id('shop') ) :
  880. $_name = jigoshop_get_page_id('shop') ? get_the_title( jigoshop_get_page_id('shop') ) : ucwords($jigoshop_options->get_option('jigoshop_shop_slug'));
  881. if (is_search()) :
  882. echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $delimiter . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
  883. else :
  884. echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . $_name . '</a>' . $after;
  885. endif;
  886. elseif ( is_single() && !is_attachment() ) :
  887. if ( get_post_type() == 'product' ) :
  888. //echo $before . '<a href="' . get_post_type_archive_link('product') . '">' . ucwords($jigoshop_options->get_option('jigoshop_shop_slug')) . '</a>' . $after . $delimiter;
  889. echo $prepend;
  890. if ($terms = get_the_terms( $post->ID, 'product_cat' )) :
  891. $term = apply_filters( 'jigoshop_product_cat_breadcrumb_terms', current($terms), $terms);
  892. $parents = array();
  893. $parent = $term->parent;
  894. while ($parent):
  895. $parents[] = $parent;
  896. $new_parent = get_term_by( 'id', $parent, 'product_cat');
  897. $parent = $new_parent->parent;
  898. endwhile;
  899. if(!empty($parents)):
  900. $parents = array_reverse($parents);
  901. foreach ($parents as $parent):
  902. $item = get_term_by( 'id', $parent, 'product_cat');
  903. echo $before . '<a href="' . get_term_link( $item->slug, 'product_cat' ) . '">' . $item->name . '</a>' . $after . $delimiter;
  904. endforeach;
  905. endif;
  906. echo $before . '<a href="' . get_term_link( $term->slug, 'product_cat' ) . '">' . $term->name . '</a>' . $after . $delimiter;
  907. endif;
  908. echo $before . get_the_title() . $after;
  909. elseif ( get_post_type() != 'post' ) :
  910. $post_type = get_post_type_object(get_post_type());
  911. $slug = $post_type->rewrite;
  912. echo $before . '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $after . $delimiter;
  913. echo $before . get_the_title() . $after;
  914. else :
  915. $cat = current(get_the_category());
  916. echo get_category_parents($cat, TRUE, $delimiter);
  917. echo $before . get_the_title() . $after;
  918. endif;
  919. elseif ( is_404() ) :
  920. echo $before . __('Error 404', 'jigoshop') . $after;
  921. elseif ( !is_single() && !is_page() && get_post_type() != 'post' ) :
  922. $post_type = get_post_type_object(get_post_type());
  923. if ($post_type) : echo $before . $post_type->labels->singular_name . $after; endif;
  924. elseif ( is_attachment() ) :
  925. $parent = get_post($post->post_parent);
  926. $cat = get_the_category($parent->ID); $cat = $cat[0];
  927. echo get_category_parents($cat, TRUE, '' . $delimiter);
  928. echo $before . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $after . $delimiter;
  929. echo $before . get_the_title() . $after;
  930. elseif ( is_page() && !$post->post_parent ) :
  931. echo $before . get_the_title() . $after;
  932. elseif ( is_page() && $post->post_parent ) :
  933. $parent_id = $post->post_parent;
  934. $breadcrumbs = array();
  935. while ($parent_id) {
  936. $page = get_page($parent_id);
  937. $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  938. $parent_id = $page->post_parent;
  939. }
  940. $breadcrumbs = array_reverse($breadcrumbs);
  941. foreach ($breadcrumbs as $crumb) :
  942. echo $crumb . '' . $delimiter;
  943. endforeach;
  944. echo $before . get_the_title() . $after;
  945. elseif ( is_search() ) :
  946. echo $before . __('Search results for &ldquo;', 'jigoshop') . get_search_query() . '&rdquo;' . $after;
  947. elseif ( is_tag() ) :
  948. echo $before . __('Posts tagged &ldquo;', 'jigoshop') . single_tag_title('', false) . '&rdquo;' . $after;
  949. elseif ( is_author() ) :
  950. $userdata = get_userdata($author);
  951. echo $before . __('Author: ', 'jigoshop') . $userdata->display_name . $after;
  952. endif;
  953. if ( get_query_var('paged') ) :
  954. echo ' (' . __('Page', 'jigoshop') . ' ' . get_query_var('paged') .')';
  955. endif;
  956. echo $wrap_after;
  957. endif;
  958. }
  959. }
  960. /**
  961. * Hook to remove the 'singular' class, for the twenty eleven theme, to properly display the sidebar
  962. *
  963. * @param array $classes
  964. */
  965. function jigoshop_body_classes ($classes) {
  966. if( ! is_content_wrapped() ) return $classes;
  967. $key = array_search('singular', $classes);
  968. if ( $key !== false ) unset($classes[$key]);
  969. return $classes;
  970. }
  971. /**
  972. * Order review table for checkout
  973. **/
  974. function jigoshop_order_review() {
  975. jigoshop_get_template('checkout/review_order.php', false);
  976. }