Changeset 3468
- Timestamp:
- 06/19/2016 12:15:28 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3465 r3468 235 235 add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 ); 236 236 add_filter( 'the_title', array( $this, 'translate_post_title' ), 1, 2 ); 237 add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1 );237 add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1, 2 ); 238 238 } 239 239 … … 508 508 * @return string 509 509 */ 510 public function translate_post_title( $title, $post_id ) {510 public function translate_post_title( $title, $post_id = null ) { 511 511 $post = get_post(); 512 512 513 513 if ( $post instanceof \WP_Post && $post_id === $post->ID ) { 514 $title = Plugin_I18n::instance()->translate( 'title', $title );514 $title = Plugin_I18n::instance()->translate( 'title', $title, [ 'post_id' => $post ] ); 515 515 } 516 516 … … 522 522 * 523 523 * @param string $excerpt 524 * @param \WP_Post $post 524 525 * @return string 525 526 */ 526 public function translate_post_excerpt( $excerpt ) {527 return Plugin_I18n::instance()->translate( 'excerpt', $excerpt );527 public function translate_post_excerpt( $excerpt, $post ) { 528 return Plugin_I18n::instance()->translate( 'excerpt', $excerpt, [ 'post_id' => $post ] ); 528 529 } 529 530 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php
r3391 r3468 268 268 } 269 269 270 if ( !empty( $args['post_id'] ) && is_numeric( $args['post_id'] ) ) { 271 $topic = get_post( $args['post_id'] ); 272 } else { 273 global $post; 274 } 275 276 if ( empty( $post ) ) { 277 return $content; 278 } 279 280 if ( !empty( $args['locale'] ) ) { 270 $args = wp_parse_args( $args, [ 271 'post_id' => null, 272 'locale' => '', 273 ] ); 274 275 $post = get_post( $args['post_id'] ); 276 277 if ( ! $post ) { 278 return $content; 279 } 280 281 if ( ! empty( $args['locale'] ) ) { 281 282 $wp_locale = $args['locale']; 282 283 } else {
Note: See TracChangeset
for help on using the changeset viewer.