/bp-forums/bbpress/bb-includes/defaults.bb-filters.php

  1. <?php 
  2. /** 
  3. * Sets up the default filters and actions for most 
  4. * of the bbPress hooks. 
  5. * 
  6. * If you need to remove a default hook, this file will 
  7. * give you the priority for which to use to remove the 
  8. * hook. 
  9. * 
  10. * Not all of the default hooks are found in this files 
  11. * 
  12. * @package bbPress 
  13. */ 
  14.  
  15. // Strip, trim, kses, special chars for string saves 
  16. $filters = array( 'pre_term_name', 'bb_pre_forum_name', 'pre_topic_title' ); 
  17. foreach ( $filters as $filter ) { 
  18. add_filter( $filter, 'strip_tags' ); 
  19. add_filter( $filter, 'trim' ); 
  20. add_filter( $filter, 'bb_filter_kses' ); 
  21. add_filter( $filter, 'esc_html', 30 ); 
  22.  
  23. // Kses only for textarea saves 
  24. $filters = array( 'pre_term_description', 'bb_pre_forum_desc' ); 
  25. foreach ( $filters as $filter ) { 
  26. add_filter( $filter, 'bb_filter_kses' ); 
  27.  
  28. // Slugs 
  29. add_filter( 'pre_term_slug', 'bb_pre_term_slug' ); 
  30. add_filter( 'editable_slug', 'urldecode'); 
  31.  
  32. // DB truncations 
  33. add_filter( 'pre_topic_title', 'bb_trim_for_db_150', 9999 ); 
  34. add_filter( 'bb_pre_forum_name', 'bb_trim_for_db_150', 9999 ); 
  35. add_filter( 'pre_term_name', 'bb_trim_for_db_55', 9999 ); 
  36.  
  37. // Format Strings for Display 
  38. $filters = array( 'forum_name', 'topic_title', 'bb_title', 'bb_option_name' ); 
  39. foreach ( $filters as $filter ) { 
  40. add_filter( $filter, 'esc_html' ); 
  41.  
  42. // Numbers 
  43. $filters = array( 'forum_topics', 'forum_posts', 'total_posts', 'total_users', 'total_topics' ); 
  44. foreach ( $filters as $filter ) { 
  45. add_filter( $filter, 'bb_number_format_i18n' ); 
  46.  
  47. // Offset Times 
  48. $filters = array( 'topic_time', 'topic_start_time', 'bb_post_time' ); 
  49. foreach ( $filters as $filter ) { 
  50. add_filter( $filter, 'bb_offset_time', 10, 2 ); 
  51.  
  52. add_filter('bb_topic_labels', 'bb_closed_label', 10); 
  53. add_filter('bb_topic_labels', 'bb_sticky_label', 20); 
  54.  
  55. add_filter('pre_post', 'trim'); 
  56. add_filter('pre_post', 'bb_encode_bad'); 
  57. add_filter('pre_post', 'bb_code_trick'); 
  58. add_filter('pre_post', 'force_balance_tags'); 
  59. add_filter('pre_post', 'bb_filter_kses', 50); 
  60. add_filter('pre_post', 'bb_autop', 60); 
  61.  
  62. add_filter('post_text', 'do_shortcode'); 
  63.  
  64. function bb_contextualise_search_post_text() 
  65. if ( bb_is_search() ) { 
  66. add_filter( 'get_post_text', 'bb_post_text_context' ); 
  67. add_action( 'bb_init', 'bb_contextualise_search_post_text' ); 
  68.  
  69. add_filter('post_text', 'make_clickable'); 
  70.  
  71. add_filter('edit_text', 'bb_code_trick_reverse'); 
  72. add_filter('edit_text', 'wp_specialchars'); 
  73. add_filter('edit_text', 'trim', 15); 
  74.  
  75. add_filter('pre_sanitize_with_dashes', 'bb_pre_sanitize_with_dashes_utf8', 10, 3 ); 
  76.  
  77. add_filter('get_user_link', 'bb_fix_link'); 
  78.  
  79. add_filter('sanitize_profile_info', 'esc_html'); 
  80. add_filter('sanitize_profile_admin', 'esc_html'); 
  81.  
  82. add_filter( 'get_recent_user_replies_fields', 'bb_get_recent_user_replies_fields' ); 
  83. add_filter( 'get_recent_user_replies_group_by', 'bb_get_recent_user_replies_group_by' ); 
  84.  
  85. add_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map'); 
  86.  
  87. // URLS 
  88.  
  89. if ( !bb_get_option( 'mod_rewrite' ) ) { 
  90. add_filter( 'bb_stylesheet_uri', 'esc_attr', 1, 9999 ); 
  91. add_filter( 'forum_link', 'esc_attr', 1, 9999 ); 
  92. add_filter( 'bb_forum_posts_rss_link', 'esc_attr', 1, 9999 ); 
  93. add_filter( 'bb_forum_topics_rss_link', 'esc_attr', 1, 9999 ); 
  94. add_filter( 'bb_tag_link', 'esc_attr', 1, 9999 ); 
  95. add_filter( 'tag_rss_link', 'esc_attr', 1, 9999 ); 
  96. add_filter( 'topic_link', 'esc_attr', 1, 9999 ); 
  97. add_filter( 'topic_rss_link', 'esc_attr', 1, 9999 ); 
  98. add_filter( 'post_link', 'esc_attr', 1, 9999 ); 
  99. add_filter( 'post_anchor_link', 'esc_attr', 1, 9999 ); 
  100. add_filter( 'user_profile_link', 'esc_attr', 1, 9999 ); 
  101. add_filter( 'profile_tab_link', 'esc_attr', 1, 9999 ); 
  102. add_filter( 'favorites_link', 'esc_attr', 1, 9999 ); 
  103. add_filter( 'view_link', 'esc_attr', 1, 9999 ); 
  104.  
  105. // Feed Stuff 
  106.  
  107. function bb_filter_feed_content() 
  108. if ( bb_is_feed() ) { 
  109. add_filter( 'bb_title_rss', 'strip_tags' ); 
  110. add_filter( 'bb_title_rss', 'ent2ncr', 8 ); 
  111. add_filter( 'bb_title_rss', 'esc_html' ); 
  112.  
  113. add_filter( 'bb_description_rss', 'strip_tags' ); 
  114. add_filter( 'bb_description_rss', 'ent2ncr', 8 ); 
  115. add_filter( 'bb_description_rss', 'esc_html' ); 
  116.  
  117. add_filter( 'post_author', 'ent2ncr', 8 ); 
  118. add_filter( 'post_link', 'esc_html' ); 
  119. add_filter( 'post_text', 'ent2ncr', 8 ); 
  120. add_filter( 'post_text', 'bb_convert_chars' ); 
  121. add_action( 'bb_init', 'bb_filter_feed_content' ); 
  122.  
  123. add_action( 'init_roles', 'bb_init_roles' ); 
  124. add_filter( 'map_meta_cap', 'bb_map_meta_cap', 1, 4 ); 
  125.  
  126. // Actions 
  127.  
  128. add_action( 'bb_head', 'bb_generator' ); 
  129. add_action('bb_head', 'bb_template_scripts'); 
  130. add_action('bb_head', 'wp_print_scripts'); 
  131. add_action('bb_head', 'wp_print_styles'); 
  132. add_action('bb_head', 'bb_rsd_link'); 
  133. add_action('bb_head', 'bb_pingback_link'); 
  134. if ( $bb_log->type === 'console' ) { 
  135. add_action('bb_head', array(&$bb_log, 'console_javascript')); 
  136. add_action('bb_admin_head', array(&$bb_log, 'console_javascript')); 
  137. add_action('bb_send_headers', 'bb_pingback_header'); 
  138. add_action('bb_admin_print_scripts', 'wp_print_scripts'); 
  139.  
  140. add_action('bb_user_has_no_caps', 'bb_give_user_default_role'); 
  141.  
  142. add_action('do_pingbacks', array('BB_Pingbacks', 'send_all'), 10, 1); 
  143.  
  144. add_action( 'bb_init', 'bb_register_default_views' ); 
  145.  
  146. add_action( 'set_current_user', 'bb_apply_wp_role_map_to_user' ); 
  147.  
  148. add_filter( 'bb_pre_get_option_gmt_offset', 'wp_timezone_override_offset' ); 
  149.  
  150. // Subscriptions 
  151.  
  152. if ( bb_is_subscriptions_active() ) { 
  153. add_action( 'bb_new_post', 'bb_notify_subscribers' ); 
  154. add_action( 'bb_insert_post', 'bb_user_subscribe_checkbox_update' ); 
  155. add_action( 'topicmeta', 'bb_user_subscribe_link' ); 
  156. add_action( 'edit_form', 'bb_user_subscribe_checkbox' );  
  157. add_action( 'post_form', 'bb_user_subscribe_checkbox' ); 
  158.  
  159. add_action( 'bb_post-form.php', 'bb_anonymous_post_form' ); 
  160.  
  161. unset( $filters, $filter ); 
.