Skip to:
Content

BuddyPress.org

Changeset 9243


Ignore:
Timestamp:
12/20/2014 07:58:37 PM (6 years ago)
Author:
djpaul
Message:

Suggestions: move the blog checks in bp_activity_maybe_load_mentions_scripts to a filter in the core component.

This reorganisation keeps the component-specific mentions checks in those specific components, rather than bundling everything into the Activity component as it had been.

See #5934

Location:
trunk/src
Files:
2 edited

Legend:

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

    r9194 r9243  
    6565 */
    6666function bp_activity_maybe_load_mentions_scripts() {
    67     $retval =
    68         bp_activity_do_mentions() &&
    69         bp_is_user_active() &&
    70         ( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() );
     67    $mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
     68    $load_mentions    = $mentions_enabled && ( bp_is_activity_component() || is_admin() );
    7169
    7270    /**
     
    7573     * @since BuddyPress (2.1.0)
    7674     *
    77      * @param bool $retval True to load mentions assets, false otherwise.
    78      */
    79     return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval );
     75     * @param bool $load_mentions True to load mentions assets, false otherwise.
     76     * @param bool $mentions_enabled True if mentions are enabled.
     77     */
     78    return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled );
    8079}
    8180
  • trunk/src/bp-core/bp-core-filters.php

    r9108 r9243  
    629629    return $edit_link;
    630630}
     631
     632/**
     633 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
     634 * mentions suggestions?
     635 *
     636 * @param bool $load_mentions True to load mentions assets, false otherwise.
     637 * @param bool $mentions_enabled True if mentions are enabled.
     638 * @return bool True if mentions scripts should be loaded.
     639 * @since BuddyPress (2.2.0)
     640 */
     641function bp_maybe_load_mentions_scripts_for_blog_content( $load_mentions, $mentions_enabled ) {
     642    if ( ! $mentions_enabled ) {
     643        return $load_mentions;
     644    }
     645
     646    if ( $load_mentions || ( bp_is_blog_page() && is_singular() && comments_open() ) ) {
     647        return true;
     648    }
     649
     650    return $load_mentions;
     651}
     652add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_maybe_load_mentions_scripts_for_blog_content', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.