Commit da8169c2 authored by agata's avatar agata

[auto] plugin: buddypress 5.1.2

parent bf7d93a0
......@@ -77,12 +77,15 @@ function bp_activity_action_post_update() {
* Filters activity object for BuddyPress core and plugin authors before posting activity update.
*
* @since 1.2.0
* @since 5.0.0 Fixed filter signature to match other instances of filter,
* with $activity_id as the first param.
*
* @param string $object Activity item being associated to.
* @param string $item_id Component ID being posted to.
* @param string $content Activity content being posted.
* @param int $activity_id ID of the activity item.
* @param string $object Activity item being associated to.
* @param string $item_id Component ID being posted to.
* @param string $content Activity content being posted.
*/
$activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
$activity_id = apply_filters( 'bp_activity_custom_update', 0, $object, $item_id, $content );
}
// Provide user feedback.
......
......@@ -310,7 +310,7 @@ function bp_activity_admin_load() {
) );
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(), bp_get_version() );
wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
wp_style_add_data( 'bp_activity_admin_css', 'rtl', 'replace' );
if ( $min ) {
wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
}
......@@ -840,13 +840,19 @@ function bp_activity_admin_get_activity_actions() {
$action = array_values( (array) $action );
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
/**
* Don't take in account:
* - a mis-named Friends activity type from before BP 1.6,
* - The Group's component 'activity_update' one as the Activity component is using it.
*/
if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
continue;
}
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
}
}
// This was a mis-named activity type from before BP 1.6.
unset( $actions['friends_register_activity_action'] );
// Sort array by the human-readable value.
natsort( $actions );
......@@ -870,13 +876,20 @@ function bp_activity_admin_edit_metabox_type( $item ) {
foreach ( bp_activity_get_actions() as $action ) {
$action = array_values( (array) $action );
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
/**
* Don't take in account:
* - a mis-named Friends activity type from before BP 1.6,
* - The Group's component 'activity_update' one as the Activity component is using it.
*/
if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
continue;
}
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
}
}
// This was a mis-named activity type from before BP 1.6.
unset( $actions['friends_register_activity_action'] );
// Sort array by the human-readable value.
natsort( $actions );
......
......@@ -36,7 +36,7 @@ function bp_activity_mentions_script() {
wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
wp_style_add_data( 'bp-mentions-css', 'rtl', true );
wp_style_add_data( 'bp-mentions-css', 'rtl', 'replace' );
if ( $min ) {
wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
}
......
......@@ -818,14 +818,16 @@ add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_
* Registers Activity personal data exporter.
*
* @since 4.0.0
* @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
*
* @param array $exporters An array of personal data exporters.
* @return array An array of personal data exporters.
*/
function bp_activity_register_personal_data_exporter( $exporters ) {
$exporters['buddypress-activity'] = array(
'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
'callback' => 'bp_activity_personal_data_exporter',
'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
'callback' => 'bp_activity_personal_data_exporter',
'exporter_bp_friendly_name' => _x( 'Activity Data', 'BuddyPress Activity data exporter friendly name', 'buddypress' ),
);
return $exporters;
......
......@@ -3848,6 +3848,11 @@ function bp_activity_show_filters( $context = '' ) {
$action['key'] = 'friendship_accepted,friendship_created';
}
// The 'activity_update' filter is already used by the Activity component.
if ( 'bp_groups_format_activity_action_group_activity_update' === $action['format_callback'] ) {
continue;
}
$filters[ $action['key'] ] = $action['label'];
}
......
......@@ -360,8 +360,10 @@ class BP_Activity_Activity {
public static function get( $args = array() ) {
global $wpdb;
$function_args = func_get_args();
// Backward compatibility with old method of passing arguments.
if ( !is_array( $args ) || func_num_args() > 1 ) {
if ( !is_array( $args ) || count( $function_args ) > 1 ) {
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
......@@ -378,7 +380,7 @@ class BP_Activity_Activity {
10 => 'spam'
);
$args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
$args = bp_core_parse_args_array( $old_args_keys, $function_args );
}
$bp = buddypress();
......@@ -1467,6 +1469,8 @@ class BP_Activity_Activity {
public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
global $wpdb;
$function_args = func_get_args();
if ( empty( $top_level_parent_id ) ) {
$top_level_parent_id = $activity_id;
}
......@@ -1514,7 +1518,7 @@ class BP_Activity_Activity {
* @param BP_Activity_Activity $value Magic method referring to currently called method.
* @param array $func_args Array of the method's argument list.
*/
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, func_get_args() ) ) {
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $function_args ) ) {
/**
* Filters the MySQL prepared statement for the legacy activity query.
......@@ -1539,6 +1543,7 @@ class BP_Activity_Activity {
$descendant_ids = $wpdb->get_col( $sql );
$descendants = self::get_activity_data( $descendant_ids );
$descendants = self::append_user_fullnames( $descendants );
$descendants = self::generate_action_strings( $descendants );
}
$ref = array();
......
......@@ -124,9 +124,30 @@ class BP_Activity_Component extends BP_Component {
require $this->path . 'bp-activity/screens/just-me.php';
}
// Screens - User secondary nav.
if ( bp_is_user() && in_array( bp_current_action(), array( 'friends', 'groups', 'favorites', 'mentions' ), true ) ) {
require $this->path . 'bp-activity/screens/' . bp_current_action() . '.php';
/**
* Screens - User secondary nav.
*
* For these specific actions, slugs can be customized using `BP_{COMPONENT}_SLUGS`.
* As a result, we need to map filenames with slugs.
*/
$filenames = array(
'favorites' => 'favorites',
'mentions' => 'mentions',
);
if ( bp_is_active( 'friends' ) ) {
$filenames[bp_get_friends_slug()] = 'friends';
}
if ( bp_is_active( 'groups' ) ) {
$filenames[bp_get_groups_slug()] = 'groups';
}
// The slug is the current action requested.
$slug = bp_current_action();
if ( bp_is_user() && isset( $filenames[ $slug ] ) ) {
require $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
}
// Screens - Single permalink.
......@@ -435,4 +456,16 @@ class BP_Activity_Component extends BP_Component {
parent::setup_cache_groups();
}
/**
* Init the BP REST API.
*
* @since 5.0.0
*
* @param array $controllers Optional. See BP_Component::rest_api_init() for
* description.
*/
public function rest_api_init( $controllers = array() ) {
parent::rest_api_init( array( 'BP_REST_Activity_Endpoint' ) );
}
}
......@@ -338,11 +338,7 @@ class BP_Activity_List_Table extends WP_List_Table {
*
* @return array Key/value pairs for the bulk actions dropdown.
*/
function get_bulk_actions() {
$actions = array();
$actions['bulk_spam'] = __( 'Mark as Spam', 'buddypress' );
$actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
$actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
public function get_bulk_actions() {
/**
* Filters the default bulk actions so plugins can add custom actions.
......@@ -351,7 +347,11 @@ class BP_Activity_List_Table extends WP_List_Table {
*
* @param array $actions Default available actions for bulk operations.
*/
return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
return apply_filters( 'bp_activity_list_table_get_bulk_actions', array(
'bulk_spam' => __( 'Mark as Spam', 'buddypress' ),
'bulk_ham' => __( 'Not Spam', 'buddypress' ),
'bulk_delete' => __( 'Delete Permanently', 'buddypress' ),
) );
}
/**
......@@ -364,6 +364,7 @@ class BP_Activity_List_Table extends WP_List_Table {
* @return array The columns to appear in the Activity list table.
*/
function get_columns() {
/**
* Filters the titles for the columns for the activity list table.
*
......@@ -373,7 +374,7 @@ class BP_Activity_List_Table extends WP_List_Table {
*/
return apply_filters( 'bp_activity_list_table_get_columns', array(
'cb' => '<input name type="checkbox" />',
'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
'author' => _x( 'Author', 'Admin SWA column header', 'buddypress' ),
'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
......@@ -383,20 +384,20 @@ class BP_Activity_List_Table extends WP_List_Table {
/**
* Get the column names for sortable columns.
*
* Currently, returns an empty array (no columns are sortable).
*
* @since 1.6.0
* @todo For this to work, BP_Activity_Activity::get() needs updating
* to support ordering by specific fields.
*
* @return array The columns that can be sorted on the Activity screen.
*/
function get_sortable_columns() {
return array();
public function get_sortable_columns() {
/*return array(
'author' => array( 'activity_author', false ), // Intentionally not using "=>"
);*/
/**
* Filters the column names for the sortable columns.
*
* @since 5.0.0
*
* @param array $value Array of column names.
*/
return apply_filters( 'bp_activity_list_table_get_sortable_columns', array() );
}
/**
......@@ -434,6 +435,11 @@ class BP_Activity_List_Table extends WP_List_Table {
$component = 'xprofile';
}
// The 'activity_update' filter is already used by the Activity component.
if ( isset( $actions->activity_update ) && 'bp_groups_format_activity_action_group_activity_update' === $actions->activity_update['format_callback'] ) {
unset( $actions->activity_update );
}
if ( bp_is_active( $component ) ) {
if ( $component === 'xprofile' ) {
$component_name = buddypress()->profile->name;
......@@ -454,7 +460,7 @@ class BP_Activity_List_Table extends WP_List_Table {
<?php
// Skip the incorrectly named pre-1.6 action.
if ( 'friends_register_activity_action' !== $action_key ) : ?>
if ( 'friends_register_activity_action' !== $action_key ) : ?>
<option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
......
......@@ -139,8 +139,10 @@ class BP_Activity_Template {
public function __construct( $args ) {
$bp = buddypress();
$function_args = func_get_args();
// Backward compatibility with old method of passing arguments.
if ( !is_array( $args ) || func_num_args() > 1 ) {
if ( !is_array( $args ) || count( $function_args ) > 1 ) {
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
......@@ -159,7 +161,7 @@ class BP_Activity_Template {
12 => 'page_arg'
);
$args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
$args = bp_core_parse_args_array( $old_args_keys, $function_args );
}
$defaults = array(
......
......@@ -61,7 +61,8 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
echo $args['before_widget'];
echo $args['before_title'] . $title . $args['after_title'];
if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) {
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) {
$instance['max_posts'] = 10;
}
......@@ -128,10 +129,13 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
* @return array $instance The parsed options to be saved.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance = $old_instance;
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
$instance['link_title'] = (bool) $new_instance['link_title'];
$instance['max_posts'] = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] );
$instance['link_title'] = ! empty( $new_instance['link_title'] );
return $instance;
}
......@@ -150,15 +154,17 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
'link_title' => false,
) );
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
$title = strip_tags( $instance['title'] );
$max_posts = strip_tags( $instance['max_posts'] );
$max_posts = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] );
$link_title = (bool) $instance['link_title'];
?>
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" /></label></p>
<p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p>
<p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
<p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
<?php
}
}
......@@ -1135,3 +1135,46 @@ function bp_core_admin_body_classes( $classes ) {
return $classes . ' buddypress';
}
add_filter( 'admin_body_class', 'bp_core_admin_body_classes' );
/**
* Adds a BuddyPress category to house BuddyPress blocks.
*
* @since 5.0.0
*
* @param array $categories Array of block categories.
* @param object $post Post being loaded.
*/
function bp_block_category( $categories = array(), $post = null ) {
if ( ! ( $post instanceof WP_Post ) ) {
return $categories;
}
/**
* Filter here to add/remove the supported post types for the BuddyPress blocks category.
*
* @since 5.0.0
*
* @param array $value The list of supported post types. Defaults to WordPress built-in ones.
*/
$post_types = apply_filters( 'bp_block_category_post_types', array( 'post', 'page' ) );
if ( ! $post_types ) {
return $categories;
}
// Get the post type of the current item.
$post_type = get_post_type( $post );
if ( ! in_array( $post_type, $post_types, true ) ) {
return $categories;
}
return array_merge( $categories, array(
array(
'slug' => 'buddypress',
'title' => __( 'BuddyPress', 'buddypress' ),
'icon' => 'buddicons-buddypress-logo',
),
) );
}
add_filter( 'block_categories', 'bp_block_category', 1, 2 );
......@@ -382,6 +382,11 @@ function bp_core_install_extended_profiles() {
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
// Make sure the custom visibility is disabled for the default field.
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
}
}
dbDelta( $insert_sql );
......@@ -535,3 +540,49 @@ function bp_core_install_emails() {
*/
do_action( 'bp_core_install_emails' );
}
/**
* Install database tables for the Invitations API
*
* @since 5.0.0
*
* @uses bp_core_set_charset()
* @uses bp_core_get_table_prefix()
* @uses dbDelta()
*/
function bp_core_install_invitations() {
$sql = array();
$charset_collate = $GLOBALS['wpdb']->get_charset_collate();
$bp_prefix = bp_core_get_table_prefix();
$sql[] = "CREATE TABLE {$bp_prefix}bp_invitations (
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id bigint(20) NOT NULL,
inviter_id bigint(20) NOT NULL,
invitee_email varchar(100) DEFAULT NULL,
class varchar(120) NOT NULL,
item_id bigint(20) NOT NULL,
secondary_item_id bigint(20) DEFAULT NULL,
type varchar(12) NOT NULL DEFAULT 'invite',
content longtext DEFAULT '',
date_modified datetime NOT NULL,
invite_sent tinyint(1) NOT NULL DEFAULT '0',
accepted tinyint(1) NOT NULL DEFAULT '0',
KEY user_id (user_id),
KEY inviter_id (inviter_id),
KEY invitee_email (invitee_email),
KEY class (class),
KEY item_id (item_id),
KEY secondary_item_id (secondary_item_id),
KEY type (type),
KEY invite_sent (invite_sent),
KEY accepted (accepted)
) {$charset_collate};";
dbDelta( $sql );
/**
* Fires after BuddyPress adds the invitations table.
*
* @since 5.0.0
*/
do_action( 'bp_core_install_invitations' );
}
......@@ -488,3 +488,82 @@ function bp_core_admin_notice_repopulate_blogs_resume() {
echo '<div class="error"><p>' . __( 'It looks like you have more sites to record. Resume recording by checking the "Repopulate site tracking records" option.', 'buddypress' ) . '</p></div>';
}
add_action( 'network_admin_notices', 'bp_core_admin_notice_repopulate_blogs_resume' );
/**
* Add BuddyPress debug info to the WordPress Site Health info screen.
*
* @since 5.0.0