| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress Filters & Actions |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Hooks |
| 8 |
* |
| 9 |
* This file contains the actions and filters that are used through-out bbPress. |
| 10 |
* They are consolidated here to make searching for them easier, and to help |
| 11 |
* developers understand at a glance the order in which things occur. |
| 12 |
* |
| 13 |
* There are a few common places that additional actions can currently be found |
| 14 |
* |
| 15 |
* - bbPress: In {@link bbPress::_setup_actions()} in bbpress.php |
| 16 |
* - Component: In {@link BBP_Component::_setup_actions()} in |
| 17 |
* bbp-includes/bbp-classes.php |
| 18 |
* - Admin: More in {@link BBP_Admin::_setup_actions()} in |
| 19 |
* bbp-admin/bbp-admin.php |
| 20 |
*/ |
| 21 |
|
| 22 |
// Exit if accessed directly |
| 23 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 24 |
|
| 25 |
/** ACTIONS *******************************************************************/ |
| 26 |
|
| 27 |
/** |
| 28 |
* Attach bbPress to WordPress |
| 29 |
* |
| 30 |
* bbPress uses its own internal actions to help aid in additional plugin |
| 31 |
* development, and to limit the amount of potential future code changes when |
| 32 |
* updates to WordPress occur. |
| 33 |
*/ |
| 34 |
add_action( 'plugins_loaded', 'bbp_loaded', 10 ); |
| 35 |
add_action( 'init', 'bbp_init', 10 ); |
| 36 |
add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 ); |
| 37 |
add_filter( 'template_include', 'bbp_template_include', 10 ); |
| 38 |
|
| 39 |
/** |
| 40 |
* bbp_loaded - Attached to 'plugins_loaded' above |
| 41 |
* |
| 42 |
* Attach various loader actions to the bbp_loaded action. |
| 43 |
* The load order helps to load code at the correct time. |
| 44 |
* v---Load order |
| 45 |
*/ |
| 46 |
add_action( 'bbp_loaded', 'bbp_constants', 2 ); |
| 47 |
add_action( 'bbp_loaded', 'bbp_boot_strap_globals', 4 ); |
| 48 |
add_action( 'bbp_loaded', 'bbp_includes', 6 ); |
| 49 |
add_action( 'bbp_loaded', 'bbp_setup_globals', 8 ); |
| 50 |
add_action( 'bbp_loaded', 'bbp_register_theme_directory', 10 ); |
| 51 |
|
| 52 |
/** |
| 53 |
* bbp_init - Attached to 'init' above |
| 54 |
* |
| 55 |
* Attach various initialization actions to the init action. |
| 56 |
* The load order helps to load code at the correct time. |
| 57 |
* v---Load order |
| 58 |
*/ |
| 59 |
add_action( 'bbp_init', 'bbp_register_textdomain', 2 ); |
| 60 |
add_action( 'bbp_init', 'bbp_setup_current_user', 4 ); |
| 61 |
add_action( 'bbp_init', 'bbp_setup_theme_compat', 6 ); |
| 62 |
add_action( 'bbp_init', 'bbp_setup_akismet', 8 ); |
| 63 |
add_action( 'bbp_init', 'bbp_register_post_types', 10 ); |
| 64 |
add_action( 'bbp_init', 'bbp_register_post_statuses', 12 ); |
| 65 |
add_action( 'bbp_init', 'bbp_register_taxonomies', 14 ); |
| 66 |
add_action( 'bbp_init', 'bbp_register_views', 16 ); |
| 67 |
add_action( 'bbp_init', 'bbp_register_shortcodes', 18 ); |
| 68 |
add_action( 'bbp_init', 'bbp_add_rewrite_tags', 20 ); |
| 69 |
add_action( 'bbp_init', 'bbp_ready', 999 ); |
| 70 |
|
| 71 |
// Theme Compat |
| 72 |
add_action( 'bbp_setup_theme_compat', 'bbp_theme_compat_set_theme' ); |
| 73 |
add_action( 'bbp_setup_theme_compat', 'bbp_theme_compat_enqueue_css' ); |
| 74 |
|
| 75 |
// Admin |
| 76 |
if ( is_admin() ) { |
| 77 |
add_action( 'bbp_init', 'bbp_admin' ); |
| 78 |
add_action( 'bbp_admin_init', 'bbp_forums_admin', 9 ); |
| 79 |
add_action( 'bbp_admin_init', 'bbp_topics_admin', 9 ); |
| 80 |
add_action( 'bbp_admin_init', 'bbp_replies_admin', 9 ); |
| 81 |
add_action( 'bbp_admin_init', 'bbp_admin_settings_help' ); |
| 82 |
add_action( 'admin_menu', 'bbp_admin_separator' ); |
| 83 |
add_action( 'custom_menu_order', 'bbp_admin_custom_menu_order' ); |
| 84 |
add_action( 'menu_order', 'bbp_admin_menu_order' ); |
| 85 |
} |
| 86 |
|
| 87 |
// Widgets |
| 88 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Login_Widget");' ) ); |
| 89 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Views_Widget");' ) ); |
| 90 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Forums_Widget");' ) ); |
| 91 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");' ) ); |
| 92 |
add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) ); |
| 93 |
|
| 94 |
// Template - Head, foot, errors and messages |
| 95 |
add_action( 'wp_head', 'bbp_head' ); |
| 96 |
add_filter( 'wp_title', 'bbp_title', 10, 3 ); |
| 97 |
add_action( 'wp_footer', 'bbp_footer' ); |
| 98 |
add_action( 'bbp_loaded', 'bbp_login_notices' ); |
| 99 |
add_action( 'bbp_head', 'bbp_topic_notices' ); |
| 100 |
add_action( 'bbp_template_notices', 'bbp_template_notices' ); |
| 101 |
|
| 102 |
// Add to body class |
| 103 |
add_filter( 'body_class', 'bbp_body_class', 10, 2 ); |
| 104 |
|
| 105 |
// Caps & Roles |
| 106 |
add_filter( 'map_meta_cap', 'bbp_map_meta_caps', 10, 4 ); |
| 107 |
add_action( 'bbp_activation', 'bbp_add_roles', 1 ); |
| 108 |
add_action( 'bbp_activation', 'bbp_add_caps', 2 ); |
| 109 |
add_action( 'bbp_deactivation', 'bbp_remove_caps', 1 ); |
| 110 |
add_action( 'bbp_deactivation', 'bbp_remove_roles', 2 ); |
| 111 |
|
| 112 |
// Options & Settings |
| 113 |
add_action( 'bbp_activation', 'bbp_add_options', 1 ); |
| 114 |
|
| 115 |
// Multisite |
| 116 |
add_action( 'bbp_new_site', 'bbp_add_roles', 2 ); |
| 117 |
add_action( 'bbp_new_site', 'bbp_add_caps', 4 ); |
| 118 |
add_action( 'bbp_new_site', 'bbp_add_options', 6 ); |
| 119 |
|
| 120 |
// Topic Tag Page |
| 121 |
add_action( 'template_redirect', 'bbp_manage_topic_tag_handler', 1 ); |
| 122 |
|
| 123 |
// Before and After the Query |
| 124 |
add_action( 'pre_get_posts', 'bbp_pre_get_posts', 2 ); |
| 125 |
add_action( 'pre_get_posts', 'bbp_pre_get_posts_exclude_forums', 4 ); |
| 126 |
add_action( 'template_redirect', 'bbp_forum_visibility_check', -1 ); |
| 127 |
|
| 128 |
// Profile Edit |
| 129 |
add_action( 'template_redirect', 'bbp_edit_user_handler', 1 ); |
| 130 |
|
| 131 |
// Profile Page Messages |
| 132 |
add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' ); |
| 133 |
add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 ); |
| 134 |
|
| 135 |
// Update forum branch |
| 136 |
add_action( 'bbp_trashed_forum', 'bbp_update_forum_walker' ); |
| 137 |
add_action( 'bbp_untrashed_forum', 'bbp_update_forum_walker' ); |
| 138 |
add_action( 'bbp_deleted_forum', 'bbp_update_forum_walker' ); |
| 139 |
add_action( 'bbp_spammed_forum', 'bbp_update_forum_walker' ); |
| 140 |
add_action( 'bbp_unspammed_forum', 'bbp_update_forum_walker' ); |
| 141 |
|
| 142 |
// New/Edit Reply |
| 143 |
add_action( 'template_redirect', 'bbp_new_reply_handler' ); |
| 144 |
add_action( 'template_redirect', 'bbp_edit_reply_handler', 1 ); |
| 145 |
add_action( 'bbp_new_reply', 'bbp_update_reply', 10, 6 ); |
| 146 |
add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 6 ); |
| 147 |
|
| 148 |
// Before Delete/Trash/Untrash Reply |
| 149 |
add_action( 'trash_post', 'bbp_trash_reply' ); |
| 150 |
add_action( 'untrash_post', 'bbp_untrash_reply' ); |
| 151 |
add_action( 'delete_post', 'bbp_delete_reply' ); |
| 152 |
|
| 153 |
// After Deleted/Trashed/Untrashed Reply |
| 154 |
add_action( 'trashed_post', 'bbp_trashed_reply' ); |
| 155 |
add_action( 'untrashed_post', 'bbp_untrashed_reply' ); |
| 156 |
add_action( 'deleted_post', 'bbp_deleted_reply' ); |
| 157 |
|
| 158 |
// New/Edit Topic |
| 159 |
add_action( 'template_redirect', 'bbp_new_topic_handler' ); |
| 160 |
add_action( 'template_redirect', 'bbp_edit_topic_handler', 1 ); |
| 161 |
add_action( 'bbp_new_topic', 'bbp_update_topic', 10, 5 ); |
| 162 |
add_action( 'bbp_edit_topic', 'bbp_update_topic', 10, 5 ); |
| 163 |
|
| 164 |
// Split/Merge Topic |
| 165 |
add_action( 'template_redirect', 'bbp_merge_topic_handler', 1 ); |
| 166 |
add_action( 'template_redirect', 'bbp_split_topic_handler', 1 ); |
| 167 |
add_action( 'bbp_merged_topic', 'bbp_merge_topic_count', 1, 3 ); |
| 168 |
add_action( 'bbp_post_split_topic', 'bbp_split_topic_count', 1, 3 ); |
| 169 |
|
| 170 |
// Before Delete/Trash/Untrash Topic |
| 171 |
add_action( 'trash_post', 'bbp_trash_topic' ); |
| 172 |
add_action( 'untrash_post', 'bbp_untrash_topic' ); |
| 173 |
add_action( 'delete_post', 'bbp_delete_topic' ); |
| 174 |
|
| 175 |
// After Deleted/Trashed/Untrashed Topic |
| 176 |
add_action( 'trashed_post', 'bbp_trashed_topic' ); |
| 177 |
add_action( 'untrashed_post', 'bbp_untrashed_topic' ); |
| 178 |
add_action( 'deleted_post', 'bbp_deleted_topic' ); |
| 179 |
|
| 180 |
// Topic/Reply Actions |
| 181 |
add_action( 'template_redirect', 'bbp_toggle_topic_handler', 1 ); |
| 182 |
add_action( 'template_redirect', 'bbp_toggle_reply_handler', 1 ); |
| 183 |
|
| 184 |
// Favorites |
| 185 |
add_action( 'template_redirect', 'bbp_favorites_handler', 1 ); |
| 186 |
add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_favorites' ); |
| 187 |
add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_favorites' ); |
| 188 |
|
| 189 |
// Subscriptions |
| 190 |
add_action( 'template_redirect', 'bbp_subscriptions_handler', 1 ); |
| 191 |
add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_subscriptions' ); |
| 192 |
add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' ); |
| 193 |
add_action( 'bbp_new_reply', 'bbp_notify_subscribers', 1, 1 ); |
| 194 |
|
| 195 |
// Sticky |
| 196 |
add_action( 'bbp_trash_topic', 'bbp_unstick_topic' ); |
| 197 |
add_action( 'bbp_delete_topic', 'bbp_unstick_topic' ); |
| 198 |
|
| 199 |
// Update topic branch |
| 200 |
add_action( 'bbp_trashed_topic', 'bbp_update_topic_walker' ); |
| 201 |
add_action( 'bbp_untrashed_topic', 'bbp_update_topic_walker' ); |
| 202 |
add_action( 'bbp_deleted_topic', 'bbp_update_topic_walker' ); |
| 203 |
add_action( 'bbp_spammed_topic', 'bbp_update_topic_walker' ); |
| 204 |
add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' ); |
| 205 |
|
| 206 |
// Update reply branch |
| 207 |
add_action( 'bbp_trashed_reply', 'bbp_update_reply_walker' ); |
| 208 |
add_action( 'bbp_untrashed_reply', 'bbp_update_reply_walker' ); |
| 209 |
add_action( 'bbp_deleted_reply', 'bbp_update_reply_walker' ); |
| 210 |
add_action( 'bbp_spammed_reply', 'bbp_update_reply_walker' ); |
| 211 |
add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' ); |
| 212 |
|
| 213 |
/** |
| 214 |
* When a new site is created in a multisite installation, run the activation |
| 215 |
* routine on that site |
| 216 |
* |
| 217 |
* @since bbPress (r3283) |
| 218 |
* |
| 219 |
* @param int $blog_id |
| 220 |
* @param int $user_id |
| 221 |
* @param string $domain |
| 222 |
* @param string $path |
| 223 |
* @param int $site_id |
| 224 |
* @param array() $meta |
| 225 |
*/ |
| 226 |
function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
| 227 |
|
| 228 |
// Switch to the new blog |
| 229 |
switch_to_blog( $blog_id ); |
| 230 |
|
| 231 |
// Do the bbPress activation routine |
| 232 |
do_action( 'bbp_new_site' ); |
| 233 |
|
| 234 |
// restore original blog |
| 235 |
restore_current_blog(); |
| 236 |
} |
| 237 |
add_action( 'wpmu_new_blog', 'bbp_new_site', 10, 6 ); |
| 238 |
|
| 239 |
/** FILTERS *******************************************************************/ |
| 240 |
|
| 241 |
/** |
| 242 |
* Template Compatibility |
| 243 |
* |
| 244 |
* If you want to completely bypass this and manage your own custom bbPress |
| 245 |
* template hierarchy, start here by removing this filter, then look at how |
| 246 |
* bbp_template_include() works and do something similar. :) |
| 247 |
*/ |
| 248 |
add_filter( 'bbp_template_include', 'bbp_template_include_theme_supports', 2, 1 ); |
| 249 |
add_filter( 'bbp_template_include', 'bbp_template_include_theme_compat', 4, 2 ); |
| 250 |
|
| 251 |
/** |
| 252 |
* Feeds |
| 253 |
* |
| 254 |
* bbPress comes with a number of custom RSS2 feeds that get handled outside |
| 255 |
* the normal scope of feeds that WordPress would normally serve. To do this, |
| 256 |
* we filter every page request, listen for a feed request, and trap it. |
| 257 |
*/ |
| 258 |
add_filter( 'request', 'bbp_request_feed_trap' ); |
| 259 |
|
| 260 |
// Links |
| 261 |
add_filter( 'paginate_links', 'bbp_add_view_all' ); |
| 262 |
add_filter( 'bbp_get_topic_permalink', 'bbp_add_view_all' ); |
| 263 |
add_filter( 'bbp_get_reply_permalink', 'bbp_add_view_all' ); |
| 264 |
add_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' ); |
| 265 |
|
| 266 |
// wp_filter_kses on new/edit topic/reply title |
| 267 |
add_filter( 'bbp_new_reply_pre_title', 'wp_filter_kses' ); |
| 268 |
add_filter( 'bbp_new_topic_pre_title', 'wp_filter_kses' ); |
| 269 |
add_filter( 'bbp_edit_reply_pre_title', 'wp_filter_kses' ); |
| 270 |
add_filter( 'bbp_edit_topic_pre_title', 'wp_filter_kses' ); |
| 271 |
|
| 272 |
// balanceTags, wp_filter_kses and wp_rel_nofollow on new/edit topic/reply text |
| 273 |
add_filter( 'bbp_new_reply_pre_content', 'balanceTags' ); |
| 274 |
add_filter( 'bbp_new_reply_pre_content', 'wp_rel_nofollow' ); |
| 275 |
add_filter( 'bbp_new_reply_pre_content', 'wp_filter_kses' ); |
| 276 |
add_filter( 'bbp_new_topic_pre_content', 'balanceTags' ); |
| 277 |
add_filter( 'bbp_new_topic_pre_content', 'wp_rel_nofollow' ); |
| 278 |
add_filter( 'bbp_new_topic_pre_content', 'wp_filter_kses' ); |
| 279 |
add_filter( 'bbp_edit_reply_pre_content', 'balanceTags' ); |
| 280 |
add_filter( 'bbp_edit_reply_pre_content', 'wp_rel_nofollow' ); |
| 281 |
add_filter( 'bbp_edit_reply_pre_content', 'wp_filter_kses' ); |
| 282 |
add_filter( 'bbp_edit_topic_pre_content', 'balanceTags' ); |
| 283 |
add_filter( 'bbp_edit_topic_pre_content', 'wp_rel_nofollow' ); |
| 284 |
add_filter( 'bbp_edit_topic_pre_content', 'wp_filter_kses' ); |
| 285 |
|
| 286 |
// Add number format filter to functions requiring numeric output |
| 287 |
add_filter( 'bbp_get_forum_topic_count', 'bbp_number_format' ); |
| 288 |
add_filter( 'bbp_get_forum_topic_reply_count', 'bbp_number_format' ); |
| 289 |
|
| 290 |
// No follow and stripslashes on user profile links |
| 291 |
add_filter( 'bbp_get_reply_author_link', 'wp_rel_nofollow' ); |
| 292 |
add_filter( 'bbp_get_reply_author_link', 'stripslashes' ); |
| 293 |
add_filter( 'bbp_get_topic_author_link', 'wp_rel_nofollow' ); |
| 294 |
add_filter( 'bbp_get_topic_author_link', 'stripslashes' ); |
| 295 |
add_filter( 'bbp_get_user_favorites_link', 'wp_rel_nofollow' ); |
| 296 |
add_filter( 'bbp_get_user_favorites_link', 'stripslashes' ); |
| 297 |
add_filter( 'bbp_get_user_subscribe_link', 'wp_rel_nofollow' ); |
| 298 |
add_filter( 'bbp_get_user_subscribe_link', 'stripslashes' ); |
| 299 |
add_filter( 'bbp_get_user_profile_link', 'wp_rel_nofollow' ); |
| 300 |
add_filter( 'bbp_get_user_profile_link', 'stripslashes' ); |
| 301 |
add_filter( 'bbp_get_user_profile_edit_link', 'wp_rel_nofollow' ); |
| 302 |
add_filter( 'bbp_get_user_profile_edit_link', 'stripslashes' ); |
| 303 |
|
| 304 |
// Run wp_kses_data on topic/reply content in admin section |
| 305 |
if ( is_admin() ) { |
| 306 |
add_filter( 'bbp_get_reply_content', 'wp_kses_data' ); |
| 307 |
add_filter( 'bbp_get_topic_content', 'wp_kses_data' ); |
| 308 |
} |
| 309 |
|
| 310 |
// Run filters on reply content |
| 311 |
if ( !is_admin() ) |
| 312 |
add_filter( 'bbp_get_reply_content', 'bbp_reply_content_append_revisions', 1, 2 ); |
| 313 |
add_filter( 'bbp_get_reply_content', 'capital_P_dangit' ); |
| 314 |
add_filter( 'bbp_get_reply_content', 'wptexturize', 3 ); |
| 315 |
add_filter( 'bbp_get_reply_content', 'convert_chars', 5 ); |
| 316 |
add_filter( 'bbp_get_reply_content', 'make_clickable', 9 ); |
| 317 |
add_filter( 'bbp_get_reply_content', 'force_balance_tags', 25 ); |
| 318 |
add_filter( 'bbp_get_reply_content', 'convert_smilies', 20 ); |
| 319 |
add_filter( 'bbp_get_reply_content', 'wpautop', 30 ); |
| 320 |
|
| 321 |
// Run filters on topic content |
| 322 |
if ( !is_admin() ) |
| 323 |
add_filter( 'bbp_get_topic_content', 'bbp_topic_content_append_revisions', 1, 2 ); |
| 324 |
add_filter( 'bbp_get_topic_content', 'capital_P_dangit' ); |
| 325 |
add_filter( 'bbp_get_topic_content', 'wptexturize', 3 ); |
| 326 |
add_filter( 'bbp_get_topic_content', 'convert_chars', 5 ); |
| 327 |
add_filter( 'bbp_get_topic_content', 'make_clickable', 9 ); |
| 328 |
add_filter( 'bbp_get_topic_content', 'force_balance_tags', 25 ); |
| 329 |
add_filter( 'bbp_get_topic_content', 'convert_smilies', 20 ); |
| 330 |
add_filter( 'bbp_get_topic_content', 'wpautop', 30 ); |
| 331 |
|
| 332 |
// Canonical |
| 333 |
add_filter( 'redirect_canonical', 'bbp_redirect_canonical' ); |
| 334 |
|
| 335 |
// Login/Register/Lost Password |
| 336 |
add_filter( 'login_redirect', 'bbp_redirect_login', 2, 3 ); |
| 337 |
add_filter( 'logout_url', 'bbp_logout_url', 2, 2 ); |
| 338 |
|
| 339 |
// Fix post author id for anonymous posts (set it back to 0) when the post status is changed |
| 340 |
add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); |
| 341 |
|
| 342 |
// Suppress private forum details |
| 343 |
add_filter( 'bbp_get_forum_topic_count', 'bbp_suppress_private_forum_meta', 10, 2 ); |
| 344 |
add_filter( 'bbp_get_forum_reply_count', 'bbp_suppress_private_forum_meta', 10, 2 ); |
| 345 |
add_filter( 'bbp_get_forum_post_count', 'bbp_suppress_private_forum_meta', 10, 2 ); |
| 346 |
add_filter( 'bbp_get_forum_freshness_link', 'bbp_suppress_private_forum_meta', 10, 2 ); |
| 347 |
add_filter( 'bbp_get_author_link', 'bbp_suppress_private_author_link', 10, 2 ); |
| 348 |
add_filter( 'bbp_get_topic_author_link', 'bbp_suppress_private_author_link', 10, 2 ); |
| 349 |
add_filter( 'bbp_get_reply_author_link', 'bbp_suppress_private_author_link', 10, 2 ); |
| 350 |
|
| 351 |
/** |
| 352 |
* Add filters to anonymous post author data |
| 353 |
* |
| 354 |
* This is used to clean-up any anonymous user data that is submitted via the |
| 355 |
* new topic and new reply forms. |
| 356 |
* |
| 357 |
* @uses add_filter() To add filters |
| 358 |
*/ |
| 359 |
function bbp_pre_anonymous_filters () { |
| 360 |
|
| 361 |
// Post author name |
| 362 |
$filters = array( |
| 363 |
'trim' => 10, |
| 364 |
'sanitize_text_field' => 10, |
| 365 |
'wp_filter_kses' => 10, |
| 366 |
'_wp_specialchars' => 30 |
| 367 |
); |
| 368 |
foreach ( $filters as $filter => $priority ) |
| 369 |
add_filter( 'bbp_pre_anonymous_post_author_name', $filter, $priority ); |
| 370 |
|
| 371 |
// Email saves |
| 372 |
foreach ( array( 'trim', 'sanitize_email', 'wp_filter_kses' ) as $filter ) |
| 373 |
add_filter( 'bbp_pre_anonymous_post_author_email', $filter ); |
| 374 |
|
| 375 |
// Save URL |
| 376 |
foreach ( array( 'trim', 'wp_strip_all_tags', 'esc_url_raw', 'wp_filter_kses' ) as $filter ) |
| 377 |
add_filter( 'bbp_pre_anonymous_post_author_website', $filter ); |
| 378 |
} |
| 379 |
bbp_pre_anonymous_filters(); |
| 380 |
|
| 381 |
/** |
| 382 |
* On multisite installations you must first allow themes to be activated and |
| 383 |
* show up on the theme selection screen. This function will let the bbPress |
| 384 |
* bundled themes show up and bypass this step. |
| 385 |
* |
| 386 |
* @since bbPress (r2944) |
| 387 |
* |
| 388 |
* @uses apply_filters() Calls 'bbp_allowed_themes' with the allowed themes list |
| 389 |
*/ |
| 390 |
function bbp_allowed_themes( $themes ) { |
| 391 |
$themes['bbp-twentyten'] = 1; |
| 392 |
|
| 393 |
return apply_filters( 'bbp_allowed_themes', $themes ); |
| 394 |
} |
| 395 |
add_filter( 'allowed_themes', 'bbp_allowed_themes' ); |
| 396 |
|
| 397 |
/** Main Actions **************************************************************/ |
| 398 |
|
| 399 |
/** |
| 400 |
* Main action responsible for constants, globals, and includes |
| 401 |
* |
| 402 |
* @since bbPress (r2599) |
| 403 |
* |
| 404 |
* @uses do_action() Calls 'bbp_loaded' |
| 405 |
*/ |
| 406 |
function bbp_loaded() { |
| 407 |
do_action( 'bbp_loaded' ); |
| 408 |
} |
| 409 |
|
| 410 |
/** |
| 411 |
* Setup constants |
| 412 |
* |
| 413 |
* @since bbPress (r2599) |
| 414 |
* |
| 415 |
* @uses do_action() Calls 'bbp_constants' |
| 416 |
*/ |
| 417 |
function bbp_constants() { |
| 418 |
do_action( 'bbp_constants' ); |
| 419 |
} |
| 420 |
|
| 421 |
/** |
| 422 |
* Setup globals BEFORE includes |
| 423 |
* |
| 424 |
* @since bbPress (r2599) |
| 425 |
* |
| 426 |
* @uses do_action() Calls 'bbp_boot_strap_globals' |
| 427 |
*/ |
| 428 |
function bbp_boot_strap_globals() { |
| 429 |
do_action( 'bbp_boot_strap_globals' ); |
| 430 |
} |
| 431 |
|
| 432 |
/** |
| 433 |
* Include files |
| 434 |
* |
| 435 |
* @since bbPress (r2599) |
| 436 |
* |
| 437 |
* @uses do_action() Calls 'bbp_includes' |
| 438 |
*/ |
| 439 |
function bbp_includes() { |
| 440 |
do_action( 'bbp_includes' ); |
| 441 |
} |
| 442 |
|
| 443 |
/** |
| 444 |
* Setup globals AFTER includes |
| 445 |
* |
| 446 |
* @since bbPress (r2599) |
| 447 |
* |
| 448 |
* @uses do_action() Calls 'bbp_setup_globals' |
| 449 |
*/ |
| 450 |
function bbp_setup_globals() { |
| 451 |
do_action( 'bbp_setup_globals' ); |
| 452 |
} |
| 453 |
|
| 454 |
/** |
| 455 |
* Initialize any code after everything has been loaded |
| 456 |
* |
| 457 |
* @since bbPress (r2599) |
| 458 |
* |
| 459 |
* @uses do_action() Calls 'bbp_init' |
| 460 |
*/ |
| 461 |
function bbp_init() { |
| 462 |
do_action ( 'bbp_init' ); |
| 463 |
} |
| 464 |
|
| 465 |
/** Supplemental Actions ******************************************************/ |
| 466 |
|
| 467 |
/** |
| 468 |
* Setup the currently logged-in user |
| 469 |
* |
| 470 |
* @since bbPress (r2695) |
| 471 |
* |
| 472 |
* @uses do_action() Calls 'bbp_setup_current_user' |
| 473 |
*/ |
| 474 |
function bbp_setup_current_user() { |
| 475 |
do_action ( 'bbp_setup_current_user' ); |
| 476 |
} |
| 477 |
|
| 478 |
/** |
| 479 |
* Load translations for current language |
| 480 |
* |
| 481 |
* @since bbPress (r2599) |
| 482 |
* |
| 483 |
* @uses do_action() Calls 'bbp_load_textdomain' |
| 484 |
*/ |
| 485 |
function bbp_register_textdomain() { |
| 486 |
do_action( 'bbp_load_textdomain' ); |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* Sets up the theme directory |
| 491 |
* |
| 492 |
* @since bbPress (r2507) |
| 493 |
* |
| 494 |
* @uses do_action() Calls 'bbp_register_theme_directory' |
| 495 |
*/ |
| 496 |
function bbp_register_theme_directory() { |
| 497 |
do_action( 'bbp_register_theme_directory' ); |
| 498 |
} |
| 499 |
|
| 500 |
/** |
| 501 |
* Setup the post types |
| 502 |
* |
| 503 |
* @since bbPress (r2464) |
| 504 |
* |
| 505 |
* @uses do_action() Calls 'bbp_register_post_type' |
| 506 |
*/ |
| 507 |
function bbp_register_post_types() { |
| 508 |
do_action ( 'bbp_register_post_types' ); |
| 509 |
} |
| 510 |
|
| 511 |
/** |
| 512 |
* Setup the post statuses |
| 513 |
* |
| 514 |
* @since bbPress (r2727) |
| 515 |
* |
| 516 |
* @uses do_action() Calls 'bbp_register_post_statuses' |
| 517 |
*/ |
| 518 |
function bbp_register_post_statuses() { |
| 519 |
do_action ( 'bbp_register_post_statuses' ); |
| 520 |
} |
| 521 |
|
| 522 |
/** |
| 523 |
* Register the built in bbPress taxonomies |
| 524 |
* |
| 525 |
* @since bbPress (r2464) |
| 526 |
* |
| 527 |
* @uses do_action() Calls 'bbp_register_taxonomies' |
| 528 |
*/ |
| 529 |
function bbp_register_taxonomies() { |
| 530 |
do_action ( 'bbp_register_taxonomies' ); |
| 531 |
} |
| 532 |
|
| 533 |
/** |
| 534 |
* Register the default bbPress views |
| 535 |
* |
| 536 |
* @since bbPress (r2789) |
| 537 |
* |
| 538 |
* @uses do_action() Calls 'bbp_register_views' |
| 539 |
*/ |
| 540 |
function bbp_register_views() { |
| 541 |
do_action ( 'bbp_register_views' ); |
| 542 |
} |
| 543 |
|
| 544 |
/** |
| 545 |
* Add the bbPress-specific rewrite tags |
| 546 |
* |
| 547 |
* @since bbPress (r2753) |
| 548 |
* |
| 549 |
* @uses do_action() Calls 'bbp_add_rewrite_tags' |
| 550 |
*/ |
| 551 |
function bbp_add_rewrite_tags() { |
| 552 |
do_action ( 'bbp_add_rewrite_tags' ); |
| 553 |
} |
| 554 |
|
| 555 |
/** |
| 556 |
* Generate bbPress-specific rewrite rules |
| 557 |
* |
| 558 |
* @since bbPress (r2688) |
| 559 |
* |
| 560 |
* @param WP_Rewrite $wp_rewrite |
| 561 |
* |
| 562 |
* @uses do_action() Calls 'bbp_generate_rewrite_rules' with {@link WP_Rewrite} |
| 563 |
*/ |
| 564 |
function bbp_generate_rewrite_rules( $wp_rewrite ) { |
| 565 |
do_action_ref_array( 'bbp_generate_rewrite_rules', array( &$wp_rewrite ) ); |
| 566 |
} |
| 567 |
|
| 568 |
/** |
| 569 |
* Setup bbPress theme compatability actions |
| 570 |
* |
| 571 |
* @since bbPress (r3028) |
| 572 |
* |
| 573 |
* @uses do_action() Calls 'bbp_setup_theme_compat' |
| 574 |
*/ |
| 575 |
function bbp_setup_theme_compat() { |
| 576 |
do_action( 'bbp_setup_theme_compat' ); |
| 577 |
} |
| 578 |
|
| 579 |
/** Final Action **************************************************************/ |
| 580 |
|
| 581 |
/** |
| 582 |
* bbPress has loaded and initialized everything, and is okay to go |
| 583 |
* |
| 584 |
* @since bbPress (r2618) |
| 585 |
* |
| 586 |
* @uses do_action() Calls 'bbp_ready' |
| 587 |
*/ |
| 588 |
function bbp_ready() { |
| 589 |
do_action( 'bbp_ready' ); |
| 590 |
} |
| 591 |
|
| 592 |
/** Theme Compatibility Filter ************************************************/ |
| 593 |
|
| 594 |
/** |
| 595 |
* The main filter used for theme compatibility and displaying custom bbPress |
| 596 |
* theme files. |
| 597 |
* |
| 598 |
* @since bbPress (r3311) |
| 599 |
* |
| 600 |
* @uses apply_filters() |
| 601 |
* |
| 602 |
* @param string $template |
| 603 |
* @return string Template file to use |
| 604 |
*/ |
| 605 |
function bbp_template_include( $template = '' ) { |
| 606 |
return apply_filters( 'bbp_template_include', $template ); |
| 607 |
} |
| 608 |
|
| 609 |
?> |
| 610 |
|