Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/29/2015 10:03:53 PM (9 years ago)
Author:
imath
Message:

Allow Administrators to disable/enable the Cover Image Feature from the BuddyPress settings (Administration screen)

  • Create two new options for targeted components (xProfile & Groups)
  • Generate two new setting fields into the components setting sections as soon as the feature is active. By default, the two new checkboxes are enabled.
  • Introduce two new functions to check if the Administrator disallowed cover image uploads for Users (bp_disable_cover_image_uploads()) and Groups (bp_disable_group_cover_image_uploads()).
  • Edit the bp_is_active() function to take in account the particularity of the xProfile component. See below for a detailled explanation.
  • Introduce a new conditional tag to check if the current page is the profile "change-cover-image" screen.

The bp_is_active() function first checks into the "bp-active-components" database option to see if the component is active. In this option the xProfile component is keyed "xprofile". But the component global holding the extended BP_Component class is keyed "profile" and features are inside a property of this component global. So to be able to check if a feature attached to the xProfile component is active, we needed to edit this function changing the component key from "xprofile" to "profile". As a result, the xProfile filter to deactivate/activate the cover image is bp_is_profile_cover_image_active. For the Groups component, the filter is bp_is_groups_cover_image_active.

Props mercime, r-a-y

See #6570

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r10109 r10152  
    19351935        // Is feature active?
    19361936        if ( ! empty( $feature ) ) {
     1937            // The xProfile component is specific
     1938            if ( 'xprofile' === $component ) {
     1939                $component = 'profile';
     1940            }
     1941
    19371942            if ( empty( buddypress()->$component->features ) || false === in_array( $feature, buddypress()->$component->features, true ) ) {
    19381943                $retval = false;
     
    22452250function bp_is_user_change_avatar() {
    22462251    return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) );
     2252}
     2253
     2254/**
     2255 * Is the current page the a user's change cover image profile page?
     2256 *
     2257 * Eg http://example.com/members/joe/profile/change-cover-image/ (or a subpage thereof).
     2258 *
     2259 * @since  2.4.0
     2260 *
     2261 * @return True if the current page is a user's profile edit cover image page.
     2262 */
     2263function bp_is_user_change_cover_image() {
     2264    return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-cover-image' ) );
    22472265}
    22482266
Note: See TracChangeset for help on using the changeset viewer.