Changeset 10352
- Timestamp:
- 10/06/2020 07:33:26 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r10340 r10352 1067 1067 * Fetch all translated content for a given post, and push it into postmeta. 1068 1068 * 1069 * @global string $locale Current locale. 1070 * 1071 * @param int $post_id Post ID to update. 1069 * @param int|string|WP_Post $plugin Plugin to update. 1072 1070 * @param int $min_translated Translations below this % threshold will not be synced to meta, to save space. 1073 1071 * @return array 1074 1072 */ 1075 public function sync_all_translations_to_meta( $p ost_id, $min_translated = 40, $skip_pfx = array( 'en_' ) ) {1073 public function sync_all_translations_to_meta( $plugin, $min_translated = 40, $skip_pfx = array( 'en_' ) ) { 1076 1074 1077 1075 $locales_to_sync = array(); 1078 $post = get_post( $post_id);1076 $post = self::get_plugin_post( $plugin ); 1079 1077 if ( $post ) { 1080 1078 $project = 'stable-readme'; … … 1082 1080 $project = 'dev-readme'; 1083 1081 } 1082 1084 1083 $translations = Plugin_I18n::instance()->find_all_translations_for_plugin( $post->post_name, $project, $min_translated ); // at least $min_translated % translated 1085 1084 if ( $translations ) { … … 1098 1097 if ( count( $locales_to_sync ) > 0 ) { 1099 1098 foreach ( $locales_to_sync as $locale ) { 1100 $this->sync_translation_to_meta( $post _id, $locale );1099 $this->sync_translation_to_meta( $post->ID, $locale ); 1101 1100 } 1102 1101 } … … 1107 1106 /** 1108 1107 * Fetch translated content for a given post and locale, and push it into postmeta. 1109 *1110 * @global string $locale Current locale.1111 1108 * 1112 1109 * @param int $post_id Post ID to update. … … 1121 1118 // Update postmeta values for the translated title, excerpt, and content, if they are available and different from the originals. 1122 1119 // There is a bug here, in that no attempt is made to remove old meta values for translations that do not have new translations. 1123 $the_title = Plugin_I18n::instance()->translate( 'title', $orig_title, [ 'post_id' => $post_id ] );1120 $the_title = Plugin_I18n::instance()->translate( 'title', $orig_title, [ 'post_id' => $post_id, 'locale' => $locale ] ); 1124 1121 if ( $the_title && $the_title != $orig_title ) { 1125 1122 update_post_meta( $post_id, 'title_' . $locale, $the_title ); 1126 1123 } 1127 1124 1128 $the_excerpt = $this->translate_post_excerpt( $orig_excerpt, $post_id);1125 $the_excerpt = Plugin_I18n::instance()->translate( 'excerpt', $orig_excerpt, [ 'post_id' => $post_id, 'locale' => $locale ] ); 1129 1126 if ( $the_excerpt && $the_excerpt != $orig_excerpt ) { 1130 1127 update_post_meta( $post_id, 'excerpt_' . $locale, $the_excerpt ); … … 1135 1132 $sections = $this->split_post_content_into_pages( $orig_content ); 1136 1133 foreach ( $sections as $section => $section_content ) { 1137 $translated_section = $this->translate_post_content( $section_content, $section, $post_id);1134 $translated_section = Plugin_I18n::instance()->translate( $section, $section_content, [ 'post_id' => $post_id, 'locale' => $locale ] ); 1138 1135 if ( $translated_section && $translated_section != $section_content ) { 1139 1136 // ES expects the section delimiters to still be present … … 1149 1146 $existing_translated_titles = array_unique( get_post_meta( $post_id, 'block_title_' . $locale ) ); 1150 1147 foreach ( array_unique( get_post_meta( $post_id, 'block_title' ) ) as $block_title ) { 1151 $translated_title = Plugin_I18n::instance()->translate( 'block_title:' . md5( $block_title ), $block_title, [ 'post_id' => $post_id ] );1148 $translated_title = Plugin_I18n::instance()->translate( 'block_title:' . md5( $block_title ), $block_title, [ 'post_id' => $post_id, 'locale' => $locale ] ); 1152 1149 1153 1150 if ( $translated_title == $block_title ) {
Note: See TracChangeset
for help on using the changeset viewer.