BP_Nouveau::register_scripts()
Register Template Pack JavaScript files
Description Description
Source Source
File: bp-templates/bp-nouveau/buddypress-functions.php
public function register_scripts() {
$min = bp_core_get_minified_asset_suffix();
$dependencies = bp_core_get_js_dependencies();
$bp_confirm = array_search( 'bp-confirm', $dependencies );
unset( $dependencies[ $bp_confirm ] );
/**
* Filters the scripts to enqueue for BuddyPress Nouveau.
*
* This filter provides a multidimensional array that will map to arguments used for wp_register_script().
* The primary index should have the script handle to use, and be assigned an array that has indexes for
* file location, dependencies, version and if it should load in the footer or not.
*
* @since 3.0.0
*
* @param array $value Array of scripts to register.
*/
$scripts = apply_filters( 'bp_nouveau_register_scripts', array(
'bp-nouveau' => array(
'file' => 'js/buddypress-nouveau%s.js',
'dependencies' => $dependencies,
'version' => $this->version,
'footer' => true,
),
) );
// Bail if no scripts
if ( empty( $scripts ) ) {
return;
}
// Add The password verify if needed.
if ( bp_is_active( 'settings' ) || bp_get_signup_allowed() ) {
/**
* BP Nouveau is now directly using the `wp-admin/js/user-profile.js` script.
*
* Setting the user password is now more consistent with how WordPress handles it.
*
* @deprecated 5.0.0
*/
$scripts['bp-nouveau-password-verify'] = array(
'file' => 'js/password-verify%s.js',
'dependencies' => array( 'bp-nouveau', 'password-strength-meter' ),
'footer' => true,
);
}
foreach ( $scripts as $handle => $script ) {
if ( ! isset( $script['file'] ) ) {
continue;
}
$file = sprintf( $script['file'], $min );
// Locate the asset if needed.
if ( false === strpos( $script['file'], '://' ) ) {
$asset = bp_locate_template_asset( $file );
if ( empty( $asset['uri'] ) || false === strpos( $asset['uri'], '://' ) ) {
continue;
}
$file = $asset['uri'];
}
$data = bp_parse_args(
$script,
array(
'dependencies' => array(),
'version' => $this->version,
'footer' => false,
),
'nouveau_register_scripts'
);
wp_register_script( $handle, $file, $data['dependencies'], $data['version'], $data['footer'] );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |