's * Remove inline CSS used by Recent Comments widget * Remove inline CSS used by posts with galleries * Remove self-closing tag and change ''s to "'s on rel_canonical() */ function roots_head_cleanup() { // Originally from http://wpengineer.com/1438/wordpress-header/ remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); global $wp_widget_factory; remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); add_filter('use_default_gallery_style', '__return_null'); if (!class_exists('WPSEO_Frontend')) { remove_action('wp_head', 'rel_canonical'); add_action('wp_head', 'roots_rel_canonical'); } } function roots_rel_canonical() { global $wp_the_query; if (!is_singular()) { return; } if (!$id = $wp_the_query->get_queried_object_id()) { return; } $link = get_permalink($id); echo "\t\n"; } add_action('init', 'roots_head_cleanup'); /** * Remove the WordPress version from RSS feeds */ add_filter('the_generator', '__return_false'); /** * Clean up language_attributes() used in tag * * Change lang="en-US" to lang="en" * Remove dir="ltr" */ function roots_language_attributes() { $attributes = array(); $output = ''; if (function_exists('is_rtl')) { if (is_rtl() == 'rtl') { $attributes[] = 'dir="rtl"'; } } $lang = get_bloginfo('language'); if ($lang && $lang !== 'en-US') { $attributes[] = "lang=\"$lang\""; } else { $attributes[] = 'lang="en"'; } $output = implode(' ', $attributes); $output = apply_filters('roots_language_attributes', $output); return $output; } add_filter('language_attributes', 'roots_language_attributes'); /** * Clean up output of stylesheet tags */ function roots_clean_style_tag($input) { preg_match_all("!!", $input, $matches); // Only display media if it's print $media = $matches[3][0] === 'print' ? ' media="print"' : ''; return '' . "\n"; } add_filter('style_loader_tag', 'roots_clean_style_tag'); /** * Add and remove body_class() classes */ function roots_body_class($classes) { // Add post/page slug if (is_single() || is_page() && !is_front_page()) { $classes[] = basename(get_permalink()); } // Remove unnecessary classes $home_id_class = 'page-id-' . get_option('page_on_front'); $remove_classes = array( 'page-template-default', $home_id_class ); $classes = array_diff($classes, $remove_classes); return $classes; } add_filter('body_class', 'roots_body_class'); /** * Root relative URLs * * WordPress likes to use absolute URLs on everything - let's clean that up. * Inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/ * * You can enable/disable this feature in config.php: * current_theme_supports('root-relative-urls'); * * @author Scott Walkinshaw */ function roots_root_relative_url($input) { $output = preg_replace_callback( '!(https?://[^/|"]+)([^"]+)?!', create_function( '$matches', // If full URL is home_url("/") and this isn't a subdir install, return a slash for relative root 'if (isset($matches[0]) && $matches[0] === home_url("/") && str_replace("http://", "", home_url("/", "http"))==$_SERVER["HTTP_HOST"]) { return "/";' . // If domain is equal to home_url("/"), then make URL relative '} elseif (isset($matches[0]) && strpos($matches[0], home_url("/")) !== false) { return $matches[2];' . // If domain is not equal to home_url("/"), do not make external link relative '} else { return $matches[0]; };' ), $input ); return $output; } /** * Terrible workaround to remove the duplicate subfolder in the src of