bp_core_admin_create_background_page()
Catch and process an admin directory page.
Description
Source
File: bp-core/admin/bp-core-admin-functions.php
2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 | function bp_core_admin_create_background_page() { if ( ! current_user_can( 'install_plugins' ) ) { wp_send_json_error(); } if ( empty ( $_POST [ 'page' ] ) ) { wp_send_json_error(); } $page_ids = bp_core_get_directory_page_ids( 'all' ); $valid_pages = array_merge ( bp_core_admin_get_directory_pages(), bp_core_admin_get_static_pages() ); if ( isset( $valid_pages [ $_POST [ 'page' ] ] ) ) { $default_title = bp_core_get_directory_page_default_titles(); $title = ( isset( $default_title [ $_POST [ 'page' ] ] ) ) ? $default_title [ $_POST [ 'page' ] ] : $valid_pages [ $_POST [ 'page' ] ]; $new_page = array ( 'post_title' => $title , 'post_status' => 'publish' , 'post_author' => bp_loggedin_user_id(), 'post_type' => 'page' , 'comment_status' => 'closed' , 'ping_status' => 'closed' , ); $page_id = wp_insert_post( $new_page ); $page_ids [ $_POST [ 'page' ] ] = (int) $page_id ; // If forums page then store into the _bbp_root_slug_custom_slug option. if ( 'new_forums_page' === $_POST [ 'page' ] ) { bp_update_option( '_bbp_root_slug_custom_slug' , $page_id ); // Else store into the directory pages. } else { bp_core_update_directory_page_ids( $page_ids ); } // If forums page then change the BBPress root slug _bbp_root_slug and flush the redirect rule. if ( 'new_forums_page' === $_POST [ 'page' ] ) { $slug = get_post_field( 'post_name' , $page_id ); bp_update_option( '_bbp_root_slug' , $slug ); flush_rewrite_rules(true); } } $response = array ( 'feedback' => __( 'Added successfully' , 'buddyboss' ), 'type' => 'success' , 'url' => add_query_arg([ 'page' => 'bp-pages' , 'added' => 'true' , ], admin_url( 'admin.php' ) ) ); wp_send_json_success( $response ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.