Skip to:
Content

BuddyPress.org

Ticket #8355: 8355.patch

File 8355.patch, 3.2 KB (added by imath, 5 years ago)
  • src/bp-core/bp-core-caps.php

    diff --git src/bp-core/bp-core-caps.php src/bp-core/bp-core-caps.php
    index 7d1d00482..24273eb2a 100644
    function bp_user_can( $user_id, $capability, $args = array() ) { 
    375375 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
    376376 */
    377377function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
     378        $admin_caps = bp_get_caps_for_role( 'administrator' );
    378379
    379380        // Bail if not checking the 'bp_moderate' cap.
    380         if ( 'bp_moderate' !== $cap ) {
     381        if ( ! in_array( $cap, $admin_caps, true ) ) {
    381382                return $caps;
    382383        }
    383384
  • src/bp-core/bp-core-filters.php

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index ec84a6990..65d97834c 100644
    add_filter( 'bp_email_set_content_html', 'wp_filter_post_kses', 6 ); 
    5858add_filter( 'bp_email_set_content_html', 'stripslashes', 8 );
    5959add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 );
    6060add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 );
     61add_filter( 'bp_get_caps_for_role', 'bp_email_set_caps_for_role', 10, 2 );
    6162
    6263/**
    6364 * Template Compatibility.
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index c1481135e..62fbd3d40 100644
    function bp_email_get_unsubscribe_type_schema() { 
    38613861        return (array) apply_filters( 'bp_email_get_unsubscribe_type_schema', $emails );
    38623862}
    38633863
     3864/**
     3865 * Sets the role's BP Email capabilities.
     3866 *
     3867 * @since 7.0.0
     3868 *
     3869 * @param array  $caps Array of capabilities to return.
     3870 * @param string $role The role currently being requested.
     3871 * @return array The role BP Email caps.
     3872 */
     3873function bp_email_set_caps_for_role( $caps = array(), $role = '' ) {
     3874        $bp_email_post_type = get_post_type_object( bp_get_email_post_type() );
     3875
     3876        if ( $bp_email_post_type ) {
     3877                $bp_email_post_type_caps = get_object_vars( $bp_email_post_type->cap );
     3878
     3879                if ( 'administrator' === $role ) {
     3880                        $caps = array_merge(
     3881                                $caps,
     3882                                array_values( $bp_email_post_type_caps )
     3883                        );
     3884                }
     3885        }
     3886
     3887        return $caps;
     3888}
     3889
    38643890/**
    38653891 * Get BuddyPress content allowed tags.
    38663892 *
  • src/bp-core/classes/class-bp-core.php

    diff --git src/bp-core/classes/class-bp-core.php src/bp-core/classes/class-bp-core.php
    index 7a322133a..0ca0e16e1 100644
    class BP_Core extends BP_Component { 
    306306                                bp_get_email_post_type(),
    307307                                apply_filters( 'bp_register_email_post_type', array(
    308308                                        'description'       => _x( 'BuddyPress emails', 'email post type description', 'buddypress' ),
    309                                         'capabilities'      => array(
    310                                                 'edit_posts'          => 'bp_moderate',
    311                                                 'edit_others_posts'   => 'bp_moderate',
    312                                                 'publish_posts'       => 'bp_moderate',
    313                                                 'read_private_posts'  => 'bp_moderate',
    314                                                 'delete_posts'        => 'bp_moderate',
    315                                                 'delete_others_posts' => 'bp_moderate',
    316                                         ),
    317                                         'map_meta_cap'      => true,
     309                                        'capability_type'   => 'bp_email',
    318310                                        'labels'            => bp_get_email_post_type_labels(),
    319311                                        'menu_icon'         => 'dashicons-email',
    320312                                        'public'            => false,