Created
March 26, 2018 12:17
-
-
Save ApoGouv/1755b9d4621e6c687c39e85c46b5e5c2 to your computer and use it in GitHub Desktop.
WP - Rewrites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mask_theme_files_urls() { | |
$theme_name = next(explode('/themes/', get_stylesheet_directory())); | |
global $wp_rewrite; | |
$new_non_wp_rules = array( | |
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1', | |
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1', | |
'images/wordpress-urls-rewrite/(.*)' => 'wp-content/themes/'. $theme_name . '/images/wordpress-urls-rewrite/$1', | |
); | |
$wp_rewrite->non_wp_rules += $new_non_wp_rules; | |
} | |
add_action('generate_rewrite_rules', 'mask_theme_files_urls'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment