Changeset 4764 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
- Timestamp:
- 01/24/2017 10:59:27 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r4717 r4764 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 use WordPressdotorg\Plugin_Directory\Plugin_i18n; 4 5 use WordPressdotorg\Plugin_Directory\Template; 5 6 use WordPressdotorg\Plugin_Directory\Tools; … … 55 56 } 56 57 58 // Support returning API data in different locales, even on wordpress.org (for api.wordpress.org usage) 59 if ( ! empty( $request['locale'] ) && !in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) { 60 switch_to_locale( $request['locale'] ); 61 } 62 57 63 $post_id = $post->ID; 58 64 59 65 $result = array(); 60 $result['name'] = $post->post_title;66 $result['name'] = get_the_title(); 61 67 $result['slug'] = $post->post_name; 62 68 $result['version'] = get_post_meta( $post_id, 'version', true ) ?: '0.0'; … … 116 122 if ( !empty( $result['sections']['faq'] ) ) { 117 123 $result['sections']['faq'] = $this->get_simplified_faq_markup( $result['sections']['faq'] ); 118 } 124 } 119 125 120 126 $result['description'] = $result['sections']['description']; 121 127 122 $result['short_description'] = $post->post_excerpt;128 $result['short_description'] = get_the_excerpt(); 123 129 $result['download_link'] = Template::download_link( $post ); 124 130 … … 132 138 */ 133 139 foreach ( $screen_shots as $image ) { 134 $result['screenshots'][ $image['resolution'] ] = array( 135 'src' => Template::get_asset_url( $post, $image ), 136 'caption' => array_key_exists( $image['resolution'], $descriptions ) ? $descriptions[ $image['resolution'] ] : '' 137 ); 140 $src = Template::get_asset_url( $post, $image ); 141 $caption = ''; 142 if ( $descriptions && !empty( $description[ (int)$image['resolution'] ] ) ) { 143 $caption = $description[ (int)$image['resolution'] ]; 144 $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $$post->ID ] ); 145 } 146 147 $result['screenshots'][ $image['resolution'] ] = compact( 'src', 'caption' ); 138 148 } 139 149 … … 145 155 146 156 $result['tags'] = array(); 147 if ( $terms = get_the_terms( $post->ID, 'plugin_ category' ) ) {157 if ( $terms = get_the_terms( $post->ID, 'plugin_tags' ) ) { 148 158 foreach ( $terms as $term ) { 149 159 $result['tags'][ $term->slug ] = $term->name;
Note: See TracChangeset
for help on using the changeset viewer.