Changeset 10119
- Timestamp:
- 08/05/2020 04:25:59 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
r10116 r10119 1107 1107 * @param string $locale Locale to translate. 1108 1108 */ 1109 public function sync_translation_to_meta( $post_id, $_locale ) { 1110 global $locale; 1111 1112 $old_locale = $locale; 1109 public function sync_translation_to_meta( $post_id, $locale ) { 1113 1110 // Keep track of the original untranslated strings 1114 1111 $orig_title = get_the_title( $post_id ); 1115 1112 $orig_excerpt = get_the_excerpt( $post_id ); 1116 1113 $orig_content = get_post_field( 'post_content', $post_id ); 1117 $locale = $_locale;1118 1114 1119 1115 // Update postmeta values for the translated title, excerpt, and content, if they are available and different from the originals. … … 1144 1140 } 1145 1141 1146 $locale = $old_locale; 1142 // Translate Block Titles. A bit more complicated as there's multiple postmeta values. 1143 $existing_translated_titles = array_unique( get_post_meta( $post_id, 'block_title_' . $locale ) ); 1144 foreach ( array_unique( get_post_meta( $post_id, 'block_title' ) ) as $block_title ) { 1145 $translated_title = Plugin_I18n::instance()->translate( 'block_title:' . md5( $block_title ), $block_title, [ 'post_id' => $post_id ] ); 1146 1147 if ( $translated_title == $block_title ) { 1148 continue; 1149 } 1150 1151 if ( false !== ( $pos = array_search( $translated_title, $existing_translated_titles, true ) ) ) { 1152 // If translation is meta'd, skip 1153 unset( $existing_translated_titles[ $pos ] ); 1154 } else { 1155 // If tranlation is unknown, add it. 1156 add_post_meta( $post_id, 'block_title_' . $locale, $translated_title ); 1157 } 1158 } 1159 // Delete any unknown translations. 1160 foreach ( $existing_translated_titles as $block_title ) { 1161 delete_post_meta( $post_id, 'block_title_' . $locale, $block_title ); 1162 } 1147 1163 } 1148 1164
Note: See TracChangeset
for help on using the changeset viewer.