Skip to:
Content

BuddyPress.org

Changeset 12188


Ignore:
Timestamp:
07/10/2018 05:19:14 PM (19 months ago)
Author:
r-a-y
Message:

Attachments: Ensure older bp-default themes can still use the Backbone interface.

Since v3.0.0, bp-nouveau is the default template pack. However, for
themes still using a version of the bp-default theme, attempting to
upload results in a fatal error due to a Nouveau function not being
available.

To address this, for bp-default themes, we revert to using the more,
portable bp-legacy attachment template parts.

Props imath, r-a-y.

See #7905 (trunk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-attachments.php

    r11904 r12188  
    975975 */
    976976function bp_attachments_get_template_part( $slug ) {
    977     $attachment_template_part = 'assets/_attachments/' . $slug;
    978 
    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';
    982 
    983         // Check whether the template part exists.
    984         if ( ! file_exists( $attachment_admin_template_part ) ) {
    985             return false;
    986         }
    987 
    988         // Load the template part.
    989         require( $attachment_admin_template_part );
    990 
    991     // Load the attachment template in WP_USE_THEMES env.
    992     } else {
    993         bp_get_template_part( $attachment_template_part );
     977    $switched = false;
     978
     979    /*
     980     * Use bp-legacy attachment template part for older bp-default themes or if in
     981     * admin area.
     982     */
     983    if ( ! bp_use_theme_compat_with_current_theme() || ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) ) {
     984        $current = bp_get_theme_compat_id();
     985        if ( 'legacy' !== $current ) {
     986            $switched = true;
     987            bp_setup_theme_compat( 'legacy' );
     988        }
     989    }
     990
     991    // Load the template part.
     992    bp_get_template_part( 'assets/_attachments/' . $slug );
     993
     994    if ( $switched ) {
     995        bp_setup_theme_compat( $current );
    994996    }
    995997}
Note: See TracChangeset for help on using the changeset viewer.