Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/01/2016 10:39:41 PM (8 years ago)
Author:
r-a-y
Message:

Activity Embeds: Use CSS asset file for inline CSS.

Previously, we were using a template part to grab the inline CSS. This
is not a great idea.

Instead, we are using the actual CSS file and including it inline.

See #7104, #6772.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-embeds.php

    r10853 r10864  
    5555 * Add inline styles for BP activity embeds.
    5656 *
    57  * This is subject to change or be removed entirely for a different system.
    58  * Potentially for BP_Legacy::locate_asset_in_stack().
    59  *
    6057 * @since  2.6.0
    61  * @access private
    62  */
    63 function _bp_activity_embed_add_inline_styles() {
     58 */
     59function bp_activity_embed_add_inline_styles() {
    6460    if ( false === bp_is_single_activity() ) {
    6561        return;
    6662    }
    6763
    68     ob_start();
     64    $min = bp_core_get_minified_asset_suffix();
     65
    6966    if ( is_rtl() ) {
    70         bp_get_asset_template_part( 'embeds/css-activity', 'rtl' );
     67        $css = bp_locate_template_asset( "assets/embeds/activity-rtl{$min}.css" );
    7168    } else {
    72         bp_get_asset_template_part( 'embeds/css-activity' );
    73     }
    74     $css = ob_get_clean();
    75 
    76     // Rudimentary CSS protection.
     69        $css = bp_locate_template_asset( "assets/embeds/activity{$min}.css" );
     70    }
     71
     72    // Bail if file wasn't found.
     73    if ( false === $css ) {
     74        return;
     75    }
     76
     77    // Grab contents of CSS file and do some rudimentary CSS protection.
     78    $css = file_get_contents( $css['file'] );
    7779    $css = wp_kses( $css, array( "\'", '\"' ) );
    7880
    7981    printf( '<style type="text/css">%s</style>', $css );
    8082}
    81 add_action( 'embed_head', '_bp_activity_embed_add_inline_styles', 20 );
     83add_action( 'embed_head', 'bp_activity_embed_add_inline_styles', 20 );
    8284
    8385/**
Note: See TracChangeset for help on using the changeset viewer.