diff --git a/functions.php b/functions.php index 8f4e054..4e15a36 100644 --- a/functions.php +++ b/functions.php @@ -1,10 +1,9 @@ +?> \ No newline at end of file diff --git a/inc/roots-admin.php b/inc/roots-admin.php deleted file mode 100644 index 1678390..0000000 --- a/inc/roots-admin.php +++ /dev/null @@ -1,27 +0,0 @@ -

" . sprintf(__('Please update your site tagline', 'roots'), admin_url('options-general.php')) . "

';")); -}; - -// set the post revisions to 5 unless the constant -// was set in wp-config.php to avoid DB bloat -if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 5); - -// allow more tags in TinyMCE including iframes -function roots_change_mce_options($options) { - $ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]'; - if (isset($initArray['extended_valid_elements'])) { - $options['extended_valid_elements'] .= ',' . $ext; - } else { - $options['extended_valid_elements'] = $ext; - } - return $options; -} - -add_filter('tiny_mce_before_init', 'roots_change_mce_options'); - -?> diff --git a/inc/roots-cleanup.php b/inc/roots-cleanup.php index 03b6dfd..f7a0a31 100644 --- a/inc/roots-cleanup.php +++ b/inc/roots-cleanup.php @@ -1,58 +1,5 @@ flush_rules(); -} - -function roots_add_rewrites($content) { - $theme_name = next(explode('/themes/', get_stylesheet_directory())); - global $wp_rewrite; - $roots_new_non_wp_rules = array( - 'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1', - 'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1', - 'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1', - 'plugins/(.*)' => 'wp-content/plugins/$1' - ); - $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules; -} - -add_action('admin_init', 'roots_flush_rewrites'); - -function roots_clean_assets($content) { - $theme_name = next(explode('/themes/', $content)); - $current_path = '/wp-content/themes/' . $theme_name; - $new_path = ''; - $content = str_replace($current_path, $new_path, $content); - return $content; -} - -function roots_clean_plugins($content) { - $current_path = '/wp-content/plugins'; - $new_path = '/plugins'; - $content = str_replace($current_path, $new_path, $content); - return $content; -} - -// only use clean urls if the theme isn't a child or an MU (Network) install -if ((!defined('WP_ALLOW_MULTISITE') || (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE !== true)) && !is_child_theme()) { - add_action('generate_rewrite_rules', 'roots_add_rewrites'); - if (!is_admin()) { - add_filter('plugins_url', 'roots_clean_plugins'); - add_filter('bloginfo', 'roots_clean_assets'); - add_filter('stylesheet_directory_uri', 'roots_clean_assets'); - add_filter('template_directory_uri', 'roots_clean_assets'); - } -} - // redirect /?s to /search/ // http://txfx.net/wordpress-plugins/nice-search/ function roots_nice_search_redirect() { @@ -394,4 +341,59 @@ function roots_check_current($val) { return preg_match('/current-menu/', $val); } -?> +// add to robots.txt +// http://codex.wordpress.org/Search_Engine_Optimization_for_WordPress#Robots.txt_Optimization +function roots_robots() { + echo "Disallow: /cgi-bin\n"; + echo "Disallow: /wp-admin\n"; + echo "Disallow: /wp-includes\n"; + echo "Disallow: /wp-content/plugins\n"; + echo "Disallow: /plugins\n"; + echo "Disallow: /wp-content/cache\n"; + echo "Disallow: /wp-content/themes\n"; + echo "Disallow: /trackback\n"; + echo "Disallow: /feed\n"; + echo "Disallow: /comments\n"; + echo "Disallow: /category/*/*\n"; + echo "Disallow: */trackback\n"; + echo "Disallow: */feed\n"; + echo "Disallow: */comments\n"; + echo "Disallow: /*?*\n"; + echo "Disallow: /*?\n"; + echo "Allow: /wp-content/uploads\n"; + echo "Allow: /assets"; +} + +add_action('do_robots', 'roots_robots'); + +function roots_author_link($link) { + return str_replace('

site tagline', 'roots'), admin_url('options-general.php')) . "

';")); +}; + +// set the post revisions to 5 unless the constant +// was set in wp-config.php to avoid DB bloat +if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 5); + +// allow more tags in TinyMCE including iframes +function roots_change_mce_options($options) { + $ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]'; + if (isset($initArray['extended_valid_elements'])) { + $options['extended_valid_elements'] .= ',' . $ext; + } else { + $options['extended_valid_elements'] = $ext; + } + return $options; +} + +add_filter('tiny_mce_before_init', 'roots_change_mce_options'); + +?> \ No newline at end of file diff --git a/inc/roots-htaccess.php b/inc/roots-htaccess.php index d24393f..9a24b62 100644 --- a/inc/roots-htaccess.php +++ b/inc/roots-htaccess.php @@ -8,6 +8,59 @@ function roots_htaccess_writable() { add_action('admin_init', 'roots_htaccess_writable'); +$theme_name = next(explode('/themes/', get_stylesheet_directory())); + +// Rewrites DO NOT happen for child themes +// rewrite /wp-content/themes/roots/css/ to /css/ +// rewrite /wp-content/themes/roots/js/ to /js/ +// rewrite /wp-content/themes/roots/img/ to /js/ +// rewrite /wp-content/plugins/ to /plugins/ + +function roots_flush_rewrites() { + global $wp_rewrite; + $wp_rewrite->flush_rules(); +} + +function roots_add_rewrites($content) { + $theme_name = next(explode('/themes/', get_stylesheet_directory())); + global $wp_rewrite; + $roots_new_non_wp_rules = array( + 'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1', + 'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1', + 'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1', + 'plugins/(.*)' => 'wp-content/plugins/$1' + ); + $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules; +} + +add_action('admin_init', 'roots_flush_rewrites'); + +function roots_clean_assets($content) { + $theme_name = next(explode('/themes/', $content)); + $current_path = '/wp-content/themes/' . $theme_name; + $new_path = ''; + $content = str_replace($current_path, $new_path, $content); + return $content; +} + +function roots_clean_plugins($content) { + $current_path = '/wp-content/plugins'; + $new_path = '/plugins'; + $content = str_replace($current_path, $new_path, $content); + return $content; +} + +// only use clean urls if the theme isn't a child or an MU (Network) install +if ((!defined('WP_ALLOW_MULTISITE') || (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE !== true)) && !is_child_theme()) { + add_action('generate_rewrite_rules', 'roots_add_rewrites'); + if (!is_admin()) { + add_filter('plugins_url', 'roots_clean_plugins'); + add_filter('bloginfo', 'roots_clean_assets'); + add_filter('stylesheet_directory_uri', 'roots_clean_assets'); + add_filter('template_directory_uri', 'roots_clean_assets'); + } +} + function roots_add_h5bp_htaccess($rules) { global $wp_filesystem;