evolve_sidebar_class

Function to print out css class according to layout used in sidebar.php.

Description

evolve_sidebar_class(); 

added by Denzel


Usage

  1. if ( !function_exists( 'evolve_sidebar_class' ) ) { 
  2. require_once '/library/functions/basic-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = evolve_sidebar_class(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/library/functions/basic-functions.php  
  1. function evolve_sidebar_class() { 
  2.  
  3. global $wp_query; 
  4. global $post; 
  5. $post_id = ''; 
  6. if ($wp_query->is_posts_page) { 
  7. $post_id = get_option('page_for_posts'); 
  8. } elseif (is_buddypress()) { 
  9. $post_id = evolve_bp_get_id(); 
  10. } else { 
  11. $post_id = isset($post->ID) ? $post->ID : ''; 
  12.  
  13. $sidebar_css = ''; 
  14.  
  15. $evolve_layout = evolve_get_option('evl_layout', '2cl'); 
  16.  
  17. //use PHP switch statement, is easier to understand. 
  18. switch ($evolve_layout): 
  19. case "1c": 
  20. //do nothing 
  21. break; 
  22. case "2cl": 
  23. $sidebar_css = 'col-sm-6 col-md-4'; 
  24. break; 
  25. case "2cr": 
  26. $sidebar_css = 'col-sm-6 col-md-4'; 
  27. break; 
  28. case "3cm": 
  29. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3'; 
  30. break; 
  31. case "3cl": 
  32. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3'; 
  33. break; 
  34. case "3cr": 
  35. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3'; 
  36. break; 
  37. endswitch; 
  38.  
  39. $evolve_sidebar_position = get_post_meta($post_id, 'evolve_sidebar_position', true); 
  40.  
  41. if(is_page() || is_single()): 
  42. //use PHP switch statement, is easier to understand. 
  43. switch ($evolve_sidebar_position): 
  44. case "default": 
  45. //do nothing 
  46. break; 
  47. case "2cl": 
  48. $sidebar_css = 'col-sm-6 col-md-4'; 
  49. break; 
  50. case "2cr": 
  51. $sidebar_css = 'col-sm-6 col-md-4'; 
  52. break; 
  53. case "3cm": 
  54. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3'; 
  55. break; 
  56. case "3cl": 
  57. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3 float-right'; 
  58. break; 
  59. case "3cr": 
  60. $sidebar_css = 'col-xs-12 col-sm-6 col-md-3 float-left'; 
  61. break; 
  62. endswitch; 
  63. endif; 
  64.  
  65.  
  66. echo $sidebar_css;