Advertisement
JulieJabber

Untitled

Apr 27th, 2015
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function avia_bbpress_enabled()
  5. {
  6. if (class_exists( 'bbPress' )) { return true; }
  7. return false;
  8. }
  9.  
  10. //check if the plugin is enabled, otherwise stop the script
  11. if(!avia_bbpress_enabled()) { return false; }
  12.  
  13.  
  14. global $avia_config;
  15.  
  16.  
  17. //register my own styles
  18. add_filter('bbp_default_styles', 'avia_bbpress_deregister_default_assets', 10, 1);
  19. function avia_bbpress_deregister_default_assets($styles)
  20. {
  21. return array();
  22. }
  23.  
  24. if(!is_admin()){ add_action('bbp_enqueue_scripts', 'avia_bbpress_register_assets',15); }
  25.  
  26. function avia_bbpress_register_assets()
  27. {
  28. global $bbp;
  29. wp_enqueue_style( 'avia-bbpress', AVIA_BASE_URL.'config-bbpress/bbpress-mod.css');
  30. }
  31.  
  32.  
  33.  
  34. //add classnames to topic class for even nicer icon display
  35. add_filter('bbp_get_topic_class', 'avia_bbpress_add_topic_class');
  36. function avia_bbpress_add_topic_class($classes)
  37. {
  38. $voices = bbp_get_topic_voice_count() > 1 ? "multi" : "single";
  39.  
  40. $classes[] = 'topic-voices-'.$voices;
  41. return $classes;
  42. }
  43.  
  44.  
  45.  
  46. //remove forum and single topic summaries at the top of the page
  47. add_filter('bbp_get_single_forum_description', 'avia_bbpress_filter_form_message',10,2 );
  48. add_filter('bbp_get_single_topic_description', 'avia_bbpress_filter_form_message',10,2 );
  49.  
  50.  
  51.  
  52. add_filter('avia_style_filter', 'avia_bbpress_forum_colors');
  53. /* add some color modifications to the forum table items */
  54. function avia_bbpress_forum_colors($config)
  55. {
  56.  
  57. return $config;
  58. }
  59.  
  60.  
  61. function avia_bbpress_filter_form_message( $retstr, $args )
  62. {
  63. //removes forum summary, voices count etc
  64. return false;
  65. }
  66.  
  67.  
  68.  
  69. /*modify default breadcrumb to work better with bb forums*/
  70.  
  71. if(!function_exists('avia_fetch_bb_trail'))
  72. {
  73. //fetch bb trail and set the bb breadcrum output to false
  74. function avia_fetch_bb_trail($trail, $breadcrumbs, $r)
  75. {
  76. global $avia_config;
  77. $avia_config['bbpress_trail'] = $breadcrumbs;
  78.  
  79. return false;
  80. }
  81.  
  82. add_filter('bbp_get_breadcrumb','avia_fetch_bb_trail',10,3);
  83. }
  84.  
  85. if(!function_exists('avia_bbpress_breadcrumb'))
  86. {
  87. //if we are viewing a forum page set the avia breadcrumb output to match the forum breadcrumb output
  88. function avia_bbpress_breadcrumb($trail)
  89. {
  90. global $avia_config;
  91.  
  92. if((isset($avia_config['currently_viewing']) && $avia_config['currently_viewing'] == 'forum') || get_post_type() === "forum" || get_post_type() === "topic")
  93. {
  94. $bc = bbp_get_breadcrumb();
  95.  
  96. if(isset($avia_config['bbpress_trail'] ))
  97. {
  98. $trail_zero = $trail[0];
  99. $trail = $avia_config['bbpress_trail'] ;
  100. $trail[0] = $trail_zero;
  101. }
  102.  
  103. if((bbp_is_single_user_edit() || bbp_is_single_user()))
  104. {
  105. $user_info = get_userdata(bbp_get_displayed_user_id());
  106. $title = __("Profile for User:","avia_framework")." ".$user_info->display_name;
  107. array_pop($trail);
  108. $trail[] = $title;
  109. }
  110. }
  111. return $trail;
  112. }
  113.  
  114.  
  115. add_filter('avia_breadcrumbs_trail','avia_bbpress_breadcrumb');
  116. }
  117.  
  118.  
  119.  
  120.  
  121. register_sidebar(array(
  122. 'name' => 'Forum',
  123. 'before_widget' => '<div id="%1$s" class="widget clearfix %2$s">',
  124. 'after_widget' => '<span class="seperator extralight-border"></span></div>',
  125. 'before_title' => '<h3 class="widgettitle">',
  126. 'after_title' => '</h3>',
  127. 'id' => 'sidebar-6',
  128. ));
  129.  
  130. /*
  131.  
  132. add_filter('bbp_view_widget_title', 'avia_widget_title');
  133. add_filter('bbp_login_widget_title', 'avia_widget_title');
  134. add_filter('bbp_forum_widget_title', 'avia_widget_title');
  135. add_filter('bbp_topic_widget_title', 'avia_widget_title');
  136. add_filter('bbp_replies_widget_title', 'avia_widget_title');
  137. */
  138.  
  139.  
  140. if(!function_exists('avia_remove_bbpress_post_type_options'))
  141. {
  142. function avia_remove_bbpress_post_type_options($post_type_option, $args)
  143. {
  144. if(!empty($post_type_option))
  145. {
  146. foreach($post_type_option as $key => $post_type)
  147. {
  148. if($post_type == 'forum' || $post_type == 'topic' || $post_type == 'reply')
  149. {
  150. unset($post_type_option[$key]);
  151. }
  152. }
  153. }
  154.  
  155. return $post_type_option;
  156. }
  157.  
  158. add_filter('avf_registered_post_type_array', 'avia_remove_bbpress_post_type_options', 10, 2);
  159. }
  160.  
  161.  
  162. if(!function_exists('avia_remove_bbpress_post_type_from_query'))
  163. {
  164. function avia_remove_bbpress_post_type_from_query($query, $params)
  165. {
  166. if(!empty($query['post_type']) && is_array($query['post_type']))
  167. {
  168. foreach($query['post_type'] as $key => $post_type)
  169. {
  170. if($post_type == 'forum' || $post_type == 'topic' || $post_type == 'reply')
  171. {
  172. unset($query['post_type'][$key]);
  173. }
  174. }
  175. }
  176.  
  177. return $query;
  178. }
  179.  
  180. add_filter('avia_masonry_entries_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  181. add_filter('avia_post_grid_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  182. add_filter('avia_post_slide_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  183. add_filter('avia_blog_post_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  184. add_filter('avf_magazine_entries_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  185. add_filter('avf_accordion_entries_query', 'avia_remove_bbpress_post_type_from_query', 10, 2);
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement