SHOW:
|
|
- or go back to the newest paste.
1 | // REMOVE WP-CONTENT | |
2 | // Rewrites DO NOT happen for child themes | |
3 | /* | |
4 | in case your wordpress is in a folder, | |
5 | and you change the site_url to the root of the domain, | |
6 | add the folder name in lines 29 to 34, | |
7 | i.e.: => 'YOUR-WP-FOLDER/wp-content/themes/' | |
8 | */ | |
9 | ||
10 | if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) { | |
11 | function roots_htaccess_writable() { | |
12 | if (!is_writable(get_home_path() . '.htaccess')) { | |
13 | add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">.htaccess</a> file is writeable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';")); | |
14 | }; | |
15 | } | |
16 | ||
17 | add_action('admin_init', 'roots_htaccess_writable'); | |
18 | ||
19 | // Rewrites DO NOT happen for child themes | |
20 | // rewrite /wp-content/themes/roots/css/ to /css/ | |
21 | // rewrite /wp-content/themes/roots/js/ to /js/ | |
22 | // rewrite /wp-content/themes/roots/img/ to /js/ | |
23 | // rewrite /wp-content/plugins/ to /plugins/ | |
24 | ||
25 | function roots_flush_rewrites() { | |
26 | global $wp_rewrite; | |
27 | $wp_rewrite->flush_rules(); | |
28 | } | |
29 | ||
30 | function roots_add_rewrites($content) { | |
31 | - | 'framework/(.*)' => 'wp-content/themes/'. $theme_name . '/framework/$1', |
31 | + | |
32 | - | 'images/(.*)' => 'wp-content/themes/'. $theme_name . '/images/$1', |
32 | + | |
33 | - | 'uploads/(.*)' => 'wp-content/uploads/$1', |
33 | + | |
34 | 'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1', | |
35 | 'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1', | |
36 | 'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1', | |
37 | 'plugins/(.*)' => 'wp-content/plugins/$1' | |
38 | ); | |
39 | $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules; | |
40 | } | |
41 | ||
42 | - | $theme_name = next(explode('/themes/', $content)); |
42 | + | |
43 | - | $current_path = '/wp-content/themes/' . $theme_name; |
43 | + | |
44 | - | $new_path = ''; |
44 | + | |
45 | - | $content = str_replace($current_path, $new_path, $content); |
45 | + | $theme_name = next(explode('/themes/', $content)); |
46 | - | return $content; |
46 | + | $current_path = '/wp-content/themes/' . $theme_name; |
47 | $new_path = ''; | |
48 | $content = str_replace($current_path, $new_path, $content); | |
49 | return $content; | |
50 | - | $current_path = '/wp-content/plugins'; |
50 | + | |
51 | - | $new_path = '/plugins'; |
51 | + | |
52 | - | $content = str_replace($current_path, $new_path, $content); |
52 | + | |
53 | - | return $content; |
53 | + | $current_path = '/wp-content/plugins'; |
54 | $new_path = '/plugins'; | |
55 | $content = str_replace($current_path, $new_path, $content); | |
56 | return $content; | |
57 | } | |
58 | ||
59 | // only use clean urls if the theme isn't a child or an MU (Network) install | |
60 | if (!is_multisite() && !is_child_theme()) { | |
61 | add_action('generate_rewrite_rules', 'roots_add_rewrites'); | |
62 | if (!is_admin()) { | |
63 | add_filter('plugins_url', 'roots_clean_plugins'); | |
64 | - | add_filter('script_loader_src', 'roots_clean_plugins'); |
64 | + | |
65 | - | add_filter('style_loader_src', 'roots_clean_plugins'); |
65 | + | |
66 | add_filter('template_directory_uri', 'roots_clean_assets'); | |
67 | } | |
68 | } | |
69 | ||
70 | function roots_add_h5bp_htaccess($rules) { | |
71 | global $wp_filesystem; | |
72 | ||
73 | if (!defined('FS_METHOD')) define('FS_METHOD', 'direct'); | |
74 | - | |
74 | + | |
75 | ||
76 | - | define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); |
76 | + | |
77 | define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); | |
78 | ||
79 | $theme_name = next(explode('/themes/', get_template_directory())); | |
80 | $filename = WP_CONTENT_DIR . '/themes/' . $theme_name . '/inc/h5bp-htaccess'; | |
81 | ||
82 | - | |
82 | + | |
83 | ||
84 | return $rules; | |
85 | } | |
86 | ||
87 | - | } |
87 | + | |
88 | } |