Changeset 3498
- Timestamp:
- 06/20/2016 11:00:11 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3476 r3498 498 498 * @return string 499 499 */ 500 public function translate_post_content( $content, $section = null ) {500 public function translate_post_content( $content, $section = null, $post_id = null ) { 501 501 if ( is_null( $section ) ) { 502 502 return $content; 503 503 } 504 return Plugin_I18n::instance()->translate( $section, $content );504 return Plugin_I18n::instance()->translate( $section, $content, [ 'post_id' => $post_id ] ); 505 505 } 506 506 … … 538 538 */ 539 539 public function append_meta_for_jetpack() { 540 // TEMP: only do this for low numbered plugin IDs, till we're sure it works.541 $post = get_post();542 if ( $post instanceof \WP_Post && $post->ID > 200 )543 return;544 545 540 // Guess if a Jetpack sync is scheduled to run. It runs during shutdown at a lower priority than this action, so we can get in first. 546 541 // Fetching the extra meta to inject is expensive, so we only want to do this if a sync is likely. 547 if ( class_exists( 'Jetpack' ) && !empty(\Jetpack:: init()->sync->sync) ) {542 if ( class_exists( 'Jetpack' ) && !empty(\Jetpack::$instance->sync->sync) ) { 548 543 add_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n' ), 10, 2 ); 549 544 } … … 562 557 remove_filter( 'wporg_plugins_custom_meta_fields', array( $this, 'filter_post_meta_i18n' ) ); 563 558 564 if ( get_post()->ID == $post_id) {565 $locales_to_sync = array( 'fr_ fr', 'es_es' ); // This should probably be a list of available translations for the plugin readme.559 if ( $post_id <= 200 ) { 560 $locales_to_sync = array( 'fr_FR', 'es_ES' ); // This should probably be a list of available translations for the plugin readme. 566 561 567 562 global $locale; 568 563 $_locale = $locale; 569 564 foreach ( $locales_to_sync as $locale ) { 570 $this->i18n_meta[$post_id]['title_'.$locale] = $this->translate_post_title( get_the_title( ), $post_id );571 $this->i18n_meta[$post_id]['excerpt_'.$locale] = $this->translate_post_excerpt( get_the_excerpt( ));565 $this->i18n_meta[$post_id]['title_'.$locale] = $this->translate_post_title( get_the_title( $post_id ), $post_id ); 566 $this->i18n_meta[$post_id]['excerpt_'.$locale] = $this->translate_post_excerpt( get_the_excerpt( $post_id ), $post_id ); 572 567 573 568 // Split up the content to translate it in sections 574 569 $content = ''; 575 $sections = $this->split_post_content_into_pages( get_the_content() ); 576 foreach ( $sections as $section => $section_content ) 577 $content .= $this->translate_post_content( $section_content, $section ); 570 $sections = $this->split_post_content_into_pages( get_the_content( $post_id ) ); 571 foreach ( $sections as $section => $section_content ) { 572 $content .= $this->translate_post_content( $section_content, $section, $post_id ); 573 } 578 574 $this->i18n_meta[$post_id]['content_'.$locale] = $content; 579 575 … … 784 780 break; 785 781 default: 786 if ( isset( $this->i18n_meta[ $object_id ][ $meta_key ] ) ) 782 if ( isset( $this->i18n_meta[ $object_id ][ $meta_key ] ) ) { 787 783 return array( $this->i18n_meta[ $object_id ][ $meta_key ] ); 784 } 788 785 break; 789 786 }
Note: See TracChangeset
for help on using the changeset viewer.