SHOW:
|
|
- or go back to the newest paste.
1 | function my_bp_redirect_assets() { | |
2 | $uri = wp_guess_url(); | |
3 | $bp_default_url = constant( 'BP_PLUGIN_URL' ) . 'bp-themes/bp-default/'; | |
4 | ||
5 | // try to find a file extension; if none, stop now! | |
6 | if ( strpos( $uri, '.' ) === false ) { | |
7 | return; | |
8 | } | |
9 | ||
10 | // see if we're attempting to access a bp-default URL | |
11 | if ( strpos( $uri, $bp_default_url ) === false ) { | |
12 | return; | |
13 | } | |
14 | ||
15 | // get bp-default dir in regular theme directory | |
16 | $new_bp_default_dir = get_theme_root( 'bp-default' ); | |
17 | - | $new_bp_default_dir = "{$bp_default_dir}/bp-default"; |
17 | + | $new_bp_default_dir = "{$new_bp_default_dir}/bp-default"; |
18 | ||
19 | // downloaded bp-default from theme repo doesn't exist | |
20 | if ( ! is_dir( $new_bp_default_dir ) ) { | |
21 | return; | |
22 | } | |
23 | ||
24 | // get the relative resource | |
25 | $resource = str_replace( $bp_default_url, '', $uri ); | |
26 | ||
27 | /* | |
28 | // do checks for specific resources here if desired | |
29 | switch ( $resource ) { | |
30 | ||
31 | } | |
32 | */ | |
33 | ||
34 | /* | |
35 | // check if file exists at new location | |
36 | if ( ! file_exists( $new_bp_default_dir . '/' . $resource ) ) { | |
37 | return; | |
38 | } | |
39 | */ | |
40 | ||
41 | // redirect the resource to new bp-default location | |
42 | wp_safe_redirect( content_url( '/themes/bp-default/' . $resource ), 307 ); | |
43 | die(); | |
44 | } | |
45 | add_action( 'bp_loaded', 'my_bp_redirect_assets' ); |