Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_bp_redirect_assets() {
- $uri = wp_guess_url();
- $bp_default_url = constant( 'BP_PLUGIN_URL' ) . 'bp-themes/bp-default/';
- // try to find a file extension; if none, stop now!
- if ( strpos( $uri, '.' ) === false ) {
- return;
- }
- // see if we're attempting to access a bp-default URL
- if ( strpos( $uri, $bp_default_url ) === false ) {
- return;
- }
- // get bp-default dir in regular theme directory
- $new_bp_default_dir = get_theme_root( 'bp-default' );
- $new_bp_default_dir = "{$new_bp_default_dir}/bp-default";
- // downloaded bp-default from theme repo doesn't exist
- if ( ! is_dir( $new_bp_default_dir ) ) {
- return;
- }
- // get the relative resource
- $resource = str_replace( $bp_default_url, '', $uri );
- /*
- // do checks for specific resources here if desired
- switch ( $resource ) {
- }
- */
- /*
- // check if file exists at new location
- if ( ! file_exists( $new_bp_default_dir . '/' . $resource ) ) {
- return;
- }
- */
- // redirect the resource to new bp-default location
- wp_safe_redirect( content_url( '/themes/bp-default/' . $resource ), 307 );
- die();
- }
- add_action( 'bp_loaded', 'my_bp_redirect_assets' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement