Changeset 43054 for trunk/src/wp-includes/media.php
- Timestamp:
- 05/01/2018 01:44:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r42871 r43054 4094 4094 return array( $mediaelement, $wpmediaelement ); 4095 4095 } 4096 4097 /** 4098 * Registers the personal data exporter for media 4099 * 4100 * @param array $exporters An array of personal data exporters. 4101 * @return array An array of personal data exporters. 4102 */ 4103 function wp_register_media_personal_data_exporter( $exporters ) { 4104 $exporters[] = array( 4105 'exporter_friendly_name' => __( 'WordPress Media' ), 4106 'callback' => 'wp_media_personal_data_exporter', 4107 ); 4108 4109 return $exporters; 4110 } 4111 4112 /** 4113 * Finds and exports attachments associated with an email address. 4114 * 4115 * @since 4.9.6 4116 * 4117 * @param string $email_address The attachment owner email address. 4118 * @param int $page Attachment page. 4119 * @return array $return An array of personal data. 4120 */ 4121 function wp_media_personal_data_exporter( $email_address, $page = 1 ) { 4122 // Limit us to 50 attachments at a time to avoid timing out. 4123 $number = 50; 4124 $page = (int) $page; 4125 4126 $data_to_export = array(); 4127 4128 $user = get_user_by( 'email' , $email_address ); 4129 if ( false === $user ) { 4130 return array( 4131 'data' => $data_to_export, 4132 'done' => true, 4133 ); 4134 } 4135 4136 $post_query = new WP_Query( 4137 array( 4138 'author' => $user->ID, 4139 'posts_per_page' => $number, 4140 'paged' => $page, 4141 'post_type' => 'attachment', 4142 'post_status' => 'any', 4143 'orderby' => 'ID', 4144 'order' => 'ASC', 4145 ) 4146 ); 4147 4148 foreach ( (array) $post_query->posts as $post ) { 4149 $attachment_url = wp_get_attachment_url( $post->ID ); 4150 4151 if ( $attachment_url ) { 4152 $post_data_to_export = array( 4153 array( 'name' => __( 'URL' ), 'value' => $attachment_url ), 4154 ); 4155 4156 $data_to_export[] = array( 4157 'group_id' => 'media', 4158 'group_label' => __( 'Media' ), 4159 'item_id' => "post-{$post->ID}", 4160 'data' => $post_data_to_export, 4161 ); 4162 } 4163 } 4164 4165 $done = $post_query->max_num_pages <= $page; 4166 4167 return array( 4168 'data' => $data_to_export, 4169 'done' => $done, 4170 ); 4171 }
Note: See TracChangeset
for help on using the changeset viewer.