| 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' ); |
| | 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 | |
| | 284 | // No need to check child if template == stylesheet |
| | 285 | if ( is_child_theme() ) { |
| | 286 | $locations['bp-child'] = array( |
| | 287 | 'dir' => get_stylesheet_directory(), |
| | 288 | 'uri' => get_stylesheet_directory_uri(), |
| | 289 | ); |
| | 290 | } |
| | 291 | |
| | 292 | $locations['bp-parent'] = array( |
| | 293 | 'dir' => get_template_directory(), |
| | 294 | 'uri' => get_template_directory_uri(), |
| | 295 | ); |
| | 296 | |
| | 297 | $locations['bp-legacy'] = array( |
| | 298 | 'dir' => bp_get_theme_compat_dir(), |
| | 299 | 'uri' => bp_get_theme_compat_url(), |
| | 300 | ); |
| | 301 | |
| | 302 | // Subdirectories within the top-level $locations directories |
| | 303 | $subdirs = array( |
| | 304 | 'buddypress/' . $type, |
| | 305 | 'community/' . $type, |
| | 306 | $type, |
| | 307 | ); |
| | 308 | |
| | 309 | $retval = array(); |
| | 310 | |
| | 311 | foreach ( $locations as $location_type => $location ) { |
| | 312 | foreach ( $subdirs as $subdir ) { |
| | 313 | if ( file_exists( trailingslashit( $location['dir'] ) . trailingslashit( $subdir ) . $file ) ) { |
| | 314 | $retval['location'] = trailingslashit( $location['uri'] ) . trailingslashit( $subdir ) . $file; |
| | 315 | $retval['handle'] = $location_type . '-' . $type; |
| | 316 | break 2; |
| | 317 | } |
| | 318 | } |
| | 319 | } |
| | 320 | |
| | 321 | return $retval; |
| | 322 | } |
| | 323 | |
| | 324 | /** |