Changeset 11535
- Timestamp:
- 02/10/2022 12:41:19 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
r10200 r11535 19 19 'donate_link' => false, 20 20 'downloaded' => false, 21 'download link'=> false,21 'download_link' => false, 22 22 'homepage' => false, 23 23 'icons' => false, … … 25 25 'rating' => false, 26 26 'ratings' => false, 27 'reviews' => false, 27 'reviews' => false, // NOTE: sub-key of 'sections'. 28 28 'requires' => false, 29 29 'requires_php' => false, … … 38 38 'author_block_rating' => false, 39 39 'language_packs' => false, 40 'versions' => false, 40 41 ); 41 42 … … 46 47 'bare_contributors' => true, 47 48 'downloaded' => true, 48 'download link'=> true,49 'download_link' => true, 49 50 'donate_link' => true, 50 51 'homepage' => true, … … 76 77 'downloaded' => true, 77 78 'description' => true, 78 'download link'=> true,79 'download_link' => true, 79 80 'donate_link' => true, 80 81 'homepage' => true, … … 109 110 'author_block_count' => true, 110 111 'author_block_rating' => true, 112 ); 113 114 // Typo/incorrect field name transforms. 115 static $field_aliases = array( 116 // from => to 117 'downloadlink' => 'download_link', // Incorrectly documented in plugins_api(). 111 118 ); 112 119 … … 160 167 161 168 // In WordPress 4.0+ we request the icons field however we don't use the 162 // description and compatibility fields so we exclu e those by default unless requested.169 // description and compatibility fields so we exclude those by default unless requested. 163 170 if ( ! empty( $this->requested_fields['icons'] ) ) { 164 171 $fields['compatibility'] = false; … … 192 199 } 193 200 } 201 202 // If the field is an aliased field, redirect to the proper field. 203 $field = self::$field_aliases[ $field ] ?? $field; 204 205 // If it's a valid field, include it. 194 206 if ( isset( self::$fields[ $field ] ) ) { 195 207 $requested_fields[ $field ] = (bool) $include; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php
r11219 r11535 155 155 * @param string $method The requested method, used to determine the default fields to include. 156 156 * 157 * @return array The $resonse with the extra fields removed. 158 */ 159 protected function remove_unexpected_fields( $response, $request, $method = '' ) { 160 $fields = $request->get_expected_fields( $method ); 157 * @return array The $response with the extra fields removed. 158 */ 159 protected function remove_unexpected_fields( $full_response, $request, $method = '' ) { 160 $response = $full_response; 161 $fields = $request->get_expected_fields( $method ); 161 162 foreach ( $fields as $field => $include ) { 162 163 if ( ! $include ) { … … 168 169 } 169 170 171 // Support requesting reviews without sections. 172 if ( ! empty( $fields['reviews'] ) && empty( $fields['sections'] ) ) { 173 $response['sections'] = array( 174 'reviews' => $full_response['sections']['reviews'] 175 ); 176 } 177 170 178 // Back-compatible routines. 171 179 // WordPress 4.9 and older need a "bare" contributor map [ user => profile ] 172 180 if ( ! empty( $fields['bare_contributors'] ) ) { 173 $contrib s= $response['contributors'] ?? [];181 $contributors = $response['contributors'] ?? []; 174 182 $response['contributors'] = array(); 175 if ( $contribs ) { 176 foreach ( $contribs as $user => $data ) { 177 $response['contributors'][ $user ] = $data['profile']; 178 } 183 foreach ( $contributors as $user => $data ) { 184 $response['contributors'][ $user ] = $data['profile']; 179 185 } 180 186 } … … 182 188 // Only include block translation data for the selected locale. 183 189 if ( ! empty( $response['block_translations'] ) ) { 184 $response['block_translations'] = !empty( $response['block_translations'][ $request->locale ] ) ? $response['block_translations'][ $request->locale ] :[];190 $response['block_translations'] = $response['block_translations'][ $request->locale ] ?? []; 185 191 } 186 192
Note: See TracChangeset
for help on using the changeset viewer.