Changeset 9016
- Timestamp:
- 07/02/2019 05:49:32 AM (6 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
r8946 r9016 969 969 return $content; 970 970 } 971 return Plugin_I18n::instance()->translate( $section, $content, [ 'post_id' => $post_id ] ); 971 972 $post = get_post( $post_id ); 973 974 // Only translate Plugin post objects 975 if ( $post && 'plugin' === $post->post_type ) { 976 return Plugin_I18n::instance()->translate( $section, $content, [ 'post_id' => $post_id ] ); 977 } 978 979 return $content; 972 980 } 973 981 … … 982 990 $post = get_post( $post_id ); 983 991 984 // The $post_id passed may be a Support Forum post ID, which thankfully is much higher than plugins ID's for now.985 if ( $post instanceof \WP_Post) {986 $title =Plugin_I18n::instance()->translate( 'title', $title, [ 'post_id' => $post ] );992 // Only translate Post type items. 993 if ( $post && $post->post_type === 'plugin' ) { 994 return Plugin_I18n::instance()->translate( 'title', $title, [ 'post_id' => $post ] ); 987 995 } 988 996 … … 998 1006 */ 999 1007 public function translate_post_excerpt( $excerpt, $post ) { 1000 return Plugin_I18n::instance()->translate( 'excerpt', $excerpt, [ 'post_id' => $post ] ); 1008 $post = get_post( $post ); 1009 1010 // Only translate Post type items. 1011 if ( $post && $post->post_type === 'plugin' ) { 1012 return Plugin_I18n::instance()->translate( 'excerpt', $excerpt, [ 'post_id' => $post ] ); 1013 } 1014 1015 return $excerpt; 1001 1016 } 1002 1017 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php
r8917 r9016 29 29 <div class="plugin-reviews"> 30 30 <?php 31 foreach ( $reviews as $review ) : 31 // Switch to the Support Forum so that Template functions that call get_post() work as intended. 32 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { 33 switch_to_blog( WPORG_SUPPORT_FORUMS_BLOGID ); 34 } 35 36 foreach ( $reviews as $review ) { 37 $GLOBALS['post'] = $review; // Override the_post(); 32 38 setup_postdata( $review ); 33 39 ?> … … 44 50 </div> 45 51 </article> 46 <?php endforeach; ?> 52 <?php 53 } 54 55 // Reset back to the plugin post. 56 wp_reset_postdata(); 57 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { 58 restore_current_blog(); 59 } 60 ?> 47 61 </div> 48 <?php wp_reset_postdata(); ?>49 62 50 63 <a class="reviews-link" href="<?php echo esc_url( 'https://wordpress.org/support/plugin/' . get_post()->post_name . '/reviews/' ); ?>">
Note: See TracChangeset
for help on using the changeset viewer.