Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/29/2015 10:03:53 PM (10 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/admin/bp-core-admin-settings.php

    r10108 r10152  
    160160}
    161161
     162/**
     163 * Allow members to upload cover images field.
     164 *
     165 * @since 2.4.0
     166 */
     167function bp_admin_setting_callback_cover_image_uploads() {
     168?>
     169    <input id="bp-disable-cover-image-uploads" name="bp-disable-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_cover_image_uploads() ); ?> />
     170    <label for="bp-disable-cover-image-uploads"><?php _e( 'Allow registered members to upload cover images', 'buddypress' ); ?></label>
     171<?php
     172}
     173
    162174/** Groups Section ************************************************************/
    163175
     
    195207    <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> />
    196208    <label for="bp-disable-group-avatar-uploads"><?php _e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label>
     209<?php
     210}
     211
     212/**
     213 * 'Enable group cover images' field markup.
     214 *
     215 * @since 2.4.0
     216 */
     217function bp_admin_setting_callback_group_cover_image_uploads() {
     218?>
     219    <input id="bp-disable-group-cover-image-uploads" name="bp-disable-group-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_cover_image_uploads() ); ?> />
     220    <label for="bp-disable-group-cover-image-uploads"><?php _e( 'Allow customizable cover images for groups', 'buddypress' ); ?></label>
    197221<?php
    198222}
     
    300324            'bp-disable-account-deletion',
    301325            'bp-disable-avatar-uploads',
     326            'bp-disable-cover-image-uploads',
    302327            'bp-disable-group-avatar-uploads',
     328            'bp-disable-group-cover-image-uploads',
    303329            'bp_disable_blogforum_comments',
    304330            'bp-disable-profile-sync',
Note: See TracChangeset for help on using the changeset viewer.