loaded_components ) ) {
foreach( $bp->loaded_components as $component_slug => $component_id ) {
// Only components that need directories should be listed here.
if ( isset( $bp->{$component_id} ) && !empty( $bp->{$component_id}->has_directory ) ) {
// The component->name property was introduced in BP 1.5, so we must provide a fallback.
$directory_pages[$component_id] = !empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id );
}
}
}
/** Directory Display *****************************************************/
/**
* Filters the loaded components needing directory page association to a WordPress page.
*
* @since 1.5.0
*
* @param array $directory_pages Array of available components to set associations for.
*/
return apply_filters( 'bp_directory_pages', $directory_pages );
}
/**
* Generate a list of static pages, for use when building Components panel markup.
*
* By default, this list contains 'register' and 'activate'.
*
* @since 2.4.1
*
* @return array
*/
function bp_core_admin_get_static_pages() {
$static_pages = array(
'register' => __( 'Register', 'buddypress' ),
'activate' => __( 'Activate', 'buddypress' ),
);
/**
* Filters the default static pages for BuddyPress setup.
*
* @since 1.6.0
*
* @param array $static_pages Array of static default static pages.
*/
return apply_filters( 'bp_static_pages', $static_pages );
}
/**
* Creates reusable markup for page setup on the Components and Pages dashboard panel.
*
* @package BuddyPress
* @since 1.6.0
* @todo Use settings API
*/
function bp_core_admin_slugs_options() {
// Get the existing WP pages.
$existing_pages = bp_core_get_directory_page_ids();
// Set up an array of components (along with component names) that have directory pages.
$directory_pages = bp_core_admin_get_directory_pages();
if ( ! empty( $directory_pages ) ) : ?>
%2$s',
esc_url( network_admin_url( 'settings.php' ) ),
esc_html_x( 'this page', 'Link text for the Multisite’s network settings page', 'buddypress' )
)
);
?>
%2$s',
esc_url( admin_url( 'options-general.php' ) ),
esc_html_x( 'this page', 'Link text for the Site’s general options page', 'buddypress' )
)
);
?>
$value ) {
if ( isset( $valid_pages[ $key ] ) ) {
$new_directory_pages[ $key ] = (int) $value;
}
}
bp_core_update_directory_page_ids( $new_directory_pages );
}
$base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings', 'updated' => 'true' ), 'admin.php' ) );
wp_redirect( $base_url );
}
}
add_action( 'bp_admin_init', 'bp_core_admin_slugs_setup_handler' );