Advertisement
cipher87

Sidebar (WP JOB MANAGER)

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