Skip to content

Instantly share code, notes, and snippets.

@ApoGouv
Created March 26, 2018 12:17
Show Gist options
  • Save ApoGouv/1755b9d4621e6c687c39e85c46b5e5c2 to your computer and use it in GitHub Desktop.
Save ApoGouv/1755b9d4621e6c687c39e85c46b5e5c2 to your computer and use it in GitHub Desktop.
WP - Rewrites
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