Advertisement
Guest User

sidebar.php

a guest
Apr 12th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. <?php
  2. /**
  3. * The Sidebar containing the main widget areas.
  4. *
  5. * @package Catch_Responsive
  6. * @subpackage Catch Responsive Pro
  7. * @since Catch Responsive 1.0
  8. */
  9.  
  10. /**
  11. * catchresponsive_before_secondary hook
  12. */
  13. do_action( 'catchresponsive_before_secondary' );
  14.  
  15. $catchresponsive_layout = catchresponsive_get_theme_layout();
  16.  
  17. //Bail early if no sidebar layout is selected
  18. if ( 'no-sidebar' == $catchresponsive_layout || 'no-sidebar-one-column' == $catchresponsive_layout || 'no-sidebar-full-width' == $catchresponsive_layout ) {
  19. return;
  20. }
  21.  
  22. // WooCommerce Shop Page excluding Cart and checkout
  23. if ( class_exists( 'WooCommerce' ) && is_woocommerce() ) {
  24. $shop_id = get_option( 'woocommerce_shop_page_id' );
  25. $sidebaroptions = get_post_meta( $shop_id, 'catchresponsive-sidebar-options', true );
  26. }
  27. else {
  28. global $post, $wp_query;
  29.  
  30. // Front page displays in Reading Settings
  31. $page_on_front = get_option('page_on_front') ;
  32. $page_for_posts = get_option('page_for_posts');
  33.  
  34. // Get Page ID outside Loop
  35. $page_id = $wp_query->get_queried_object_id();
  36.  
  37. // Blog Page or Front Page setting in Reading Settings
  38. if ( $page_id == $page_for_posts || $page_id == $page_on_front ) {
  39. $sidebaroptions = get_post_meta( $page_id, 'catchresponsive-sidebar-options', true );
  40. }
  41. elseif ( is_singular() ) {
  42. if ( is_attachment() ) {
  43. $parent = $post->post_parent;
  44. $sidebaroptions = get_post_meta( $parent, 'catchresponsive-sidebar-options', true );
  45.  
  46. }
  47. else {
  48. $sidebaroptions = get_post_meta( $post->ID, 'catchresponsive-sidebar-options', true );
  49. }
  50. }
  51. else {
  52. $sidebaroptions = '';
  53. }
  54. }
  55.  
  56. do_action( 'catchresponsive_before_primary_sidebar' );
  57. ?>
  58. <aside class="sidebar sidebar-primary widget-area" role="complementary">
  59. <?php
  60. if ( is_active_sidebar( 'sidebar-optional-woocommmerce' ) && class_exists( 'WooCommerce' ) && ( is_woocommerce() || is_cart() || is_checkout() ) ) {
  61. dynamic_sidebar( 'sidebar-optional-woocommmerce' );
  62. }
  63. elseif ( is_active_sidebar( 'sidebar-optional-one' ) && 'optional-sidebar-one' == $sidebaroptions ) {
  64. dynamic_sidebar( 'sidebar-optional-one' );
  65. }
  66. elseif ( is_active_sidebar( 'sidebar-optional-two' ) && 'optional-sidebar-two' == $sidebaroptions ) {
  67. dynamic_sidebar( 'sidebar-optional-two' );
  68. }
  69. elseif ( is_active_sidebar( 'sidebar-optional-three' ) && 'optional-sidebar-three' == $sidebaroptions ) {
  70. dynamic_sidebar( 'sidebar-optional-three' );
  71. }
  72. elseif ( is_active_sidebar( 'sidebar-optional-four' ) && 'optional-sidebar-four' == $sidebaroptions ) {
  73. dynamic_sidebar( 'sidebar-optional-four' );
  74. }
  75. elseif ( is_active_sidebar( 'sidebar-optional-five' ) && 'optional-sidebar-five' == $sidebaroptions ) {
  76. dynamic_sidebar( 'sidebar-optional-five' );
  77. }
  78. elseif ( is_active_sidebar( 'sidebar-optional-homepage' ) && ( is_front_page() || ( is_home() && $page_id != $page_for_posts ) ) ) {
  79. dynamic_sidebar( 'sidebar-optional-homepage' );
  80. }
  81. elseif ( is_active_sidebar( 'sidebar-optional-archive' ) && ( is_archive() || ( is_home() && $page_id != $page_for_posts ) ) ) {
  82. dynamic_sidebar( 'sidebar-optional-archive' );
  83. }
  84. elseif ( is_page() && is_active_sidebar( 'sidebar-optional-page' ) ) {
  85. dynamic_sidebar( 'sidebar-optional-page' );
  86. }
  87. elseif ( is_single() && is_active_sidebar( 'sidebar-optional-post' ) ) {
  88. dynamic_sidebar( 'sidebar-optional-post' );
  89. }
  90. elseif ( is_active_sidebar( 'primary-sidebar' ) ) {
  91. dynamic_sidebar( 'primary-sidebar' );
  92. }
  93. else {
  94. //Helper Text
  95. if ( current_user_can( 'edit_theme_options' ) ) { ?>
  96. <section id="widget-default-text" class="widget widget_text">
  97. <div class="widget-wrap">
  98. <h4 class="widget-title"><?php _e( 'Primary Sidebar Widget Area', 'catch-responsive-pro' ); ?></h4>
  99.  
  100. <div class="textwidget">
  101. <p><?php _e( 'This is the Primary Sidebar Widget Area if you are using a two or three column site layout option.', 'catch-responsive-pro' ); ?></p>
  102. <p><?php printf( __( 'By default it will load Search and Archives widgets as shown below. You can add widget to this area by visiting your <a href="%s">Widgets Panel</a> which will replace default widgets.', 'catch-responsive-pro' ), esc_url( admin_url( 'widgets.php' ) ) ); ?></p>
  103. </div>
  104. </div><!-- .widget-wrap -->
  105. </section><!-- #widget-default-text -->
  106. <?php
  107. } ?>
  108. <section class="widget widget_search" id="default-search">
  109. <div class="widget-wrap">
  110. <?php get_search_form(); ?>
  111. </div><!-- .widget-wrap -->
  112. </section><!-- #default-search -->
  113. <section class="widget widget_archive" id="default-archives">
  114. <div class="widget-wrap">
  115. <h4 class="widget-title"><?php _e( 'Archives', 'catch-responsive-pro' ); ?></h4>
  116. <ul>
  117. <?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
  118. </ul>
  119. </div><!-- .widget-wrap -->
  120. </section><!-- #default-archives -->
  121. <?php
  122. } ?>
  123. </aside><!-- .sidebar sidebar-primary widget-area -->
  124. <?php
  125. /**
  126. * catchresponsive_after_primary_sidebar hook
  127. */
  128. do_action( 'catchresponsive_after_primary_sidebar' );
  129.  
  130.  
  131. /**
  132. * catchresponsive_after_secondary hook
  133. *
  134. */
  135. do_action( 'catchresponsive_after_secondary' );
  136.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement