Changeset 3319
- Timestamp:
- 06/08/2016 02:55:55 AM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3293 r3319 217 217 if ( 'en_US' != get_locale() ) { 218 218 add_filter( 'get_term', array( __NAMESPACE__ . '\i18n', 'translate_term' ) ); 219 add_filter( 'the_content', array( $this, 'translate_post_content' ), 1, 2 ); 220 add_filter( 'the_title', array( $this, 'translate_post_title' ), 1, 2 ); 221 add_filter( 'get_the_excerpt', array( $this, 'translate_post_excerpt' ), 1 ); 219 222 } 220 223 … … 439 442 } 440 443 444 } 445 446 /** 447 * Returns the requested page's content, translated. 448 * 449 * @param string $content 450 * @return string 451 */ 452 public function translate_post_content( $content, $section = null ) { 453 if ( is_null( $section ) ) { 454 return $content; 455 } 456 return Plugin_i18n::instance()->translate( $section, $content ); 457 } 458 459 /** 460 * Returns the requested page's content, translated. 461 * 462 * @param string $content 463 * @return string 464 */ 465 public function translate_post_title( $title, $post_id ) { 466 if ( $post_id === get_post()->ID ) { 467 return Plugin_i18n::instance()->translate( 'title', $title ); 468 } 469 return $title; 470 } 471 472 /** 473 * Returns the requested page's excerpt, translated. 474 * 475 * @param string $content 476 * @return string 477 */ 478 public function translate_post_excerpt( $excerpt ) { 479 return Plugin_i18n::instance()->translate( 'excerpt', $excerpt ); 441 480 } 442 481
Note: See TracChangeset
for help on using the changeset viewer.