Skip to:
Content

BuddyPress.org

Changeset 12416


Ignore:
Timestamp:
07/25/2019 01:54:40 PM (5 months ago)
Author:
imath
Message:

BP Settings: Introduce a new BP friendly name key into data exporters

The name of this key is exporter_bp_friendly_name. It is added to BP & WP exporter arrays to adapt the existing exporter_friendly_name for a non Administrator role context. If this new key is provided it will be used to output the friendly name of the exported items, otherwise it will use the existing exporter_friendly_name key.

For example, into the items list of the site.url/username/settings/data page of the logged in user, "WordPress Comments" will be replaced by "Comments" and so on for every built-in WordPress and BuddyPress items.

Props sbrajesh, r-a-y, boonebgorges

Fixes #8013

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-filters.php

    r12393 r12416  
    819819 *
    820820 * @since 4.0.0
     821 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    821822 *
    822823 * @param array $exporters  An array of personal data exporters.
     
    825826function bp_activity_register_personal_data_exporter( $exporters ) {
    826827    $exporters['buddypress-activity'] = array(
    827         'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
    828         'callback'               => 'bp_activity_personal_data_exporter',
     828        'exporter_friendly_name'    => __( 'BuddyPress Activity Data', 'buddypress' ),
     829        'callback'                  => 'bp_activity_personal_data_exporter',
     830        'exporter_bp_friendly_name' => _x( 'Activity Data', 'BuddyPress Activity data exporter friendly name', 'buddypress' ),
    829831    );
    830832
  • trunk/src/bp-friends/bp-friends-filters.php

    r12160 r12416  
    5353 *
    5454 * @since 4.0.0
     55 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    5556 *
    5657 * @param array $exporters  An array of personal data exporters.
     
    5960function bp_friends_register_personal_data_exporters( $exporters ) {
    6061    $exporters['buddypress-friends'] = array(
    61         'exporter_friendly_name' => __( 'BuddyPress Friends', 'buddypress' ),
    62         'callback'               => 'bp_friends_personal_data_exporter',
     62        'exporter_friendly_name'    => __( 'BuddyPress Friends', 'buddypress' ),
     63        'callback'                  => 'bp_friends_personal_data_exporter',
     64        'exporter_bp_friendly_name' => _x( 'Friends', 'BuddyPress Friends data exporter friendly name', 'buddypress' ),
    6365    );
    6466
    6567    $exporters['buddypress-friends-pending-sent-requests'] = array(
    66         'exporter_friendly_name' => __( 'BuddyPress Friend Requests (Sent)', 'buddypress' ),
    67         'callback'               => 'bp_friends_pending_sent_requests_personal_data_exporter',
     68        'exporter_friendly_name'    => __( 'BuddyPress Friend Requests (Sent)', 'buddypress' ),
     69        'callback'                  => 'bp_friends_pending_sent_requests_personal_data_exporter',
     70        'exporter_bp_friendly_name' => _x( 'Friend Requests (Sent)', 'BuddyPress Friend Requests data exporter friendly name', 'buddypress' ),
    6871    );
    6972
    7073    $exporters['buddypress-friends-pending-received-requests'] = array(
    71         'exporter_friendly_name' => __( 'BuddyPress Friend Requests (Received)', 'buddypress' ),
    72         'callback'               => 'bp_friends_pending_received_requests_personal_data_exporter',
     74        'exporter_friendly_name'    => __( 'BuddyPress Friend Requests (Received)', 'buddypress' ),
     75        'callback'                  => 'bp_friends_pending_received_requests_personal_data_exporter',
     76        'exporter_bp_friendly_name' => _x( 'Friend Requests (Received)', 'BuddyPress Friend Requests data exporter friendly name', 'buddypress' ),
    7377    );
    7478
  • trunk/src/bp-groups/bp-groups-filters.php

    r12163 r12416  
    371371 *
    372372 * @since 4.0.0
     373 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    373374 *
    374375 * @param array $exporters  An array of personal data exporters.
     
    377378function bp_groups_register_personal_data_exporters( $exporters ) {
    378379    $exporters['buddypress-groups-memberships'] = array(
    379         'exporter_friendly_name' => __( 'BuddyPress Group Memberships', 'buddypress' ),
    380         'callback'               => 'bp_groups_memberships_personal_data_exporter',
     380        'exporter_friendly_name'    => __( 'BuddyPress Group Memberships', 'buddypress' ),
     381        'callback'                  => 'bp_groups_memberships_personal_data_exporter',
     382        'exporter_bp_friendly_name' => _x( 'Group Memberships', 'BuddyPress Group Memberships data exporter friendly name', 'buddypress' ),
    381383    );
    382384
    383385    $exporters['buddypress-groups-pending-requests'] = array(
    384         'exporter_friendly_name' => __( 'BuddyPress Pending Group Membership Requests', 'buddypress' ),
    385         'callback'               => 'bp_groups_pending_requests_personal_data_exporter',
     386        'exporter_friendly_name'    => __( 'BuddyPress Pending Group Membership Requests', 'buddypress' ),
     387        'callback'                  => 'bp_groups_pending_requests_personal_data_exporter',
     388        'exporter_bp_friendly_name' => _x( 'Pending Group Membership Requests', 'BuddyPress Pending Group Membership Requests data exporter friendly name', 'buddypress' ),
    386389    );
    387390
    388391    $exporters['buddypress-groups-pending-received-invitations'] = array(
    389         'exporter_friendly_name' => __( 'BuddyPress Pending Group Invitations (Received)', 'buddypress' ),
    390         'callback'               => 'bp_groups_pending_received_invitations_personal_data_exporter',
     392        'exporter_friendly_name'    => __( 'BuddyPress Pending Group Invitations (Received)', 'buddypress' ),
     393        'callback'                  => 'bp_groups_pending_received_invitations_personal_data_exporter',
     394        'exporter_bp_friendly_name' => _x( 'Pending Group Invitations (Received)', 'BuddyPress Pending Group Invitations data exporter friendly name', 'buddypress' ),
    391395    );
    392396
    393397    $exporters['buddypress-groups-pending-sent-invitations'] = array(
    394         'exporter_friendly_name' => __( 'BuddyPress Pending Group Invitations (Sent)', 'buddypress' ),
    395         'callback'               => 'bp_groups_pending_sent_invitations_personal_data_exporter',
     398        'exporter_friendly_name'    => __( 'BuddyPress Pending Group Invitations (Sent)', 'buddypress' ),
     399        'callback'                  => 'bp_groups_pending_sent_invitations_personal_data_exporter',
     400        'exporter_bp_friendly_name' => _x( 'Pending Group Invitations (Sent)', 'BuddyPress Pending Group Invitations data exporter friendly name', 'buddypress' ),
    396401    );
    397402
  • trunk/src/bp-messages/bp-messages-filters.php

    r12164 r12416  
    135135 *
    136136 * @since 4.0.0
     137 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    137138 *
    138139 * @param array $exporters  An array of personal data exporters.
     
    141142function bp_messages_register_personal_data_exporter( $exporters ) {
    142143    $exporters['buddypress-messages'] = array(
    143         'exporter_friendly_name' => __( 'BuddyPress Messages', 'buddypress' ),
    144         'callback'               => 'bp_messages_personal_data_exporter',
     144        'exporter_friendly_name'    => __( 'BuddyPress Messages', 'buddypress' ),
     145        'callback'                  => 'bp_messages_personal_data_exporter',
     146        'exporter_bp_friendly_name' => _x( 'Private Messages', 'BuddyPress Messages data exporter friendly name', 'buddypress' ),
    145147    );
    146148
  • trunk/src/bp-notifications/bp-notifications-filters.php

    r12158 r12416  
    1515 *
    1616 * @since 4.0.0
     17 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    1718 *
    1819 * @param array $exporters  An array of personal data exporters.
     
    2122function bp_register_notifications_personal_data_exporter( $exporters ) {
    2223    $exporters['buddypress-notifications'] = array(
    23         'exporter_friendly_name' => __( 'BuddyPress Notifications Data', 'buddypress' ),
    24         'callback'               => 'bp_notifications_personal_data_exporter',
     24        'exporter_friendly_name'    => __( 'BuddyPress Notifications Data', 'buddypress' ),
     25        'callback'                  => 'bp_notifications_personal_data_exporter',
     26        'exporter_bp_friendly_name' => _x( 'Notifications Data', 'BuddyPress Notifications data exporter friendly name', 'buddypress' ),
    2527    );
    2628
  • trunk/src/bp-settings/bp-settings-filters.php

    r12159 r12416  
    1414 *
    1515 * @since 4.0.0
     16 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    1617 *
    1718 * @param array $exporters  An array of personal data exporters.
     
    2021function bp_settings_register_personal_data_exporter( $exporters ) {
    2122    $exporters['buddypress-settings'] = array(
    22         'exporter_friendly_name' => __( 'BuddyPress Settings Data', 'buddypress' ),
    23         'callback'               => 'bp_settings_personal_data_exporter',
     23        'exporter_friendly_name'    => __( 'BuddyPress Settings Data', 'buddypress' ),
     24        'callback'                  => 'bp_settings_personal_data_exporter',
     25        'exporter_bp_friendly_name' => _x( 'Personal settings', 'BuddyPress Settings Data data exporter friendly name', 'buddypress' ),
    2426    );
    2527
  • trunk/src/bp-settings/bp-settings-functions.php

    r12272 r12416  
    317317 * 'exporter_friendly_name' key, which is meant for the admin area.
    318318 *
    319  * @todo We should look for a custom key like 'exporter_frontend_name' if available.
    320  *
    321  * @since 4.0.0
     319 * @since 4.0.0
     320 * @since 5.0.0 Looks for a potential exporter's BP/custom friendly name.
    322321 */
    323322function bp_settings_data_exporter_items() {
    324323    /** This filter is documented in /wp-admin/includes/ajax-actions.php */
    325     $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() );
     324    $exporters             = apply_filters( 'wp_privacy_personal_data_exporters', array() );
     325    $custom_friendly_names = apply_filters( 'bp_settings_data_custom_friendly_names', array(
     326        'wordpress-comments' => _x( 'Comments', 'WP Comments data exporter friendly name', 'buddypress' ),
     327        'wordpress-media'    => _x( 'Media', 'WP Media data exporter friendly name', 'buddypress' ),
     328        'wordpress-user'     => _x( 'Personal information', 'WP Media data exporter friendly name', 'buddypress' ),
     329    ) );
    326330
    327331?>
    328332    <ul>
    329333    <?php foreach ( $exporters as $exporter => $data ) :
     334        // Use the exporter friendly name by default.
     335        $friendly_name = $data['exporter_friendly_name'];
     336
    330337        /**
    331          * Filters the data exporter name for display on the "Settings > Data" page.
     338         * Use the exporter friendly name if directly available
     339         * into the exporters array.
     340         */
     341        if ( isset( $data['exporter_bp_friendly_name'] ) ) {
     342            $friendly_name = $data['exporter_bp_friendly_name'];
     343
     344        // Look for a potential match into the custom friendly names.
     345        } elseif ( isset( $custom_friendly_names[ $exporter ] ) ) {
     346            $friendly_name = $custom_friendly_names[ $exporter ];
     347        }
     348
     349        /**
     350         * Filters the data exporter friendly name for display on the "Settings > Data" page.
    332351         *
    333352         * @since 4.0.0
     353         * @since 5.0.0 replaces the `$name` parameter with the `$friendly_name` one.
    334354         *
    335          * @param string $name    Data exporter friendly name.
    336          * @param string $exporter Internal exporter name.
     355         * @param string $friendly_name Data exporter friendly name.
     356         * @param string $exporter      Internal exporter name.
    337357         */
    338         $item = apply_filters( 'bp_settings_data_exporter_name', esc_html( $data['exporter_friendly_name'] ), $exporter );
     358        $item = apply_filters( 'bp_settings_data_exporter_name', esc_html( $friendly_name ), $exporter );
    339359    ?>
    340360
  • trunk/src/bp-xprofile/bp-xprofile-filters.php

    r12396 r12416  
    667667 *
    668668 * @since 4.0.0
     669 * @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
    669670 *
    670671 * @param array $exporters  An array of personal data exporters.
     
    673674function bp_xprofile_register_personal_data_exporter( $exporters ) {
    674675    $exporters['buddypress-xprofile'] = array(
    675         'exporter_friendly_name' => __( 'BuddyPress Extended Profile Data', 'buddypress' ),
    676         'callback'               => 'bp_xprofile_personal_data_exporter',
     676        'exporter_friendly_name'    => __( 'BuddyPress Extended Profile Data', 'buddypress' ),
     677        'callback'                  => 'bp_xprofile_personal_data_exporter',
     678        'exporter_bp_friendly_name' => _x( 'Extended Profile information', 'BuddyPress Extended Profile data exporter friendly name', 'buddypress' ),
    677679    );
    678680
Note: See TracChangeset for help on using the changeset viewer.