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

    r10108 r10152  
    2424        /** Components ********************************************************/
    2525
    26         'bp-deactivated-components'       => array(),
     26        'bp-deactivated-components'            => array(),
    2727
    2828        /** bbPress ***********************************************************/
    2929
    3030        // Legacy bbPress config location
    31         'bb-config-location'              => ABSPATH . 'bb-config.php',
     31        'bb-config-location'                   => ABSPATH . 'bb-config.php',
    3232
    3333        /** XProfile **********************************************************/
    3434
    3535        // Base profile groups name
    36         'bp-xprofile-base-group-name'     => 'Base',
     36        'bp-xprofile-base-group-name'          => 'Base',
    3737
    3838        // Base fullname field name
    39         'bp-xprofile-fullname-field-name' => 'Name',
     39        'bp-xprofile-fullname-field-name'      => 'Name',
    4040
    4141        /** Blogs *************************************************************/
    4242
    4343        // Used to decide if blogs need indexing
    44         'bp-blogs-first-install'          => false,
     44        'bp-blogs-first-install'               => false,
    4545
    4646        /** Settings **********************************************************/
    4747
    4848        // Disable the WP to BP profile sync
    49         'bp-disable-profile-sync'         => false,
     49        'bp-disable-profile-sync'              => false,
    5050
    5151        // Hide the Toolbar for logged out users
    52         'hide-loggedout-adminbar'         => false,
     52        'hide-loggedout-adminbar'              => false,
    5353
    5454        // Avatar uploads
    55         'bp-disable-avatar-uploads'       => false,
     55        'bp-disable-avatar-uploads'            => false,
     56
     57        // Cover image uploads
     58        'bp-disable-cover-image-uploads'       => false,
    5659
    5760        // Group Profile Photos
    58         'bp-disable-group-avatar-uploads' => false,
     61        'bp-disable-group-avatar-uploads'      => false,
     62
     63        // Group Cover image uploads
     64        'bp-disable-group-cover-image-uploads' => false,
    5965
    6066        // Allow users to delete their own accounts
    61         'bp-disable-account-deletion'     => false,
     67        'bp-disable-account-deletion'          => false,
    6268
    6369        // Allow comments on blog and forum activity items
    64         'bp-disable-blogforum-comments'   => true,
     70        'bp-disable-blogforum-comments'        => true,
    6571
    6672        // The ID for the current theme package.
    67         '_bp_theme_package_id'            => 'legacy',
     73        '_bp_theme_package_id'                 => 'legacy',
    6874
    6975        /** Groups ************************************************************/
     
    7278
    7379        // Restrict group creation to super admins
    74         'bp_restrict_group_creation'      => false,
     80        'bp_restrict_group_creation'           => false,
    7581
    7682        /** Akismet ***********************************************************/
    7783
    7884        // Users from all sites can post
    79         '_bp_enable_akismet'              => true,
     85        '_bp_enable_akismet'                   => true,
    8086
    8187        /** Activity HeartBeat ************************************************/
    8288
    8389        // HeartBeat is on to refresh activities
    84         '_bp_enable_heartbeat_refresh'    => true,
     90        '_bp_enable_heartbeat_refresh'         => true,
    8591
    8692        /** BuddyBar **********************************************************/
    8793
    8894        // Force the BuddyBar
    89         '_bp_force_buddybar'              => false,
     95        '_bp_force_buddybar'                   => false,
    9096
    9197        /** Legacy theme *********************************************/
    9298
    9399        // Whether to register the bp-default themes directory
    94         '_bp_retain_bp_default'           => false,
     100        '_bp_retain_bp_default'                => false,
    95101
    96102        /** Widgets **************************************************/
     
    597603
    598604/**
     605 * Are members able to upload their own cover images?
     606 *
     607 * @since 2.4.0
     608 *
     609 * @uses bp_get_option() To get the cover image uploads option.
     610 *
     611 * @param bool $default Optional. Fallback value if not found in the database.
     612 *                      Default: false.
     613 *
     614 * @return bool True if cover image uploads are disabled, otherwise false.
     615 */
     616function bp_disable_cover_image_uploads( $default = false ) {
     617
     618    /**
     619     * Filters whether or not members are able to upload their own cover images.
     620     *
     621     * @since 2.4.0
     622     *
     623     * @param bool $value Whether or not members are able to upload their own cover images.
     624     */
     625    return (bool) apply_filters( 'bp_disable_cover_image_uploads', (bool) bp_get_option( 'bp-disable-cover-image-uploads', $default ) );
     626}
     627
     628/**
    599629 * Are group avatars disabled?
    600630 *
     
    629659     */
    630660    return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
     661}
     662
     663/**
     664 * Are group cover images disabled?
     665 *
     666 * @since 2.4.0
     667 *
     668 * @uses bp_get_option() To get the group cover image uploads option.
     669 *
     670 * @param bool $default Optional. Fallback value if not found in the database.
     671 *                      Default: false.
     672 *
     673 * @return bool True if group cover image uploads are disabled, otherwise false.
     674 */
     675function bp_disable_group_cover_image_uploads( $default = false ) {
     676
     677    /**
     678     * Filters whether or not members are able to upload group cover images.
     679     *
     680     * @since 2.4.0
     681     *
     682     * @param bool $value Whether or not members are able to upload thier groups cover images.
     683     */
     684    return (bool) apply_filters( 'bp_disable_group_cover_image_uploads', (bool) bp_get_option( 'bp-disable-group-cover-image-uploads', $default ) );
    631685}
    632686
Note: See TracChangeset for help on using the changeset viewer.