Changeset 47236
- Timestamp:
- 02/10/2020 05:30:03 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r47219 r47236 2960 2960 $user_meta = get_user_meta( $user->ID ); 2961 2961 2962 $user_prop _to_export = array(2962 $user_props_to_export = array( 2963 2963 'ID' => __( 'User ID' ), 2964 2964 'user_login' => __( 'User Login Name' ), … … 2976 2976 $user_data_to_export = array(); 2977 2977 2978 foreach ( $user_prop _to_export as $key => $name ) {2978 foreach ( $user_props_to_export as $key => $name ) { 2979 2979 $value = ''; 2980 2980 … … 3013 3013 ); 3014 3014 3015 /** 3016 * Introduce any Community Events Location data that is available. 3017 * 3018 * @since 5.4.0 3019 */ 3020 if ( isset( $user_meta['community-events-location'] ) ) { 3021 $location = maybe_unserialize( $user_meta['community-events-location'][0] ); 3022 3023 $location_props_to_export = array( 3024 'description' => __( 'City' ), 3025 'country' => __( 'Country' ), 3026 'latitude' => __( 'Latitude' ), 3027 'longitude' => __( 'Longitude' ), 3028 'ip' => __( 'IP' ), 3029 ); 3030 3031 $location_data_to_export = array(); 3032 3033 foreach ( $location_props_to_export as $key => $name ) { 3034 if ( ! empty( $location[ $key ] ) ) { 3035 $location_data_to_export[] = array( 3036 'name' => $name, 3037 'value' => $location[ $key ], 3038 ); 3039 } 3040 } 3041 3042 $data_to_export[] = array( 3043 'group_id' => 'community-events-location', 3044 'group_label' => __( 'Community Events Location' ), 3045 'group_description' => __( 'User’s location data used for the Community Events in the WordPress Events and News dashboard widget.' ), 3046 'item_id' => "community-events-location-{$user->ID}", 3047 'data' => $location_data_to_export, 3048 ); 3049 } 3050 3015 3051 return array( 3016 3052 'data' => $data_to_export, -
trunk/tests/phpunit/tests/user.php
r47122 r47236 1652 1652 1653 1653 /** 1654 * Testing the `wp_user_personal_data_exporter _no_user` function when no user exists.1654 * Testing the `wp_user_personal_data_exporter()` function when no user exists. 1655 1655 * 1656 1656 * @ticket 43547 … … 1668 1668 1669 1669 /** 1670 * Testing the `wp_user_personal_data_exporter _no_user` function when the requested1670 * Testing the `wp_user_personal_data_exporter()` function when the requested 1671 1671 * user exists. 1672 1672 * … … 1686 1686 $this->assertSame( 11, count( $actual['data'][0]['data'] ) ); 1687 1687 } 1688 1689 /** 1690 * Testing the `wp_user_personal_data_exporter()` function 1691 * with Community Events Location IP data. 1692 * 1693 * @ticket 43921 1694 */ 1695 function test_wp_community_events_location_ip_personal_data_exporter() { 1696 $test_user = new WP_User( self::$contrib_id ); 1697 1698 $location_data = array( 'ip' => '0.0.0.0' ); 1699 update_user_option( $test_user->ID, 'community-events-location', $location_data, true ); 1700 1701 $actual = wp_user_personal_data_exporter( $test_user->user_email ); 1702 1703 $this->assertTrue( $actual['done'] ); 1704 1705 // Contains 'Community Events Location'. 1706 $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] ); 1707 1708 // Contains location IP. 1709 $this->assertEquals( 'IP', $actual['data'][1]['data'][0]['name'] ); 1710 $this->assertEquals( '0.0.0.0', $actual['data'][1]['data'][0]['value'] ); 1711 } 1712 1713 /** 1714 * Testing the `wp_user_personal_data_exporter()` function 1715 * with Community Events Location city data. 1716 * 1717 * @ticket 43921 1718 */ 1719 function test_wp_community_events_location_city_personal_data_exporter() { 1720 $test_user = new WP_User( self::$contrib_id ); 1721 1722 $location_data = array( 1723 'description' => 'Cincinnati', 1724 'country' => 'US', 1725 'latitude' => '39.1271100', 1726 'longitude' => '-84.5143900', 1727 ); 1728 update_user_option( $test_user->ID, 'community-events-location', $location_data, true ); 1729 1730 $actual = wp_user_personal_data_exporter( $test_user->user_email ); 1731 1732 $this->assertTrue( $actual['done'] ); 1733 1734 // Contains 'Community Events Location'. 1735 $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] ); 1736 1737 // Contains location city. 1738 $this->assertEquals( 'City', $actual['data'][1]['data'][0]['name'] ); 1739 $this->assertEquals( 'Cincinnati', $actual['data'][1]['data'][0]['value'] ); 1740 1741 // Contains location country. 1742 $this->assertEquals( 'Country', $actual['data'][1]['data'][1]['name'] ); 1743 $this->assertEquals( 'US', $actual['data'][1]['data'][1]['value'] ); 1744 1745 // Contains location latitude. 1746 $this->assertEquals( 'Latitude', $actual['data'][1]['data'][2]['name'] ); 1747 $this->assertEquals( '39.1271100', $actual['data'][1]['data'][2]['value'] ); 1748 1749 // Contains location longitude. 1750 $this->assertEquals( 'Longitude', $actual['data'][1]['data'][3]['name'] ); 1751 $this->assertEquals( '-84.5143900', $actual['data'][1]['data'][3]['value'] ); 1752 1753 } 1688 1754 }
Note: See TracChangeset
for help on using the changeset viewer.