205 | | // Check parent theme |
206 | | } elseif ( file_exists( trailingslashit( get_template_directory() ) . $file ) ) { |
207 | | $location = trailingslashit( get_template_directory_uri() ); |
208 | | $handle = 'bp-parent-css'; |
209 | | |
210 | | // BuddyPress Theme Compatibility |
211 | | } else { |
212 | | $location = trailingslashit( $this->url ); |
213 | | $handle = 'bp-legacy-css'; |
| 203 | // Enqueue BuddyPress-specific styling, if found |
| 204 | if ( isset( $asset['location'], $asset['handle'] ) ) { |
| 205 | wp_enqueue_style( $asset['handle'], $asset['location'], array(), $this->version, 'screen' ); |
235 | | // Check parent theme |
236 | | } elseif ( file_exists( trailingslashit( get_template_directory() ) . $file ) ) { |
237 | | $location = trailingslashit( get_template_directory_uri() ); |
238 | | $handle = 'bp-parent-js'; |
239 | | |
240 | | // BuddyPress Theme Compatibility |
241 | | } else { |
242 | | $location = trailingslashit( $this->url ); |
243 | | $handle = 'bp-legacy-js'; |
| 221 | // Enqueue the global JS, if found - AJAX will not work |
| 222 | // without it |
| 223 | if ( isset( $asset['location'], $asset['handle'] ) ) { |
| 224 | wp_enqueue_script( $asset['handle'], $asset['location'], array( 'jquery' ), $this->version ); |
| 251 | * Get the URL and handle of a web-accessible CSS or JS asset |
| 252 | * |
| 253 | * We provide two levels of customizability with respect to where CSS |
| 254 | * and JS files can be stored: (1) the child theme/parent theme/theme |
| 255 | * compat hierarchy, and (2) the "template stack" of /buddypress/css/, |
| 256 | * /community/css/, and /css/. In this way, CSS and JS assets can be |
| 257 | * overloaded, and default versions provided, in exactly the same way |
| 258 | * as corresponding PHP templates. |
| 259 | * |
| 260 | * We are duplicating some of the logic that is currently found in |
| 261 | * bp_locate_template() and the _template_stack() functions. Those |
| 262 | * functions were built with PHP templates in mind, and will require |
| 263 | * refactoring in order to provide "stack" functionality for assets |
| 264 | * that must be accessible both using file_exists() (the file path) |
| 265 | * and at a public URI. |
| 266 | * |
| 267 | * This method is marked private, with the understanding that the |
| 268 | * implementation is subject to change or removal in an upcoming |
| 269 | * release, in favor of a unified _template_stack() system. Plugin |
| 270 | * and theme authors should not attempt to use what follows. |
| 271 | * |
| 272 | * @since BuddyPress (1.8) |
| 273 | * @access private |
| 274 | * @param string $file A filename like buddypress.cs |
| 275 | * @param string $type css|js |
| 276 | * @return array An array of data for the wp_enqueue_* function: |
| 277 | * 'handle' (eg 'bp-child-css') and a 'location' (the URI of the |
| 278 | * asset) |
| 279 | */ |
| 280 | private function locate_asset_in_stack( $file, $type = 'css' ) { |
| 281 | // Child, parent, theme compat |
| 282 | $locations = array( |
| 283 | 'bp-child' => array( |
| 284 | 'dir' => get_stylesheet_directory(), |
| 285 | 'uri' => get_stylesheet_directory_uri(), |
| 286 | ), |
| 287 | 'bp-parent' => array( |
| 288 | 'dir' => get_template_directory(), |
| 289 | 'uri' => get_template_directory_uri(), |
| 290 | ), |
| 291 | 'bp-legacy' => array( |
| 292 | 'dir' => bp_get_theme_compat_dir(), |
| 293 | 'uri' => bp_get_theme_compat_url(), |
| 294 | ), |
| 295 | ); |
| 296 | |
| 297 | // Subdirectories within the top-level $locations directories |
| 298 | $subdirs = array( |
| 299 | 'buddypress/' . $type, |
| 300 | 'community/' . $type, |
| 301 | $type, |
| 302 | ); |
| 303 | |
| 304 | $retval = array(); |
| 305 | |
| 306 | foreach ( $locations as $location_type => $location ) { |
| 307 | foreach ( $subdirs as $subdir ) { |
| 308 | if ( file_exists( trailingslashit( $location['dir'] ) . trailingslashit( $subdir ) . $file ) ) { |
| 309 | $retval['location'] = trailingslashit( $location['uri'] ) . trailingslashit( $subdir ) . $file; |
| 310 | $retval['handle'] = $location_type . '-' . $type; |
| 311 | break 2; |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | return $retval; |
| 317 | } |
| 318 | |
| 319 | /** |