[buddypress-trac] [BuddyPress Trac] #9304: 'no-js' body class not being added correctly since BuddyPress 12.1.0
buddypress-trac
noreply at wordpress.org
Wed Jun 3 15:38:04 UTC 2026
#9304: 'no-js' body class not being added correctly since BuddyPress 12.1.0
--------------------------+--------------------------
Reporter: r-a-y | Owner: espellcaste
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 14.5.0
Component: Templates | Version: 12.1.1
Severity: normal | Resolution:
Keywords: has-patch |
--------------------------+--------------------------
Changes (by emaralive):
* status: closed => reopened
* resolution: fixed =>
Comment:
Reopened due an incomplete assessment of the efficacy of the initial
patch. It turns out that the boolean operator used for a conditional check
should have been `&&` (AND) as opposed to `||` (OR). The below snippet
represents the current coding with the `OR` operator.
{{{
public function add_nojs_body_class( $classes ) {
/** This filter is documented in bp-core/bp-core-dependency.php */
if ( ! is_buddypress() || apply_filters(
'bp_enqueue_assets_in_bp_pages_only', true ) ) {
return $classes;
}
$classes[] = 'no-js';
return array_unique( $classes );
}
}}}
The following is that table that supports a simple truth table to
illustrate the issue at hand:
A = ! is_buddypress() - true when on a non !BuddyPress page and false when
on a !BuddyPress page
B = apply_filters( 'bp_enqueue_assets_in_bp_pages_only', true ) - true
when only enqueue on BP pages, false on any page
T = true
F = false
R = result - true when `no-js` is added to the body class, otherwise false
The below truth table represent the situation with the `OR` operator.
||= A =||= B =||= R =||
|| T || T || F ||
|| T || F || F ||
|| F || T || F ||
|| F || F || T ||
So, the only state in which `no-js` is added to the body class is when on
a BP page (A is false) and when the filter hook
`bp_enqueue_assets_in_bp_pages_only` is false (B is false).
The top image (without patch) from the screenshot (9304-without-
patch_with-patch.png) represents the truth table state of when on a BP
page (A is false) and when the filter hook
`bp_enqueue_assets_in_bp_pages_only` is false (B is true).
Changing the boolean operator from `OR` to `AND`, produces the following
truth table which produces the desired outcome for each state. The bottom
image (with patch) from the screenshot (9304-without-patch_with-patch.png)
represents the truth table state of when on a BP page (A is false) and
when the filter hook `bp_enqueue_assets_in_bp_pages_only` is false (B is
true).
||= A =||= B =||= R =||
|| T || T || F ||
|| T || F || T ||
|| F || T || T ||
|| F || F || T ||
[[span(style=color: #FF0000, NOTE:)]] attachment 9304.02.patch supersedes
attachment 9304.01.patch.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9304#comment:5>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list