Changeset 4764
- Timestamp:
- 01/24/2017 10:59:27 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 5 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; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php
r3511 r4764 16 16 */ 17 17 static function translate_term( $term ) { 18 if ( 'en_US' == get_locale() ) { 19 return $term; 20 } 21 18 22 if ( 'plugin_category' == $term->taxonomy ) { 19 23 $term->name = esc_html( translate_with_gettext_context( html_entity_decode( $term->name ), 'Plugin Category Name', 'wporg-plugins' ) ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r4620 r4764 454 454 } 455 455 456 if ( 'en_US' != get_locale() ) { 457 add_filter( 'get_term', array( __NAMESPACE__ . '\I18n', 'translate_term' ) ); 458 add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 ); 459 add_filter( 'the_title', array( $this, 'translate_post_title' ), 1, 2 ); 460 add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1, 2 ); 461 } 456 add_filter( 'get_term', array( __NAMESPACE__ . '\I18n', 'translate_term' ) ); 457 add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 ); 458 add_filter( 'the_title', array( $this, 'translate_post_title' ), 1, 2 ); 459 add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1, 2 ); 462 460 463 461 // Instantiate our copy of the Jetpack_Search class. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php
r4622 r4764 332 332 } 333 333 334 if ( ! $wp_locale ) {334 if ( ! $wp_locale || 'en_US' == $wp_locale ) { 335 335 return $content; 336 336 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
r4622 r4764 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 use WordPressdotorg\Plugin_Directory\Template; 4 use WordPressdotorg\Plugin_Directory\Plugin_i18n; 4 5 5 6 /** … … 35 36 36 37 if ( $descriptions && ! empty( $descriptions[ (int)$image['resolution'] ] ) ) { 37 $screen_shot .= '<figcaption>' . $descriptions[ (int)$image['resolution'] ] . '</figcaption>'; 38 $caption = $descriptions[ (int)$image['resolution'] ]; 39 $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $$plugin->ID ] ); 40 $screen_shot .= '<figcaption>' . $caption . '</figcaption>'; 38 41 } 39 42
Note: See TracChangeset
for help on using the changeset viewer.