Changeset 4559
- Timestamp:
- 12/19/2016 07:00:06 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r4505 r4559 112 112 } 113 113 $result['sections']['reviews'] = $this->get_plugin_reviews_markup( $post->post_name ); 114 if ( !empty( $result['sections']['faq'] ) ) { 115 $result['sections']['enhanced_faq'] = $result['sections']['faq']; 116 $result['sections']['faq'] = $this->get_simplified_faq_markup( $result['sections']['enhanced_faq'] ); 117 } 118 114 119 $result['description'] = $result['sections']['description']; 115 120 … … 271 276 } 272 277 278 /** 279 * Return a 'simplified' markup for the FAQ screen. 280 * WordPress only supports a whitelisted selection of tags, `<dl>` is not one of them. 281 * 282 * @see https://core.trac.wordpress.org/browser/tags/4.7/src/wp-admin/includes/plugin-install.php#L478 283 * @param string $markup The existing Markup. 284 * @return string Them markup with `<dt>` replaced with `<h4>` and `<dd>` with `<p>`. 285 */ 286 protected function get_simplified_faq_markup( $markup ) { 287 $markup = str_replace( 288 array( '<dl>', '</dl>', '<dt>', '</dt>', '<dd>', '</dd>' ), 289 array( '', '', '<h4>', '</h4>', '<p>', '</p>' ), 290 $markup 291 ); 292 293 return $markup; 294 } 295 273 296 } 274 297 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-popular-tags.php
r4125 r4559 25 25 */ 26 26 function popular_tags( $request ) { 27 $terms = get_terms( 'plugin_tags', array( 'hide_empty' => false, 'orderby' => 'count', 'order' => 'DESC' ) ); 27 $terms = get_terms( 'plugin_tags', array( 28 'hide_empty' => true, 29 'orderby' => 'count', 30 'order' => 'DESC', 31 'number' => 1000 32 ) ); 28 33 29 34 $response = array(); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
r4197 r4559 47 47 'sections' => true, 48 48 'tags' => true, 49 'tested' => true, 49 'tested' => true, 50 'enhanced_faq' => false, 50 51 ); 51 52 … … 65 66 'short_description' => true, 66 67 'tags' => true, 67 'tested' => true, 68 'tested' => true, 69 'enhanced_faq' => false, 68 70 ); 69 71 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php
r4125 r4559 112 112 if ( 'reviews' === $field && ! $include ) { 113 113 unset( $response['sections']['reviews'] ); 114 } 115 if ( 'enhanced_faq' === $field ) { 116 if ( $include ) { 117 $response['sections']['faq'] = $response['sections']['enhanced_faq']; 118 } 119 unset( $response['sections']['enhanced_faq'] ); 114 120 } 115 121 } … … 180 186 */ 181 187 public function popular_tags( $request ) { 182 if ( false === ( $response = false&&wp_cache_get( $cache_key = $this->popular_tags_cache_key( $request ), self::CACHE_GROUP ) ) ) {183 $response = $this->internal_rest_api_call( 'plugins/v1/popular- categories', array( 'locale' => $request->locale ) );188 if ( false === ( $response = wp_cache_get( $cache_key = $this->popular_tags_cache_key( $request ), self::CACHE_GROUP ) ) ) { 189 $response = $this->internal_rest_api_call( 'plugins/v1/popular-tags', array( 'locale' => $request->locale ) ); 184 190 185 191 if ( 200 != $response->status ) { … … 191 197 } 192 198 193 if ( $request->number && count( $response ) > $request->number ) { 194 $response = array_slice( $response, 0, $request->number, true ); 199 $number_items_requested = 100; 200 if ( !empty( $request->number ) ) { 201 $number_items_requested = $request->number; 202 } 203 204 if ( count( $response ) > $number_items_requested ) { 205 $response = array_slice( $response, 0, $number_items_requested, true ); 195 206 } 196 207 197 208 $this->output( (object) $response ); 198 209 } 199 /** 200 * Generates a cache key for a 'hot_categories' API request. 210 211 /** 212 * Generates a cache key for a 'hot_tags' API request. 201 213 */ 202 214 protected function popular_tags_cache_key( $request ) { 203 return 'hot_ categories:' . $request->locale;215 return 'hot_tags:' . $request->locale;; 204 216 } 205 217
Note: See TracChangeset
for help on using the changeset viewer.