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-admin.php

    r10108 r10152  
    339339            add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
    340340
     341            // Avatars
    341342            add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
    342343            register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
     344
     345            // Cover images
     346            if ( bp_is_active( 'xprofile', 'cover_image' ) ) {
     347                add_settings_field( 'bp-disable-cover-image-uploads', __( 'Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_cover_image_uploads', 'buddypress', 'bp_xprofile' );
     348                register_setting( 'buddypress', 'bp-disable-cover-image-uploads', 'intval' );
     349            }
    343350
    344351            // Profile sync setting
     
    361368            add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
    362369            register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
     370
     371            // Allow group cover images.
     372            if ( bp_is_active( 'groups', 'cover_image' ) ) {
     373                add_settings_field( 'bp-disable-group-cover-image-uploads', __( 'Group Cover Image Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_cover_image_uploads', 'buddypress', 'bp_groups' );
     374                register_setting( 'buddypress', 'bp-disable-group-cover-image-uploads', 'intval' );
     375            }
    363376        }
    364377
Note: See TracChangeset for help on using the changeset viewer.