Making WordPress.org


Ignore:
Timestamp:
07/02/2019 05:49:32 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Reviews: Don't attempt to translate review titles/content, and switch to the Support Forums blog to ensure that template functions work as expected for Reviews.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php

    r8917 r9016  
    2929        <div class="plugin-reviews">
    3030            <?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();
    3238                setup_postdata( $review );
    3339                ?>
     
    4450                    </div>
    4551                </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        ?>
    4761        </div>
    48         <?php wp_reset_postdata(); ?>
    4962
    5063        <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.