diff --git src/bp-core/bp-core-actions.php src/bp-core/bp-core-actions.php
index caf628b97..cce575de3 100644
|
|
add_action( 'bp_after_setup_theme', 'bp_check_theme_template_pack_dependency', |
119 | 119 | add_action( 'bp_after_setup_theme', 'bp_load_theme_functions', 1 ); |
120 | 120 | add_action( 'bp_after_setup_theme', 'bp_register_theme_compat_default_features', 10 ); |
121 | 121 | |
| 122 | // Adds a new hook to be sure to enqueue scripts when `is_buddypress()` is true. |
| 123 | add_action( 'bp_enqueue_scripts', 'bp_enqueue_community_scripts' ); |
| 124 | |
122 | 125 | // Load the admin. |
123 | 126 | if ( is_admin() ) { |
124 | 127 | add_action( 'bp_loaded', 'bp_admin' ); |
diff --git src/bp-core/bp-core-cssjs.php src/bp-core/bp-core-cssjs.php
index 56b6c9f09..eeeadb8d4 100644
|
|
function bp_core_confirmation_js() { |
185 | 185 | ) ); |
186 | 186 | |
187 | 187 | } |
188 | | add_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' ); |
| 188 | add_action( 'bp_enqueue_community_scripts', 'bp_core_confirmation_js', 1 ); |
189 | 189 | add_action( 'bp_admin_enqueue_scripts', 'bp_core_confirmation_js' ); |
190 | 190 | |
191 | 191 | /** |
… |
… |
function bp_core_avatar_scripts() { |
206 | 206 | add_action( 'bp_after_group_admin_content', 'bp_avatar_template_check' ); |
207 | 207 | add_action( 'bp_after_group_avatar_creation_step', 'bp_avatar_template_check' ); |
208 | 208 | } |
209 | | add_action( 'bp_enqueue_scripts', 'bp_core_avatar_scripts' ); |
| 209 | add_action( 'bp_enqueue_community_scripts', 'bp_core_avatar_scripts' ); |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Enqueues the css and js required by the Cover Image UI. |
… |
… |
function bp_core_cover_image_scripts() { |
221 | 221 | // Enqueue the Attachments scripts for the Cover Image UI. |
222 | 222 | bp_attachments_enqueue_scripts( 'BP_Attachment_Cover_Image' ); |
223 | 223 | } |
224 | | add_action( 'bp_enqueue_scripts', 'bp_core_cover_image_scripts' ); |
| 224 | add_action( 'bp_enqueue_community_scripts', 'bp_core_cover_image_scripts' ); |
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Enqueues jCrop library and hooks BP's custom cropper JS. |
… |
… |
function bp_add_cover_image_inline_css( $return = false ) { |
522 | 522 | } |
523 | 523 | } |
524 | 524 | } |
525 | | add_action( 'bp_enqueue_scripts', 'bp_add_cover_image_inline_css', 11 ); |
| 525 | add_action( 'bp_enqueue_community_scripts', 'bp_add_cover_image_inline_css', 11 ); |
526 | 526 | |
527 | 527 | /** |
528 | 528 | * Enqueues livestamp.js on BuddyPress pages. |
… |
… |
add_action( 'bp_enqueue_scripts', 'bp_add_cover_image_inline_css', 11 ); |
530 | 530 | * @since 2.7.0 |
531 | 531 | */ |
532 | 532 | function bp_core_add_livestamp() { |
533 | | if ( ! is_buddypress() ) { |
534 | | return; |
535 | | } |
536 | | |
537 | 533 | bp_core_enqueue_livestamp(); |
538 | 534 | } |
539 | | add_action( 'bp_enqueue_scripts', 'bp_core_add_livestamp' ); |
| 535 | add_action( 'bp_enqueue_community_scripts', 'bp_core_add_livestamp' ); |
540 | 536 | |
541 | 537 | /** |
542 | 538 | * Enqueue and localize livestamp.js script. |
diff --git src/bp-core/bp-core-dependency.php src/bp-core/bp-core-dependency.php
index 91d2566b3..5e3df5429 100644
|
|
function bp_enqueue_scripts() { |
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
502 | | * Fires the 'bp_enqueue_embed_scripts' action in the <head> for BP oEmbeds. |
| 502 | * Fires an action hook to enqueue scripts and styles for specific BuddyPress contexts. |
503 | 503 | * |
504 | | * @since 2.6.0 |
| 504 | * @since 11.0.0 |
| 505 | * |
| 506 | * @param string $context The specific BuddyPress context. Supported values are `embed` and `community`. |
| 507 | * Default: `embed`. |
505 | 508 | */ |
506 | | function bp_enqueue_embed_scripts() { |
| 509 | function bp_enqueue_context_scripts( $context = 'embed' ) { |
507 | 510 | if ( ! is_buddypress() ) { |
508 | 511 | return; |
509 | 512 | } |
510 | 513 | |
511 | 514 | /** |
512 | | * Enqueue CSS and JS files for BuddyPress embeds. |
| 515 | * Enqueue CSS and JS files for a specific BuddyPress context. |
513 | 516 | * |
514 | | * @since 2.6.0 |
| 517 | * @since 11.0.0 |
515 | 518 | */ |
516 | | do_action( 'bp_enqueue_embed_scripts' ); |
| 519 | do_action( "bp_enqueue_{$context}_scripts" ); |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Fires the 'bp_enqueue_embed_scripts' action in the <head> for BP oEmbeds. |
| 524 | * |
| 525 | * @since 2.6.0 |
| 526 | */ |
| 527 | function bp_enqueue_embed_scripts() { |
| 528 | return bp_enqueue_context_scripts( 'embed' ); |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Fires the `bp_enqueue_community_scripts` action for Template packs scripts and styles. |
| 533 | * |
| 534 | * @since 11.0.0 |
| 535 | */ |
| 536 | function bp_enqueue_community_scripts() { |
| 537 | return bp_enqueue_context_scripts( 'community' ); |
517 | 538 | } |
518 | 539 | |
519 | 540 | /** |
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
index dd9ca60bd..76d6d3108 100644
|
|
class BP_Legacy extends BP_Theme_Compat { |
80 | 80 | |
81 | 81 | /** Scripts ***********************************************************/ |
82 | 82 | |
83 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS |
84 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS |
85 | | add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization |
| 83 | add_action( 'bp_enqueue_community_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS |
| 84 | add_action( 'bp_enqueue_community_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS |
| 85 | add_action( 'bp_enqueue_community_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization |
86 | 86 | |
87 | 87 | /** Body no-js Class **************************************************/ |
88 | 88 | |
diff --git src/bp-templates/bp-nouveau/buddypress-functions.php src/bp-templates/bp-nouveau/buddypress-functions.php
index fac582cab..685e2b93f 100644
|
|
class BP_Nouveau extends BP_Theme_Compat { |
178 | 178 | |
179 | 179 | // Scripts & Styles. |
180 | 180 | $registration_params = array( |
181 | | 'hook' => 'bp_enqueue_scripts', |
| 181 | 'hook' => 'bp_enqueue_community_scripts', |
182 | 182 | 'priority' => 2, |
183 | 183 | ); |
184 | 184 | |
… |
… |
class BP_Nouveau extends BP_Theme_Compat { |
195 | 195 | add_action( $registration_params['hook'], array( $this, 'register_scripts' ), $registration_params['priority'] ); |
196 | 196 | |
197 | 197 | // Enqueue theme CSS. |
198 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
| 198 | add_action( 'bp_enqueue_community_scripts', array( $this, 'enqueue_styles' ) ); |
199 | 199 | |
200 | 200 | // Enqueue theme JS. |
201 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 201 | add_action( 'bp_enqueue_community_scripts', array( $this, 'enqueue_scripts' ) ); |
202 | 202 | |
203 | 203 | // Enqueue theme script localization. |
204 | | add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); |
205 | | remove_action( 'bp_enqueue_scripts', 'bp_core_confirmation_js' ); |
| 204 | add_action( 'bp_enqueue_community_scripts', array( $this, 'localize_scripts' ) ); |
| 205 | remove_action( 'bp_enqueue_community_scripts', 'bp_core_confirmation_js', 1 ); |
206 | 206 | |
207 | 207 | // Body no-js class. |
208 | 208 | add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 ); |