setup_globals(); $this->includes(); $this->setup_actions(); } /** * Set admin-related globals. * * @since 1.6.0 */ private function setup_globals() { $bp = buddypress(); // Paths and URLs $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-core/admin' ); // Admin path. $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-core/admin' ); // Admin url. $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL. $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL. $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL. // Main settings page. $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; // Main capability. $this->capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options'; } /** * Include required files. * * @since 1.6.0 */ private function includes() { require( $this->admin_dir . 'bp-core-admin-actions.php' ); require( $this->admin_dir . 'bp-core-admin-settings.php' ); require( $this->admin_dir . 'bp-core-admin-functions.php' ); require( $this->admin_dir . 'bp-core-admin-components.php' ); require( $this->admin_dir . 'bp-core-admin-slugs.php' ); require( $this->admin_dir . 'bp-core-admin-tools.php' ); } /** * Set up the admin hooks, actions, and filters. * * @since 1.6.0 * */ private function setup_actions() { /* General Actions ***************************************************/ // Add some page specific output to the . add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); // Add menu item to settings menu. add_action( 'admin_menu', array( $this, 'site_admin_menus' ), 5 ); add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); // Enqueue all admin JS and CSS. add_action( 'bp_admin_enqueue_scripts', array( $this, 'admin_register_styles' ), 1 ); add_action( 'bp_admin_enqueue_scripts', array( $this, 'admin_register_scripts' ), 1 ); add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); /* BuddyPress Actions ************************************************/ // Load the BuddyPress metabox in the WP Nav Menu Admin UI. add_action( 'load-nav-menus.php', 'bp_admin_wp_nav_menu_meta_box' ); // Add settings. add_action( 'bp_register_admin_settings', array( $this, 'register_admin_settings' ) ); // Add a link to BuddyPress About page to the admin bar. add_action( 'admin_bar_menu', array( $this, 'admin_bar_about_link' ), 15 ); // Add a description of new BuddyPress tools in the available tools page. add_action( 'tool_box', 'bp_core_admin_available_tools_intro' ); add_action( 'bp_network_tool_box', 'bp_core_admin_available_tools_intro' ); // On non-multisite, catch. add_action( 'load-users.php', 'bp_core_admin_user_manage_spammers' ); // Emails. add_filter( 'manage_' . bp_get_email_post_type() . '_posts_columns', array( $this, 'emails_register_situation_column' ) ); add_action( 'manage_' . bp_get_email_post_type() . '_posts_custom_column', array( $this, 'emails_display_situation_column_data' ), 10, 2 ); /* Filters ***********************************************************/ // Add link to settings page. add_filter( 'plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 ); add_filter( 'network_admin_plugin_action_links', array( $this, 'modify_plugin_action_links' ), 10, 2 ); // Add "Mark as Spam" row actions on users.php. add_filter( 'ms_user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 ); add_filter( 'user_row_actions', 'bp_core_admin_user_row_actions', 10, 2 ); // Emails add_filter( 'bp_admin_menu_order', array( $this, 'emails_admin_menu_order' ), 20 ); } /** * Register site- or network-admin nav menu elements. * * Contextually hooked to site or network-admin depending on current configuration. * * @since 1.6.0 */ public function admin_menus() { // Bail if user cannot moderate. if ( ! bp_current_user_can( 'manage_options' ) ) { return; } // About. add_dashboard_page( __( 'Welcome to BuddyPress', 'buddypress' ), __( 'Welcome to BuddyPress', 'buddypress' ), 'manage_options', 'bp-about', array( $this, 'about_screen' ) ); // Credits. add_dashboard_page( __( 'Welcome to BuddyPress', 'buddypress' ), __( 'Welcome to BuddyPress', 'buddypress' ), 'manage_options', 'bp-credits', array( $this, 'credits_screen' ) ); $hooks = array(); // Changed in BP 1.6 . See bp_core_admin_backpat_menu(). $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_menu', 'div' ); $hooks[] = add_submenu_page( 'bp-general-settings', __( 'BuddyPress Help', 'buddypress' ), __( 'Help', 'buddypress' ), $this->capability, 'bp-general-settings', 'bp_core_admin_backpat_page' ); // Add the option pages. $hooks[] = add_submenu_page( $this->settings_page, __( 'BuddyPress Components', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), $this->capability, 'bp-components', 'bp_core_admin_components_settings' ); $hooks[] = add_submenu_page( $this->settings_page, __( 'BuddyPress Pages', 'buddypress' ), __( 'BuddyPress Pages', 'buddypress' ), $this->capability, 'bp-page-settings', 'bp_core_admin_slugs_settings' ); $hooks[] = add_submenu_page( $this->settings_page, __( 'BuddyPress Options', 'buddypress' ), __( 'BuddyPress Options', 'buddypress' ), $this->capability, 'bp-settings', 'bp_core_admin_settings' ); // For consistency with non-Multisite, we add a Tools menu in // the Network Admin as a home for our Tools panel. if ( is_multisite() && bp_core_do_network_admin() ) { $tools_parent = 'network-tools'; $hooks[] = add_menu_page( __( 'Tools', 'buddypress' ), __( 'Tools', 'buddypress' ), $this->capability, $tools_parent, 'bp_core_tools_top_level_item', '', 24 // Just above Settings. ); $hooks[] = add_submenu_page( $tools_parent, __( 'Available Tools', 'buddypress' ), __( 'Available Tools', 'buddypress' ), $this->capability, 'available-tools', 'bp_core_admin_available_tools_page' ); } else { $tools_parent = 'tools.php'; } $hooks[] = add_submenu_page( $tools_parent, __( 'BuddyPress Tools', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), $this->capability, 'bp-tools', 'bp_core_admin_tools' ); // For network-wide configs, add a link to (the root site's) Emails screen. if ( is_network_admin() && bp_is_network_activated() ) { $email_labels = bp_get_email_post_type_labels(); $email_url = get_admin_url( bp_get_root_blog_id(), 'edit.php?post_type=' . bp_get_email_post_type() ); $hooks[] = add_menu_page( $email_labels['name'], $email_labels['menu_name'], $this->capability, '', '', 'dashicons-email', 26 ); // Hack: change the link to point to the root site's admin, not the network admin. $GLOBALS['menu'][26][2] = esc_url_raw( $email_url ); } foreach( $hooks as $hook ) { add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); } } /** * Register site-admin nav menu elements. * * @since 2.5.0 */ public function site_admin_menus() { if ( ! bp_current_user_can( 'manage_options' ) ) { return; } $hooks = array(); // Require WP 4.0+. if ( bp_is_root_blog() && version_compare( $GLOBALS['wp_version'], '4.0', '>=' ) ) { // Appearance > Emails. $hooks[] = add_theme_page( _x( 'Emails', 'screen heading', 'buddypress' ), _x( 'Emails', 'screen heading', 'buddypress' ), $this->capability, 'bp-emails-customizer-redirect', 'bp_email_redirect_to_customizer' ); // Emails > Customize. $hooks[] = add_submenu_page( 'edit.php?post_type=' . bp_get_email_post_type(), _x( 'Customize', 'email menu label', 'buddypress' ), _x( 'Customize', 'email menu label', 'buddypress' ), $this->capability, 'bp-emails-customizer-redirect', 'bp_email_redirect_to_customizer' ); } foreach( $hooks as $hook ) { add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); } } /** * Register the settings. * * @since 1.6.0 * */ public function register_admin_settings() { /* Main Section ******************************************************/ // Add the main section. add_settings_section( 'bp_main', __( 'Main Settings', 'buddypress' ), 'bp_admin_setting_callback_main_section', 'buddypress' ); // Hide toolbar for logged out users setting. add_settings_field( 'hide-loggedout-adminbar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_admin_bar', 'buddypress', 'bp_main' ); register_setting( 'buddypress', 'hide-loggedout-adminbar', 'intval' ); // Only show 'switch to Toolbar' option if the user chose to retain the BuddyBar during the 1.6 upgrade. if ( (bool) bp_get_option( '_bp_force_buddybar', false ) ) { // Load deprecated code if not available. if ( ! function_exists( 'bp_admin_setting_callback_force_buddybar' ) ) { require buddypress()->plugin_dir . 'bp-core/deprecated/2.1.php'; } add_settings_field( '_bp_force_buddybar', __( 'Toolbar', 'buddypress' ), 'bp_admin_setting_callback_force_buddybar', 'buddypress', 'bp_main' ); register_setting( 'buddypress', '_bp_force_buddybar', 'bp_admin_sanitize_callback_force_buddybar' ); } // Allow account deletion. add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' ); register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' ); // Template pack picker. add_settings_field( '_bp_theme_package_id', __( 'Template Pack', 'buddypress' ), 'bp_admin_setting_callback_theme_package_id', 'buddypress', 'bp_main' ); register_setting( 'buddypress', '_bp_theme_package_id', 'sanitize_text_field' ); /* XProfile Section **************************************************/ if ( bp_is_active( 'xprofile' ) ) { // Add the main section. add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' ); // Avatars. add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' ); register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' ); // Cover images. if ( bp_is_active( 'xprofile', 'cover_image' ) ) { add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' ); register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' ); } // Profile sync setting. add_settings_field( 'bp-disable-profile-sync', __( 'Profile Syncing', 'buddypress' ), 'bp_admin_setting_callback_profile_sync', 'buddypress', 'bp_xprofile' ); register_setting ( 'buddypress', 'bp-disable-profile-sync', 'intval' ); } /* Groups Section ****************************************************/ if ( bp_is_active( 'groups' ) ) { // Add the main section. add_settings_section( 'bp_groups', __( 'Groups Settings', 'buddypress' ), 'bp_admin_setting_callback_groups_section', 'buddypress' ); // Allow subscriptions setting. add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation', 'buddypress' ), 'bp_admin_setting_callback_group_creation', 'buddypress', 'bp_groups' ); register_setting( 'buddypress', 'bp_restrict_group_creation', 'intval' ); // Allow group avatars. add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' ); register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' ); // Allow group cover images. if ( bp_is_active( 'groups', 'cover_image' ) ) { add_settings_field( 'bp-disable-group-cover-image-uploads', __( 'Group Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_cover_image_uploads', 'buddypress', 'bp_groups' ); register_setting( 'buddypress', 'bp-disable-group-cover-image-uploads', 'intval' ); } } /* Forums ************************************************************/ if ( bp_is_active( 'forums' ) ) { // Add the main section. add_settings_section( 'bp_forums', __( 'Legacy Group Forums', 'buddypress' ), 'bp_admin_setting_callback_bbpress_section', 'buddypress' ); // Allow subscriptions setting. add_settings_field( 'bb-config-location', __( 'bbPress Configuration', 'buddypress' ), 'bp_admin_setting_callback_bbpress_configuration', 'buddypress', 'bp_forums' ); register_setting( 'buddypress', 'bb-config-location', '' ); } /* Activity Section **************************************************/ if ( bp_is_active( 'activity' ) ) { // Add the main section. add_settings_section( 'bp_activity', __( 'Activity Settings', 'buddypress' ), 'bp_admin_setting_callback_activity_section', 'buddypress' ); // Activity commenting on blog and forum posts. add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog & Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' ); register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' ); // Activity Heartbeat refresh. add_settings_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddypress' ), 'bp_admin_setting_callback_heartbeat', 'buddypress', 'bp_activity' ); register_setting( 'buddypress', '_bp_enable_heartbeat_refresh', 'intval' ); // Allow activity akismet. if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) { add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' ); register_setting( 'buddypress', '_bp_enable_akismet', 'intval' ); } } } /** * Add a link to BuddyPress About page to the admin bar. * * @since 1.9.0 * * @param WP_Admin_Bar $wp_admin_bar As passed to 'admin_bar_menu'. */ public function admin_bar_about_link( $wp_admin_bar ) { if ( is_user_logged_in() ) { $wp_admin_bar->add_menu( array( 'parent' => 'wp-logo', 'id' => 'bp-about', 'title' => esc_html__( 'About BuddyPress', 'buddypress' ), 'href' => add_query_arg( array( 'page' => 'bp-about' ), bp_get_admin_url( 'index.php' ) ), ) ); } } /** * Add Settings link to plugins area. * * @since 1.6.0 * * @param array $links Links array in which we would prepend our link. * @param string $file Current plugin basename. * @return array Processed links. */ public function modify_plugin_action_links( $links, $file ) { // Return normal links if not BuddyPress. if ( plugin_basename( buddypress()->basename ) != $file ) { return $links; } // Add a few links to the existing links array. return array_merge( $links, array( 'settings' => '' . esc_html__( 'Settings', 'buddypress' ) . '', 'about' => '' . esc_html__( 'About', 'buddypress' ) . '' ) ); } /** * Add some general styling to the admin area. * * @since 1.6.0 */ public function admin_head() { // Settings pages. remove_submenu_page( $this->settings_page, 'bp-page-settings' ); remove_submenu_page( $this->settings_page, 'bp-settings' ); // Network Admin Tools. remove_submenu_page( 'network-tools', 'network-tools' ); // About and Credits pages. remove_submenu_page( 'index.php', 'bp-about' ); remove_submenu_page( 'index.php', 'bp-credits' ); } /** * Add some general styling to the admin area. * * @since 1.6.0 */ public function enqueue_scripts() { wp_enqueue_style( 'bp-admin-common-css' ); } /** About *****************************************************************/ /** * Output the about screen. * * @since 1.7.0 */ public function about_screen() { ?>

  • ' . __( 'Set Up Components', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) ) ); ?>
  • ' . __( 'Assign Components to Pages', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), $this->settings_page ) ) ) ); ?>
  • ' . __( 'Customize Settings', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), $this->settings_page ) ) ) ); ?>

  • ' . __( 'Add User Profile Fields', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-profile-setup' ), 'users.php' ) ) ) ); ?>
  • ' . __( 'Manage User Signups', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-signups' ), 'users.php' ) ) ) ); ?>
  • ' . __( 'Moderate Activity Streams', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-activity' ), 'admin.php' ) ) ) ); ?>
  • ' . __( 'Manage Groups', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-groups' ), 'admin.php' ) ) ) ); ?>
  • ' . __( 'Repair Data', 'buddypress' ) . '', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-tools' ), 'tools.php' ) ) ) ); ?>

BuddyPress Codex has you covered.', 'buddypress' ) ?>

our support forums, where active BuddyPress users and developers are waiting to share tips and more.', 'buddypress' ) ?>

trailingslashit()' ); ?>

Settings.', 'buddypress' ); ?>

bp_group_link()' ); ?>

55don, AaronOfTomorrow, allianse, Antonio Mangiacapra (antonioeatgoat), Benj (benjlipchak), Boone B Gorges (boonebgorges), Bunty (bhargavbhandari90), Brajesh Singh (sbrajesh), Christian Wach (needle), brandonliles, danbp, David Cavins (dcavins), dkelm, dsar, dsided, Henry Wright (henry.wright), Hugo (hnla), Ido Friedlander (idofri), Jay (uscore713), John Blackbourn (johnbillion), John James Jacoby (johnjamesjacoby), Juanho, lakrisgubben, Laurens Offereins (Offereins), lne1030, lenasterg, Maniou, Mathieu Viet (imath), mercime, Michael Beckwith (tw2113), Mike Gillihan (MikeGillihan), Milind More (milindmore22), modemlooper, mrjarbenne, Nicolas Kulka (NicolasKulka), Oelita, Paul Gibbs (DJPaul), paresh.radadiya (pareshradadiya), r-a-y, Renato Alves (espellcaste), Rian Rietveld (rianrietvelde), Samuel Elh (elhardoum), seventhqueen, Slava Abakumov (slaffik), Stephen Edgar (netweb), Vishal Kakadiya (vishalkakadiya)

At.js, bbPress, Caret.js, Cerberus, Ionicons, jquery.cookie, Livestamp.js, MediaWiki, Moment.js, WordPress.

_x( 'Situations', 'Email post type', 'buddypress' ) ); // Inject our 'Situations' column just before the last 'Date' column. return array_slice( $columns, 0, -1, true ) + $situation + array_slice( $columns, -1, null, true ); } /** * Output column data for our custom 'Situations' column. * * @since 2.6.0 * * @param string $column Current column name. * @param int $post_id Current post ID. */ public function emails_display_situation_column_data( $column = '', $post_id = 0 ) { if ( 'situation' !== $column ) { return; } // Grab email situations for the current post. $situations = wp_list_pluck( get_the_terms( $post_id, bp_get_email_tax_type() ), 'description' ); // Output each situation as a list item. echo ''; } /** Helpers ***************************************************************/ /** * Return true/false based on whether a query argument is set. * * @see bp_do_activation_redirect() * * @since 2.2.0 * * @return bool */ public static function is_new_install() { return (bool) isset( $_GET['is_new_install'] ); } /** * Return a user-friendly version-number string, for use in translations. * * @since 2.2.0 * * @return string */ public static function display_version() { // Use static variable to prevent recalculations. static $display = ''; // Only calculate on first run. if ( '' === $display ) { // Get current version. $version = bp_get_version(); // Check for prerelease hyphen. $pre = strpos( $version, '-' ); // Strip prerelease suffix. $display = ( false !== $pre ) ? substr( $version, 0, $pre ) : $version; } // Done! return $display; } /** * Add Emails menu item to custom menus array. * * Several BuddyPress components have top-level menu items in the Dashboard, * which all appear together in the middle of the Dashboard menu. This function * adds the Emails screen to the array of these menu items. * * @since 2.4.0 * * @param array $custom_menus The list of top-level BP menu items. * @return array $custom_menus List of top-level BP menu items, with Emails added. */ public function emails_admin_menu_order( $custom_menus = array() ) { array_push( $custom_menus, 'edit.php?post_type=' . bp_get_email_post_type() ); if ( is_network_admin() && bp_is_network_activated() ) { array_push( $custom_menus, get_admin_url( bp_get_root_blog_id(), 'edit.php?post_type=' . bp_get_email_post_type() ) ); } return $custom_menus; } /** * Register styles commonly used by BuddyPress wp-admin screens. * * @since 2.5.0 */ public function admin_register_styles() { $min = bp_core_get_minified_asset_suffix(); $url = $this->css_url; /** * Filters the BuddyPress Core Admin CSS file path. * * @since 1.6.0 * * @param string $file File path for the admin CSS. */ $common_css = apply_filters( 'bp_core_admin_common_css', "{$url}common{$min}.css" ); /** * Filters the BuddyPress admin stylesheet files to register. * * @since 2.5.0 * * @param array $value Array of admin stylesheet file information to register. */ $styles = apply_filters( 'bp_core_admin_register_styles', array( // Legacy. 'bp-admin-common-css' => array( 'file' => $common_css, 'dependencies' => array(), ), // 2.5 'bp-customizer-controls' => array( 'file' => "{$url}customizer-controls{$min}.css", 'dependencies' => array(), ), ) ); $version = bp_get_version(); foreach ( $styles as $id => $style ) { wp_register_style( $id, $style['file'], $style['dependencies'], $version ); wp_style_add_data( $id, 'rtl', true ); if ( $min ) { wp_style_add_data( $id, 'suffix', $min ); } } } /** * Register JS commonly used by BuddyPress wp-admin screens. * * @since 2.5.0 */ public function admin_register_scripts() { $min = bp_core_get_minified_asset_suffix(); $url = $this->js_url; /** * Filters the BuddyPress admin JS files to register. * * @since 2.5.0 * * @param array $value Array of admin JS file information to register. */ $scripts = apply_filters( 'bp_core_admin_register_scripts', array( // 2.5 'bp-customizer-controls' => array( 'file' => "{$url}customizer-controls{$min}.js", 'dependencies' => array( 'jquery' ), 'footer' => true, ), ) ); $version = bp_get_version(); foreach ( $scripts as $id => $script ) { wp_register_script( $id, $script['file'], $script['dependencies'], $version, $script['footer'] ); } } } endif; // End class_exists check.