PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/shop-isle/inc/structure/template-tags.php

https://bitbucket.org/afitri_151/elipse-kids
PHP | 335 lines | 187 code | 65 blank | 83 comment | 29 complexity | 715d63946a9e50ee45220110a5a7415f MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, GPL-3.0
  1. <?php
  2. /**
  3. * Custom template tags for this theme.
  4. *
  5. * Eventually, some of the functionality here could be replaced by core features.
  6. *
  7. * @package shop-isle
  8. */
  9. if ( ! function_exists( 'shop_isle_product_categories' ) ) {
  10. /**
  11. * Display Product Categories
  12. * Hooked into the `homepage` action in the homepage template
  13. *
  14. * @since 1.0.0
  15. * @return void
  16. */
  17. function shop_isle_product_categories( $args ) {
  18. if ( is_woocommerce_activated() ) {
  19. $args = apply_filters(
  20. 'shop_isle_product_categories_args', array(
  21. 'limit' => 3,
  22. 'columns' => 3,
  23. 'child_categories' => 0,
  24. 'orderby' => 'name',
  25. 'title' => __( 'Product Categories', 'shop-isle' ),
  26. )
  27. );
  28. echo '<section class="shop-isle-product-section shop-isle-product-categories">';
  29. do_action( 'shop_isle_homepage_before_product_categories' );
  30. echo '<h2 class="section-title">' . esc_attr( $args['title'] ) . '</h2>';
  31. echo do_shortcode( '[product_categories number="' . intval( $args['limit'] ) . '" columns="' . intval( $args['columns'] ) . '" orderby="' . esc_attr( $args['orderby'] ) . '" parent="' . esc_attr( $args['child_categories'] ) . '"]' );
  32. do_action( 'shop_isle_homepage_after_product_categories' );
  33. echo '</section>';
  34. }
  35. }
  36. }
  37. if ( ! function_exists( 'shop_isle_recent_products' ) ) {
  38. /**
  39. * Display Recent Products
  40. * Hooked into the `homepage` action in the homepage template
  41. *
  42. * @since 1.0.0
  43. * @return void
  44. */
  45. function shop_isle_recent_products( $args ) {
  46. if ( is_woocommerce_activated() ) {
  47. $args = apply_filters(
  48. 'shop_isle_recent_products_args', array(
  49. 'limit' => 4,
  50. 'columns' => 4,
  51. 'title' => __( 'Recent Products', 'shop-isle' ),
  52. )
  53. );
  54. echo '<section class="shop-isle-product-section shop-isle-recent-products">';
  55. do_action( 'shop_isle_homepage_before_recent_products' );
  56. echo '<h2 class="section-title">' . esc_attr( $args['title'] ) . '</h2>';
  57. echo do_shortcode( '[recent_products per_page="' . intval( $args['limit'] ) . '" columns="' . intval( $args['columns'] ) . '"]' );
  58. do_action( 'shop_isle_homepage_after_recent_products' );
  59. echo '</section>';
  60. }
  61. }
  62. }
  63. if ( ! function_exists( 'shop_isle_featured_products' ) ) {
  64. /**
  65. * Display Featured Products
  66. * Hooked into the `homepage` action in the homepage template
  67. *
  68. * @since 1.0.0
  69. * @return void
  70. */
  71. function shop_isle_featured_products( $args ) {
  72. if ( is_woocommerce_activated() ) {
  73. $args = apply_filters(
  74. 'shop_isle_featured_products_args', array(
  75. 'limit' => 4,
  76. 'columns' => 4,
  77. 'orderby' => 'date',
  78. 'order' => 'desc',
  79. 'title' => __( 'Featured Products', 'shop-isle' ),
  80. )
  81. );
  82. echo '<section class="shop-isle-product-section shop-isle-featured-products">';
  83. do_action( 'shop_isle_homepage_before_featured_products' );
  84. echo '<h2 class="section-title">' . esc_attr( $args['title'] ) . '</h2>';
  85. echo do_shortcode( '[featured_products per_page="' . intval( $args['limit'] ) . '" columns="' . intval( $args['columns'] ) . '" orderby="' . esc_attr( $args['orderby'] ) . '" order="' . esc_attr( $args['order'] ) . '"]' );
  86. do_action( 'shop_isle_homepage_after_featured_products' );
  87. echo '</section>';
  88. }
  89. }
  90. }
  91. if ( ! function_exists( 'shop_isle_popular_products' ) ) {
  92. /**
  93. * Display Popular Products
  94. * Hooked into the `homepage` action in the homepage template
  95. *
  96. * @since 1.0.0
  97. * @return void
  98. */
  99. function shop_isle_popular_products( $args ) {
  100. if ( is_woocommerce_activated() ) {
  101. $args = apply_filters(
  102. 'shop_isle_popular_products_args', array(
  103. 'limit' => 4,
  104. 'columns' => 4,
  105. 'title' => __( 'Top Rated Products', 'shop-isle' ),
  106. )
  107. );
  108. echo '<section class="shop-isle-product-section shop-isle-popular-products">';
  109. do_action( 'shop_isle_homepage_before_popular_products' );
  110. echo '<h2 class="section-title">' . esc_attr( $args['title'] ) . '</h2>';
  111. echo do_shortcode( '[top_rated_products per_page="' . intval( $args['limit'] ) . '" columns="' . intval( $args['columns'] ) . '"]' );
  112. do_action( 'shop_isle_homepage_after_popular_products' );
  113. echo '</section>';
  114. }
  115. }
  116. }
  117. if ( ! function_exists( 'shop_isle_on_sale_products' ) ) {
  118. /**
  119. * Display On Sale Products
  120. * Hooked into the `homepage` action in the homepage template
  121. *
  122. * @since 1.0.0
  123. * @return void
  124. */
  125. function shop_isle_on_sale_products( $args ) {
  126. if ( is_woocommerce_activated() ) {
  127. $args = apply_filters(
  128. 'shop_isle_on_sale_products_args', array(
  129. 'limit' => 4,
  130. 'columns' => 4,
  131. 'title' => __( 'On Sale', 'shop-isle' ),
  132. )
  133. );
  134. echo '<section class="shop-isle-product-section shop-isle-on-sale-products">';
  135. do_action( 'shop_isle_homepage_before_on_sale_products' );
  136. echo '<h2 class="section-title">' . esc_attr( $args['title'] ) . '</h2>';
  137. echo do_shortcode( '[sale_products per_page="' . intval( $args['limit'] ) . '" columns="' . intval( $args['columns'] ) . '"]' );
  138. do_action( 'shop_isle_homepage_after_on_sale_products' );
  139. echo '</section>';
  140. }
  141. }
  142. }
  143. if ( ! function_exists( 'shop_isle_homepage_content' ) ) {
  144. /**
  145. * Display homepage content
  146. * Hooked into the `homepage` action in the homepage template
  147. *
  148. * @since 1.0.0
  149. * @return void
  150. */
  151. function shop_isle_homepage_content() {
  152. while ( have_posts() ) :
  153. the_post();
  154. get_template_part( 'content', 'page' );
  155. endwhile; // end of the loop.
  156. }
  157. }
  158. if ( ! function_exists( 'shop_isle_social_icons' ) ) {
  159. /**
  160. * Display social icons
  161. * If the subscribe and connect plugin is active, display the icons.
  162. *
  163. * @link http://wordpress.org/plugins/subscribe-and-connect/
  164. * @since 1.0.0
  165. */
  166. function shop_isle_social_icons() {
  167. if ( class_exists( 'Subscribe_And_Connect' ) ) {
  168. echo '<div class="subscribe-and-connect-connect">';
  169. subscribe_and_connect_connect();
  170. echo '</div>';
  171. }
  172. }
  173. }
  174. if ( ! function_exists( 'shop_isle_get_sidebar' ) ) {
  175. /**
  176. * Display sidebar
  177. *
  178. * @uses get_sidebar()
  179. * @since 1.0.0
  180. */
  181. function shop_isle_get_sidebar() {
  182. get_sidebar();
  183. }
  184. }
  185. if ( ! function_exists( 'shop_isle_get_sidebar_shop_archive' ) ) {
  186. /**
  187. * Display sidebar
  188. *
  189. * @uses get_sidebar()
  190. * @since 1.0.0
  191. */
  192. function shop_isle_get_sidebar_shop_archive() {
  193. get_sidebar( 'shop-archive' );
  194. }
  195. }
  196. if ( ! function_exists( 'shop_isle_the_very_top_bar' ) ) {
  197. /**
  198. * Function to display Very Top Bar.
  199. *
  200. * @param bool $is_callback Check if we need to add shop-isle-top-bar div.
  201. * @access public
  202. */
  203. function shop_isle_the_very_top_bar( $is_callback = false ) {
  204. $hide_top_bar = get_theme_mod( 'shop_isle_top_bar_hide', true );
  205. if ( (bool) $hide_top_bar === true ) {
  206. return;
  207. }
  208. $shop_isle_top_bar_alignment = get_theme_mod( 'shop_isle_top_bar_alignment', 'right' );
  209. $menu_class = 'pull-right';
  210. $sidebar_class = 'pull-left';
  211. if ( ! empty( $shop_isle_top_bar_alignment ) && $shop_isle_top_bar_alignment === 'left' ) {
  212. $menu_class = 'pull-left';
  213. $sidebar_class = 'pull-right';
  214. }
  215. if ( $is_callback !== true ) {
  216. echo '<div class="shop-isle-top-bar">';
  217. }
  218. echo '<div class="container">';
  219. echo '<div class="row">';
  220. /**
  221. * Call for sidebar
  222. */
  223. if ( is_active_sidebar( 'sidebar-top-bar' ) ) {
  224. $sidebar_class .= ' col-md-6';
  225. if ( ! has_nav_menu( 'top-bar-menu' ) && ! current_user_can( 'manage_options' ) ) {
  226. $sidebar_class .= ' col-md-12';
  227. }
  228. echo '<div class="' . esc_attr( $sidebar_class ) . '">';
  229. dynamic_sidebar( 'sidebar-top-bar' );
  230. echo '</div>';
  231. }
  232. if ( is_active_sidebar( 'sidebar-top-bar' ) ) {
  233. $menu_class .= ' col-md-6';
  234. } else {
  235. $menu_class .= ' col-md-12';
  236. }
  237. echo '<div class="' . esc_attr( $menu_class ) . '">';
  238. /**
  239. * Call for the menu
  240. */
  241. wp_nav_menu(
  242. array(
  243. 'theme_location' => 'top-bar-menu',
  244. 'depth' => 1,
  245. 'container' => 'div',
  246. 'container_id' => 'top-bar-navigation',
  247. 'menu_class' => 'nav top-bar-nav',
  248. )
  249. );
  250. echo '</div>';
  251. echo '</div>';
  252. echo '</div>';
  253. if ( $is_callback !== true ) {
  254. echo '</div>';
  255. }
  256. }
  257. }
  258. if ( ! function_exists( 'shop_isle_hidden_sidebars' ) ) {
  259. /**
  260. * Fix for sections with widgets not appearing anymore after the hide button is selected for each section.
  261. */
  262. function shop_isle_hidden_sidebars() {
  263. echo '<div style="display: none">';
  264. if ( is_customize_preview() ) {
  265. dynamic_sidebar( 'sidebar-top-bar' );
  266. }
  267. echo '</div>';
  268. }
  269. }
  270. add_action( 'shop_isle_footer', 'shop_isle_hidden_sidebars' );