提高性能

提高性能

Codex Home → Getting Started → Improving Performance
Improving Performance

Due to the highly dynamic nature of social networks, without caching BuddyPress will add extra load on your server.
Thankfully, there are lots of options for increasing the performance of your server that take very little time to set up.
Reduce Database Hits
With many different content objects on each page, BuddyPress needs to pull a wide range of content from the database. The number of hits to the database is always a consideration and has been kept to a minimum where possible.
An excellent way to reduce the number of database hits per page even further is to turn on the persistent cache in the form of object caching.
To do this you will need to add: define( ‘WP_CACHE’, true ); into your wp-config.php file above the “stop editing” line.
You will then need to choose the type of persistent caching you would like to use. The most notable options are file based, memcached. If you’re unsure go with the file based caching.

File based
Memcached

You will need to make sure you have object-cache.php in your wp-content directory and a writable wp-content/cache/ directory for file based caching.
Reduce Memory Usage
An excellent way to significantly reduce memory usage is to install op-code caching on your server. There are two well known:

eAccellerator
XCache

Tweak Your Server
Tweaking your server settings can have a huge impact on performance. Even the smallest of adjustments can yield impressive results. Here are some articles that you may find helpful:

WP Codex: WordPress Optimization
WordPress optimization guide

Please feel free to edit this page and add any tactics you have found that increase your hardware performance.

核心组件

核心组件

Codex Home → Developer Resources → Function Examples → Core Component
Core Component

Core component functions can be used by any official component, add-on component, WordPress or BuddyPress plugin. The core is always required, so you can be sure that the functions are always present.

bp_core_add_nav_item()

bp_core_add_nav_item()

Codex Home → Developer Resources → Deprecated → bp_core_add_nav_item()
bp_core_add_nav_item()

Deprecated
This function is deprecated in BuddyPress 1.1. Refer to bp_core_new_nav_item() going forward. Use of this function in BuddyPress versions greater than 1.1 is not recommended, but it will still work by internally calling bp_core_new_nav_item() to compensate.
Description
Adds a navigation item to the main navigation array used in BuddyPress themes.
Parameters
$nameString | Required | The display name for the navigation item.
$slugString | Required | The URL slug for the navigation item.
$css_idString | Optional | Default: $slug value | The ID to give the navigation item in HTML for CSS styling.
$add_to_usernav Boolean | Optional | Default: TRUE | Should this navigation item be added to all user’s profiles, not just the user who is logged in?
Notes
This function is deprecated in BuddyPress 1.1.
Last Updated by John James Jacoby on September 9, 2009 – 4:19pm EST

bp_core_add_nav_default()

bp_core_add_nav_default()

Codex Home → Developer Resources → Deprecated → bp_core_add_nav_default()
bp_core_add_nav_default()

Deprecated
This function is deprecated in BuddyPress 1.1. Please refer to bp_core_new_nav_item() going forward.
Description
Set a default action for a nav item, when a sub nav item has not yet been selected.
Usage

Parameters
$parent_idString | Required | The id of the parent navigation item (usually the slug, or the css_id if set)
$function String | Required | The name of the screen function that will display the sub-nav item screen.
$slugString | Optional | Default: false | By setting a slug you can override the $bp[‘current_action’] variable. Can be used to change which navigation item is highlighted.
$user_has_access Bool | Optional | Default: true | Does the logged in user have access to this sub-nav item? You can use bp_is_home() to limit a sub-nav item to only the logged in user.
$admin_only Bool | Optional | Default: false | Can this item only be access by site administrators?
Return Values
N/A
Examples

Notes

bp_core_add_subnav_item()

bp_core_add_subnav_item()

Codex Home → Developer Resources → Deprecated → bp_core_add_subnav_item()
bp_core_add_subnav_item()

Deprecated
This function is deprecated in BuddyPress 1.1. Please refer to bp_core_new_subnav_item() going forward.
Description
Adds a navigation item to the sub navigation array used in BuddyPress themes.
Usage

Parameters
$parent_idString | Required | The id of the parent navigation item (usually the slug, or the css_id if set)
$slug String | Required | The URL slug for the sub-nav item.
$name String | Required | The display name for the sub-nav item.
$link String | Required | The URL of the sub-nav item, without the slug. This is basically the URL of the main nav item.
$function String | Required | The name of the screen function that will display the sub-nav item screen.
$css_id String | Optional | Default: $slug value | The ID to give the navigation item in HTML for CSS styling.
$user_has_access Bool | Optional | Default: true | Does the logged in user have access to this sub-nav item? You can use bp_is_home() to limit a sub-nav item to only the logged in user.
$admin_only Bool | Optional | Default: false | Can this sub-nav item only be access by site administrators?.
Return Values
N/A
Examples

Notes

核心(Core)

核心(Core)

Codex Home → Developer Resources → Action Reference → Core
Core

bp-core.php

bp_core_render_notice
bp_core_clear_cache

bp-core/bp-core-activation.php

activate_header
bp_activation_extras

bp-core/bp-core-adminbar.php

bp_adminbar_logo
bp_adminbar_menus

bp-core/bp-core-ajaxhandler.php

wp_ajax_[post action]

bp-core/bp-core-avatars.php

bp_core_render_avatar_cropper
bp_core_avatar_save (removed since BP 1.2)
bp_core_render_avatar_upload_form
bp_core_delete_avatar

bp-core/bp-core-settings.php

bp_notification_settings

bp-core/bp-core-signup.php

signup_header
signup_blogform
signup_extra_fields
signup_hidden_fields
signup_finished
preprocess_signup_form

bp-core/bp-core-templatetags.php

bp_styles
bp_custom_profile_boxes
bp_custom_profile_sidebar_boxes

bp-core/directories/bp-core-directory-members.php

bp_core_directory_members_content
bp_core_directory_members_sidebar

博客(Blogs)

博客(Blogs)

Codex Home → Developer Resources → Action Reference → Blogs
Blogs

bp-blogs.php

bp_blogs_screen_my_blogs
bp_blogs_screen_recent_posts
bp_blogs_screen_recent_comments
bp_blogs_screen_create_a_blog
bp_blogs_format_activity
bp_blogs_new_blog
bp_blogs_new_blog_post
bp_blogs_new_blog_comment
bp_blogs_remove_blog
bp_blogs_remove_blog_for_user
bp_blogs_remove_post
bp_blogs_remove_comment
bp_blogs_remove_data_for_blog
bp_blogs_remove_data

bp-blogs/directories/bp-blogs-directory-blogs.php

bp_blogs_directory_blogs_content
bp_blogs_directory_blogs_sidebar

好友(Friends)

好友(Friends)

Codex Home → Developer Resources → Action Reference → Friends
Friends

bp-friends.php

friends_screen_my_friends
friends_screen_requests
friends_screen_friend_finder
friends_screen_notification_settings
friends_format_activity
friends_format_notifications
friends_friendship_requested
friends_friendship_deleted
friends_friendship_accepted
friends_friendship_rejected
friends_remove_data

bp-friends/bp-friends-templatetags.php

friends_header_tabs