Advertisement
ramiropuig

enfold - sidebar

Aug 29th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. <?php
  2. if ( !defined('ABSPATH') ){ die(); }
  3.  
  4. global $avia_config;
  5.  
  6. ##############################################################################
  7. # Display the sidebar
  8. ##############################################################################
  9.  
  10. $default_sidebar = true;
  11. $sidebar_pos = avia_layout_class('main', false);
  12.  
  13. $sidebar_smartphone = avia_get_option('smartphones_sidebar') == 'smartphones_sidebar' ? 'smartphones_sidebar_active' : "";
  14. $sidebar = "";
  15.  
  16. if(strpos($sidebar_pos, 'sidebar_left') !== false) $sidebar = 'left';
  17. if(strpos($sidebar_pos, 'sidebar_right') !== false) $sidebar = 'right';
  18.  
  19. //filter the sidebar position (eg woocommerce single product pages always want the same sidebar pos)
  20. $sidebar = apply_filters('avf_sidebar_position', $sidebar);
  21.  
  22. //if the layout hasnt the sidebar keyword defined we dont need to display one
  23. if(empty($sidebar)) return;
  24. if(!empty($avia_config['overload_sidebar'])) $avia_config['currently_viewing'] = $avia_config['overload_sidebar'];
  25.  
  26.  
  27. echo "<aside class='sidebar sidebar_".$sidebar." ".$sidebar_smartphone." ".avia_layout_class( 'sidebar', false )." units' ".avia_markup_helper(array('context' => 'sidebar', 'echo' => false)).">";
  28. echo "<div class='inner_sidebar extralight-border'>";
  29.  
  30. //Display a subnavigation for pages that is automatically generated, so the users do not need to work with widgets
  31. $av_sidebar_menu = avia_sidebar_menu(false);
  32. if($av_sidebar_menu)
  33. {
  34. echo $av_sidebar_menu;
  35. $default_sidebar = false;
  36. }
  37.  
  38.  
  39. $the_id = @get_the_ID();
  40. $custom_sidebar = "";
  41. if(!empty($the_id) && is_singular())
  42. {
  43. $custom_sidebar = get_post_meta($the_id, 'sidebar', true);
  44. }
  45.  
  46. $custom_sidebar = apply_filters('avf_custom_sidebar', $custom_sidebar);
  47.  
  48. //From Enfold forum for o have Sidebar Blog Cat in category pages
  49. if ( is_taxonomy('portfolio_entries') ) { $custom_sidebar = "Sidebar Blog Cat"; }
  50.  
  51. if($custom_sidebar)
  52. {
  53. dynamic_sidebar($custom_sidebar);
  54. $default_sidebar = false;
  55. }
  56. else
  57. {
  58. if(empty($avia_config['currently_viewing'])) $avia_config['currently_viewing'] = 'page';
  59.  
  60. // general shop sidebars
  61. if ($avia_config['currently_viewing'] == 'shop' && dynamic_sidebar('Shop Overview Page') ) : $default_sidebar = false; endif;
  62.  
  63. // single shop sidebars
  64. if ($avia_config['currently_viewing'] == 'shop_single') $default_sidebar = false;
  65. if ($avia_config['currently_viewing'] == 'shop_single' && dynamic_sidebar('Single Product Pages') ) : $default_sidebar = false; endif;
  66.  
  67. // general blog sidebars
  68. if ($avia_config['currently_viewing'] == 'blog' && dynamic_sidebar('Sidebar Blog') ) : $default_sidebar = false; endif;
  69.  
  70. // general pages sidebars
  71. if ($avia_config['currently_viewing'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;
  72.  
  73. // forum pages sidebars
  74. if ($avia_config['currently_viewing'] == 'forum' && dynamic_sidebar('Forum') ) : $default_sidebar = false; endif;
  75.  
  76. }
  77.  
  78. //global sidebar
  79. if (dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif;
  80.  
  81.  
  82.  
  83. //default dummy sidebar
  84. if (apply_filters('avf_show_default_sidebars', $default_sidebar))
  85. {
  86. if(apply_filters('avf_show_default_sidebar_pages', true)) {avia_dummy_widget(2);}
  87. if(apply_filters('avf_show_default_sidebar_categories', true)) {avia_dummy_widget(3);}
  88. if(apply_filters('avf_show_default_sidebar_archiv', true)) {avia_dummy_widget(4);}
  89.  
  90. // customize default sidebar and add your sidebars
  91. do_action ('ava_add_custom_default_sidebars');
  92. }
  93.  
  94. echo "</div>";
  95. echo "</aside>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement