Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/25/2019 01:54:40 PM (4 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.