Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. <?php
  2. /**
  3. * Show options for ordering
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/loop/orderby.php.
  6. *
  7. * HOWEVER, on occasion WooCommerce will need to update template files and you
  8. * (the theme developer) will need to copy the new files to your theme to
  9. * maintain compatibility. We try to do this as little as possible, but it does
  10. * happen. When this occurs the version of the template file will be bumped and
  11. * the readme will list any important changes.
  12. *
  13. * @see https://docs.woocommerce.com/document/template-structure/
  14. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 3.6.0
  17. */
  18.  
  19. if ( ! defined( 'ABSPATH' ) ) {
  20. exit;
  21. }
  22.  
  23. global $wp;
  24. $current_url = esc_url(home_url(add_query_arg(array(),$wp->request)));
  25. ?>
  26. <div class="section-sort">
  27. <p><?php echo esc_html__('Sort', 'motor'); ?></p>
  28. <div class="dropdown-wrap">
  29. <?php foreach ( $catalog_orderby_options as $id => $name ) : ?>
  30. <?php
  31. switch ($id) {
  32. case 'menu_order':
  33. $sort_name = esc_html__('Default', 'motor'); break;
  34. case 'popularity':
  35. $sort_name = esc_html__('Popularity', 'motor'); break;
  36. case 'rating':
  37. $sort_name = esc_html__('Average rating', 'motor'); break;
  38. case 'date':
  39. $sort_name = esc_html__('Newness', 'motor'); break;
  40. case 'price':
  41. $sort_name = esc_html__('Price: low to high', 'motor'); break;
  42. case 'price-desc':
  43. $sort_name = esc_html__('Price: high to low', 'motor'); break;
  44. default:
  45. $sort_name = $name; break;
  46. }
  47. ?>
  48. <?php if ( $orderby == $id ) : ?>
  49. <p class="dropdown-title section-sort-ttl"><?php echo esc_html( $sort_name ); ?></p>
  50. <?php endif; ?>
  51. <?php endforeach; ?>
  52. <ul class="dropdown-list">
  53. <?php foreach ( $catalog_orderby_options as $id => $name ) : ?>
  54. <?php
  55. switch ($id) {
  56. case 'menu_order':
  57. $sort_name = esc_html__('Default', 'motor'); break;
  58. case 'popularity':
  59. $sort_name = esc_html__('Popularity', 'motor'); break;
  60. case 'rating':
  61. $sort_name = esc_html__('Average rating', 'motor'); break;
  62. case 'date':
  63. $sort_name = esc_html__('Newness', 'motor'); break;
  64. case 'price':
  65. $sort_name = esc_html__('Price: low to high', 'motor'); break;
  66. case 'price-desc':
  67. $sort_name = esc_html__('Price: high to low', 'motor'); break;
  68. default:
  69. $sort_name = $name; break;
  70. }
  71. ?>
  72. <li<?php if ( $orderby == $id ) echo ' class="active"'; ?>>
  73. <a href="<?php echo esc_url(add_query_arg(array('orderby'=> esc_attr( $id )))); ?>"><?php echo esc_html( $sort_name ); ?></a>
  74. </li>
  75. <?php endforeach; ?>
  76. </ul>
  77. </div>
  78. <?php
  79. // Keep query string vars intact
  80. foreach ( $_GET as $key => $val ) {
  81. if ( 'orderby' === $key || 'submit' === $key ) {
  82. continue;
  83. }
  84. if ( is_array( $val ) ) {
  85. foreach( $val as $innerVal ) {
  86. echo '<input type="hidden" name="' . esc_attr( $key ) . '[]" value="' . esc_attr( $innerVal ) . '" />';
  87. }
  88. } else {
  89. echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $val ) . '" />';
  90. }
  91. }
  92. ?>
  93. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement