bbp_locate_enqueueable( string $file = '' )
Locate an enqueueable file on the server. Used before being enqueued.
Description Description
If SCRIPT_DEBUG is set and the file includes a .min suffix, this function will automatically attempt to locate a non-minified version of that file.
If SCRIPT_DEBUG is not set and the file exclude a .min suffix, this function will automatically attempt to locate a minified version of that file.
Parameters Parameters
- $file
-
(Optional)
Default value: ''
Return Return
(boolean)
Source Source
File: includes/core/template-functions.php
function bbp_locate_enqueueable( $file = '' ) { // Bail if no file to locate if ( empty( $file ) ) { return false; } // Add file to files array $files = array( $file ); // Get the file variant (minified or not, but opposite of $file) $file_is_min = ( false !== strpos( $file, '.min' ) ); $file_variant = ( false === $file_is_min ) ? str_replace( array( '.css', '.js' ), array( '.min.css', '.min.js' ), $file ) : str_replace( '.min', '', $file ); // Are we debugging? $script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; // Debugging, so prefer unminified files if ( true === $script_debug ) { if ( true === $file_is_min ) { array_unshift( $files, $file_variant ); } else { array_push( $files, $file_variant ); } // Not debugging, so prefer minified files } elseif ( false === $script_debug ) { if ( true === $file_is_min ) { array_push( $files, $file_variant ); } else { array_unshift( $files, $file_variant ); } } // Return first found file location in the stack return bbp_locate_template( $files, false, false ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |