Changeset 6485 for trunk/src/includes/extend/buddypress/functions.php
- Timestamp:
- 06/04/2017 09:49:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/extend/buddypress/functions.php
r6438 r6485 16 16 add_filter( 'bbp_is_single_user', 'bbp_filter_is_single_user', 10, 1 ); 17 17 add_filter( 'bbp_is_user_home', 'bbp_filter_is_user_home', 10, 1 ); 18 19 // Group Forum Root 20 add_action( 'load-settings_page_bbpress', 'bbp_maybe_create_group_forum_root' ); 21 add_action( 'bbp_delete_forum', 'bbp_maybe_delete_group_forum_root' ); 18 22 19 23 /** BuddyPress Helpers ********************************************************/ … … 306 310 } 307 311 312 /** Forum Group Root **********************************************************/ 313 314 /** 315 * Clean up the group root setting if the forum is being deleted 316 * 317 * @since 2.6.0 bbPress (r6479) 318 * 319 * @param int $forum_id The forum ID being deleted 320 */ 321 function bbp_maybe_delete_group_forum_root( $forum_id = 0 ) { 322 323 // Bail if no forum ID 324 $forum_id = bbp_get_forum_id(); 325 if ( empty( $forum_id ) ) { 326 return; 327 } 328 329 // Get the group root 330 $group_root = (int) get_option( '_bbp_group_forums_root_id', 0 ); 331 332 // Delete the group root if the forum just got deleted 333 if ( $group_root === $forum_id ) { 334 delete_option( '_bbp_group_forums_root_id' ); 335 } 336 } 337 338 /** 339 * Handle the new group forum root creation 340 * 341 * @since 2.6.0 bbPress (r6479) 342 * 343 * @return 344 */ 345 function bbp_maybe_create_group_forum_root() { 346 347 // Bail if no nonce 348 if ( empty( $_GET['_wpnonce'] ) || ( empty( $_GET['create'] ) || ( 'bbp-group-forum-root' !== $_GET['create'] ) ) ) { 349 return; 350 } 351 352 // Bail if user cannot publish forums 353 if ( ! current_user_can( 'publish_forums' ) ) { 354 return; 355 } 356 357 // Bail if nonce check fails 358 if ( ! wp_verify_nonce( $_GET['_wpnonce'], '_bbp_group_forums_root_id' ) ) { 359 return; 360 } 361 362 // Create new forum 363 $forum_id = bbp_insert_forum( 364 365 // Post 366 array( 'post_title' => esc_html__( 'Group Forums', 'bbpress' ) ), 367 368 // Meta 369 array( 'forum_type' => 'category' ) 370 ); 371 372 // Update & redirect 373 if ( ! empty( $forum_id ) ) { 374 375 // Create 376 update_option( '_bbp_group_forums_root_id', $forum_id ); 377 378 // Redirect 379 wp_safe_redirect( add_query_arg( array( 380 'page' => 'bbpress', 381 'updated' => true // Lame, but still supported 382 ), admin_url( 'options-general.php' ) ) ); 383 die; 384 } 385 } 386 308 387 /** Forum/Group Sync **********************************************************/ 309 388 310 389 /** 311 390 * These functions are used to keep the many-to-many relationships between 312 * groups and forums synchronized. Each forum and group stores po nters to each391 * groups and forums synchronized. Each forum and group stores pointers to each 313 392 * other in their respective meta. This way if a group or forum is deleted 314 * their associat tions can be updated without much effort.393 * their associations can be updated without much effort. 315 394 */ 316 395 … … 512 591 513 592 /** 514 * Remove a group from a all forums593 * Remove a group from all forums 515 594 * 516 595 * @param type $group_id
Note: See TracChangeset
for help on using the changeset viewer.