Skip to:
Content

BuddyPress.org

Ticket #7905: 7905.01.patch

File 7905.01.patch, 1.4 KB (added by r-a-y, 7 years ago)
  • src/bp-core/bp-core-attachments.php

     
    976976function bp_attachments_get_template_part( $slug ) {
    977977        $attachment_template_part = 'assets/_attachments/' . $slug;
    978978
    979         // Load the attachment template in WP Administration screens.
    980         if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    981                 $attachment_admin_template_part = buddypress()->themes_dir . '/bp-legacy/buddypress/' . $attachment_template_part . '.php';
     979        $switched = false;
    982980
    983                 // Check whether the template part exists.
    984                 if ( ! file_exists( $attachment_admin_template_part ) ) {
    985                         return false;
     981        /*
     982         * Use bp-legacy attachment template part for older bp-default themes or if in
     983         * admin area.
     984         */
     985        if ( ! bp_use_theme_compat_with_current_theme() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) ) {
     986                $current = bp_get_theme_compat_id();
     987                if ( 'legacy' !== $current ) {
     988                        bp_setup_theme_compat( 'legacy' );
    986989                }
     990        }
    987991
    988                 // Load the template part.
    989                 require( $attachment_admin_template_part );
     992        bp_get_template_part( $attachment_template_part );
    990993
    991         // Load the attachment template in WP_USE_THEMES env.
    992         } else {
    993                 bp_get_template_part( $attachment_template_part );
     994        if ( $switched ) {
     995                bp_setup_theme_compat( $current );
    994996        }
    995997}
    996998