Changeset 4475
- Timestamp:
- 12/04/2016 07:11:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php
r3716 r4475 416 416 $original = preg_quote( $original, '/' ); 417 417 $content = preg_replace( "/(<([a-z0-9]*)\b[^>]*>){$original}(<\/\\2>)/m", '${1}___TRANSLATION___${3}', $content ); // Don't use $translation, it may contain backreference-like characters. 418 $content = str_replace( '___TRANSLATION___', $translation, $content ); } 418 $content = str_replace( '___TRANSLATION___', $translation, $content ); 419 } 419 420 420 421 return $content; … … 424 425 * Returns a list of translation locales for a given plugin slug and branch. 425 426 * 426 * @param string $slug Plugin slug.427 * @param string $branch Branch - 'stable-readme' for example.428 * @param string $min_percentOnly return locales where percent_translated is >= this value.427 * @param string $slug Plugin slug. 428 * @param string $branch Branch - 'stable-readme' for example. 429 * @param int $min_percent Optional. Only return locales where percent_translated is >= this value. 429 430 * @return array 430 431 */ … … 434 435 $api_url = esc_url_raw( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $slug . '/' . $branch, array( 'https' ) ); 435 436 436 $http = new \WP_Http(); 437 $out = array(); 438 $http = new \WP_Http(); 437 439 $result = $http->request( $api_url ); 438 440 439 $out = array(); 440 if ( !is_wp_error( $result ) ) { 441 $json = $result['body']; 442 if ( $data = json_decode( $json ) ) { 443 if ( isset( $data->translation_sets ) ) { 444 foreach ( $data->translation_sets as $translation ) { 445 if ( $translation->percent_translated >= $min_percent ) 446 $out[] = $translation->wp_locale; 441 if ( ! is_wp_error( $result ) ) { 442 $data = json_decode( $result['body'] ); 443 444 if ( $data && isset( $data->translation_sets ) ) { 445 foreach ( $data->translation_sets as $translation ) { 446 if ( $translation->percent_translated >= $min_percent ) { 447 $out[] = $translation->wp_locale; 447 448 } 448 449 } … … 452 453 return $out; 453 454 } 454 455 455 }
Note: See TracChangeset
for help on using the changeset viewer.