Twenty Seventeen 二〇一七主题

Twenty Seventeen 二〇一七主题

Codex Home → BuddyPress Theme Development → BP Theme Compatibility and the WordPress Default Themes → Twenty Seventeen Theme
Twenty Seventeen Theme

To change Twenty Seventeen’s default two-column layout to a full width layout as seen in the image above, add the following code to the `functions.php` file of your Twenty Seven child theme:
?12345678910// Remove the page-two-column CSS class from the body class in BuddyPress pagesfunction bp_remove_two_column_body_class($wp_classes) {    if( function_exists ( ‘bp_loaded’ ) && !bp_is_blog_page() ) :        foreach($wp_classes as $key => $value) {             if ($value == ‘page-two-column’) unset($wp_classes[$key]);        }    endif;    return $wp_classes;}add_filter(‘body_class’, ‘bp_remove_two_column_body_class’, 20, 2);

BuddyPress 案例研究

BuddyPress 案例研究

Codex Home → Getting Started → BuddyPress Case Studies
BuddyPress Case Studies

 
Twcfit – Fitness

Article: Total Wellness Challenge: Fitness with BuddyPress
Author: Tara Claeys
BuddyPress Site: Total Wellness Challenge

Nefisyemektarifleri – Turkish Recipes

Article: Largest Turkish Recipe Site Spiced Up with BuddyPress
Author: Mustafa Uysal
BuddyPress Site: NefisYemekTarifleri.com

Naturkontakt – Environmental NGO

Article: Naturkontakt, Organising Sweden’s Largest Environmental NGO
Author: Alexander Berthelsen
BuddyPress Site: Naturkontakt (private)

StudentsNepal – Education Portal

Article: Building Bridges between Students and Educators in Nepal
Author: Arjun Bhattarai
BuddyPress Site: StudentsNepal.com

BuddyPress Hooks 挂钩 – 操作和过滤器

BuddyPress Hooks 挂钩 – 操作和过滤器

Codex Home → Developer Resources → BuddyPress Hooks – Actions & Filters
BuddyPress Hooks – Actions & Filters

Attached are links to PDFs listing the BuddyPress Actions and Filters as of BuddyPress 2.8.2
BuddyPress Action Hook
BuddyPress Filters (add_filter)
BuddyPress Filters (apply_filters)

“Nouveau” 群组邀请用户界面

“Nouveau” 群组邀请用户界面

Codex Home → Getting Started → User Submitted Guides → A “Nouveau” Group Invites User Interface
A “Nouveau” Group Invites User Interface

“Nouveau” is the name of the new Template Pack bundled within the 3.0.0 release of BuddyPress. You can activate it from the BuddyPress Options Administration screen. “Nouveau” comes with some new Backbone.JS based User Interfaces and one of them, the Group Invites UI, is experimenting an alternative way to deal with single group invites. In short: it’s always possible to invite community members when “Nouveau” is the selected Template Pack!
Selecting Members to invite.

The Group Invites UI uses a dynamic tabbed interface to help you choose the members you want to invite into your existing or your new group. If the Friends component is active, you’ll find 2 tabs “My Friends” and “All Members” to perform this selection. Otherwise you will always find at least the “All Members” tab.

To add a new member to your group invites, you need to click on the “+” icon. Once done, a new tab named “Send Invites” is dynamically added under the others. It contains a counter to inform you about the number of members you added to your invites list.

If you added a member by mistake, you can remove him from the list clicking on the “x” icon.

You can switch between tabs at anytime to select the members or friends you need to invite into your group, you won’t lose the members you already selected.

If your community is large, you can use the search field to filter the displayed members.

When your selection is ready, click on the “Send Invites” tab to send your invites to the selected members. If you realize at this point you don’t want to invite “Laurent”, just click on his avatar to remove him from your invites list. If you want to explain why the invited members should join your group, you can add a message to your invite. Oh and don’t forget to click on the “Send” button to actually send the invites !!
Checking for pending invites.

When a group has pending invites you can check it to see if one of your friends is already invited. Oh by the way, if you don’t find a specific member into the “My Friends” or “All Members” tab, there’s a good chance you’ll find him into these pending invites or into the existing Group Members
Putting all screens together

Video Playerhttps://cldup.com/ubTOhLK6EX.mp400:0000:0000:00Use Up/Down Arrow keys to increase or decrease volume.
 
Restricting the user listed into the “All Members” tab
Any member can choose to disappear from the “All Members” tab at anytime from their “Group Invites” settings profile page.

If you are the site owner, you can also completely disable the “All Members” tab by using the following code into your bp-custom.php file :
add_filter( ‘bp_nouveau_groups_disallow_all_members_invites’, ‘__return_true’ );

版本编号

版本编号

Codex Home → Getting Started → Version numbering
Version numbering

Beginning with version 4.0.0 (#7710), BuddyPress releases are numbered according to a slightly modified version of Semantic Versioning (SemVer).

As in SemVer, BuddyPress version numbers follow the MAJOR.MINOR.PATCH format, where:

MAJOR releases are those that include major new features, and may incorporate backward-incompatible API changes. We make an effort to document such changes on our dev blog https://bpdevel.wordpress.comMINOR releases include backward-compatible bug fixes and minor functionalityPATCH releases include backward-compatible bug fixes or security fixes only

Prior to 4.0.0, BuddyPress releases followed WordPress’s MAJOR.MINOR format, where MAJOR is a one-place decimal (of the format x.y, such as 2.8) that represents new features, and MINOR is .z (such as 2.8.1) that includes bug fixes only.

活动流和 date_query

活动流和 date_query

Codex Home → Developer Resources → Activity Stream and date_query
Activity Stream and date_query

If you have a lot of activity entries on your site, load times can suffer dramatically when viewing activity streams.

You can use the date_query argument to speed things up by limiting the entries to only those from the past day or week or month, etc.

But you cannot add it as a string in the usual fashion. For example, adding a per_page argument:

Instead, you need to use an array, which is easy enough until you try to include the value of bp_ajax_querystring( ‘activity’ ) as an argument and the ‘Load More’ button stops working properly.

Here’s the solution. You can paste it in your overload of the activity-loop template or you could use the bp_before_has_activities_parse_args filter.

$date_limit,
),
);

$activity_args[‘per_page’] = 5;

?>

// etc.

Note the use of wp_parse_str to add the query string needed for the ‘Load More’ button.

And you can use conditionals to change the date_query argument depending on which activity stream you’re viewing:

?12345678910111213if ( bp_is_activity_directory() ) {     $date_limit = date(“Y-m-d H:i:s”, strtotime(“-1 week”));      } elseif( bp_is_group() ) {     $date_limit = date(“Y-m-d H:i:s”, strtotime(“-1 month”));      } else { // profile stream     $date_limit = date(“Y-m-d H:i:s”, strtotime(“-1 year”));      }

PHP 版本支持

PHP 版本支持

Codex Home → Getting Started → PHP version support
PHP version support

BP supports the latest versions of PHP
BuddyPress supports all stable versions of PHP officially supported by the PHP project.
For the best security and performance, site admins are strongly encouraged to run the latest stable PHP.
BuddyPress 6.0.0 will require at least PHP 5.6
Legacy PHP support
In addition to the official supported releases, BuddyPress maintains support for a number of legacy PHP versions.
Justification for legacy support
Like WordPress, BuddyPress is meant to be easy to install and use on a large number of hosting environments. The statistics collected on wordpress.org indicate that a large number of WordPress installations continue to be hosted on out-of-date versions of PHP. (The stats breakdown for BuddyPress installations shows a similar spread.) For certain legacy versions, dropping support in a backward-incompatible way would break tens of thousands of websites. We choose not to be so strict that a majority of BP installations cannot run the software.
How we decide
At the beginning of each major development cycle (roughly three times per year), the BuddyPress team decides on the minimum PHP version that will be supported by the following major release. Thus, at the beginning of the 2.7 cycle, decisions are made about support in 2.8. This gap allows enough time for deliberation as well as for developer outreach.
The following considerations are weighed in the decision about whether to drop support for a legacy PHP version:

Usage – When a legacy version of PHP drops below a certain percentage of total installations – as gauged by the publicly available stats or by more BuddyPress-specific numbers reported by the wordpress.org team – it becomes a candidate for removal. The rule-of-thumb threshold for consideration is 5% of modern (say, 2.0+) BuddyPress installations.
Benefits – Some versions of PHP have introduced more significant features than others. If dropping support for a given version of PHP would allow for vastly improved development practices, removing support for that version will be a higher priority.

These are rough guidelines. In some cases, it may be worth obsolescing thousands of sites because the downsides of supporting the legacy version are so great. In others, the practical benefits of increasing our minimum version may be so minimal that it’s not worth breaking any sites at all.
Decisions will be made by the core team during a regularly scheduled dev chat.
What does “support” mean?
When we say that BuddyPress “supports” a version of PHP, we mean the following:

BuddyPress should run error-free (ie, without fatal errors or PHP notices) on the PHP version.
If a new version of BP includes a feature that requires a more recent version of PHP, the feature should be gracefully disabled on earlier PHP versions.
The PHP version will be included in our automated testing build matrix.

By extension: When we “drop support” for a legacy version of PHP, it means we stop including it in our builds, stop answering support questions related to that specific PHP version, and stop putting function_exists() checks (and the like) targeting that version when building new BP features.

群组管理员 – 添加自定义列

群组管理员 – 添加自定义列

Codex Home → BuddyPress Plugin Development → Groups Admin – Add Custom Column
Groups Admin – Add Custom Column

It can be very handy to see additional information about each group when viewing the Groups screen in wp-admin.

The necessary hooks are found in this file: buddypress/bp-groups/classes/class-bp-groups-list-table.php

This example will add a column to show the number of pending member requests to join each private group. If a group is public there can be no pending requests, so we’ll show a simple dash in that row.

// add the column
function groups_admin_add_custom_column( $columns ) {

$columns[“pending_group_members”] = “Join Requests”;

return $columns;

}
add_filter( “bp_groups_list_table_get_columns”, “groups_admin_add_custom_column” );

// add the column data for each row
function groups_admin_custom_column_content( $retval = “”, $column_name, $item ) {

if ( “pending_group_members” !== $column_name ) {
return $retval;
}

if ( “private” == $item[“status”] ) {

$user_ids = BP_Groups_Member::get_all_membership_request_user_ids( $item[“id”] );

return count( $user_ids );
}

return “-“;

}
add_filter( “bp_groups_admin_get_group_custom_column”, “groups_admin_custom_column_content”, 10, 3 );

This code can be placed in bp-custom.php .

BuddyPress 2.8 需要 PHP 5.3+

BuddyPress 2.8 需要 PHP 5.3+

Codex Home → Getting Started → BuddyPress 2.8 requires PHP 5.3+
BuddyPress 2.8 requires PHP 5.3+

Starting with version 2.8, the minimum version of PHP required to run BuddyPress is 5.3.
Why the change?
PHP is the server-side programming language that powers WordPress and BuddyPress. Old versions of PHP are potentially unstable and insecure, and are missing some features that can be used to make BuddyPress faster and more powerful. The change is especially marked with the jump from PHP 5.2 to PHP 5.3, and the BuddyPress team has decided that now is the time to make the move.
Site administrators are strongly encouraged to run the latest stable version of all server software, including PHP.
See our PHP version compatibility guidelines for more details on how BP’s PHP version support is determined.
Am I affected?
Starting with version 2.7, BuddyPress creates a notice in the Dashboard if it detects that your installation doesn’t meet the minimum requirements for version 2.8+. If you reached this page via this kind of notice, then your server needs to be upgraded.
You can also check your PHP version using your hosting tools. For example, here is a tutorial from InMotion Hosting on using cPanel to view your PHP version.
How do I upgrade PHP?
Most popular webhosts have an interface for changing PHP version. Check your host’s documentation or support for more details. A few examples:

SiteGround
GoDaddy
Bluehost
DreamHost
HostGator

When in doubt, contact your host’s support.
What will happen if I don’t upgrade PHP?
BuddyPress 2.8 and later are completely incompatible with PHP 5.2: activating the plugin on an unsupported version of PHP will result in fatal errors.
BuddyPress 2.7 includes PHP version detection. If BP 2.7 detects that you are running PHP 5.2, it attempts to prevent you from upgrading to BP 2.8+ via all the normal WordPress upgrade paths (like Dashboard > Plugins). In this situation, your site will run BP 2.7.x until PHP has been upgraded.

添加电子邮件令牌

添加电子邮件令牌

Codex Home → Emails → Add Email Token
Add Email Token

Adding a token to an existing email can be done by using the bp_email_set_tokens filter.

For example, an email is sent when a member requests membership in a private group. Let’s add the requesting member’s email address to the body of that email.

function maybe_add_tokens_bp_email( $formatted_tokens, $tokens, $obj ) {

if ( isset( $formatted_tokens[‘requesting-user.name’] ) && isset( $formatted_tokens[‘requesting-user.id’] ) ) {

$user_info = get_userdata( $formatted_tokens[‘requesting-user.id’] );

$formatted_tokens[‘memberemail’] = $user_info->user_email;

}

return $formatted_tokens;

}
add_filter( ‘bp_email_set_tokens’, ‘maybe_add_tokens_bp_email’, 11, 3 );

This page lists the default tokens.

We can use that information to set the conditional so that the token is only added when a group membership request email is generated:

if ( isset( $formatted_tokens[‘requesting-user.name’] ) && isset( $formatted_tokens[‘requesting-user.id’] ) ) {
// etc

Now that we have added the memberemail token, we need to use the token in the body of the email.

Go to wp-admin > Emails and find the Membership request for group email. Roll over the name and click Edit. 

Then add the new token to the body of the email.

For example: Member Email: {{memberemail}}

Click Update and the token will be used every time that type of email is generated.