diff --git a/inc/cleanup.php b/inc/cleanup.php index cb6728a..b0084d3 100644 --- a/inc/cleanup.php +++ b/inc/cleanup.php @@ -13,9 +13,11 @@ add_action('template_redirect', 'roots_nice_search_redirect'); function roots_search_query($escaped = true) { $query = apply_filters('roots_search_query', get_query_var('s')); + if ($escaped) { - $query = esc_attr($query); + $query = esc_attr($query); } + return urldecode($query); } @@ -25,8 +27,9 @@ add_filter('get_search_query', 'roots_search_query'); // http://wordpress.org/support/topic/blank-search-sends-you-to-the-homepage#post-1772565 function roots_request_filter($query_vars) { if (isset($_GET['s']) && empty($_GET['s'])) { - $query_vars['s'] = " "; + $query_vars['s'] = ' '; } + return $query_vars; } @@ -49,6 +52,7 @@ function roots_root_relative_url($input) { ), $input ); + return $output; } @@ -57,11 +61,13 @@ function roots_root_relative_url($input) { function roots_fix_duplicate_subfolder_urls($input) { $output = roots_root_relative_url($input); preg_match_all('!([^/]+)/([^/]+)!', $output, $matches); + if (isset($matches[1]) && isset($matches[2])) { if ($matches[1][0] === $matches[2][0]) { $output = substr($output, strlen($matches[1][0]) + 1); } } + return $output; } @@ -111,6 +117,7 @@ if (enable_root_relative_urls()) { function roots_language_attributes() { $attributes = array(); $output = ''; + if (function_exists('is_rtl')) { if (is_rtl() == 'rtl') { $attributes[] = 'dir="rtl"'; @@ -118,6 +125,7 @@ function roots_language_attributes() { } $lang = get_bloginfo('language'); + if ($lang && $lang !== 'en-US') { $attributes[] = "lang=\"$lang\""; } else { @@ -126,6 +134,7 @@ function roots_language_attributes() { $output = implode(' ', $attributes); $output = apply_filters('roots_language_attributes', $output); + return $output; } @@ -133,6 +142,7 @@ add_filter('language_attributes', 'roots_language_attributes'); // remove WordPress version from RSS feed function roots_no_generator() { return ''; } + add_filter('the_generator', 'roots_no_generator'); // cleanup wp_head @@ -143,11 +153,12 @@ function roots_noindex() { } function roots_rel_canonical() { + global $wp_the_query; + if (!is_singular()) { return; } - global $wp_the_query; if (!$id = $wp_the_query->get_queried_object_id()) { return; } @@ -159,6 +170,7 @@ function roots_rel_canonical() { // remove CSS from recent comments widget function roots_remove_recent_comments_style() { global $wp_widget_factory; + if (isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])) { remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); } @@ -203,6 +215,7 @@ function roots_gallery_shortcode($attr) { // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); + if ($output != '') { return $output; } @@ -228,7 +241,8 @@ function roots_gallery_shortcode($attr) { ), $attr)); $id = intval($id); - if ('RAND' == $order) { + + if ($order === 'RAND') { $orderby = 'none'; } @@ -259,19 +273,20 @@ function roots_gallery_shortcode($attr) { } $captiontag = tag_escape($captiontag); - $columns = intval($columns); - $itemwidth = $columns > 0 ? floor(100/$columns) : 100; - $float = is_rtl() ? 'right' : 'left'; - - $selector = "gallery-{$instance}"; + $columns = intval($columns); + $itemwidth = $columns > 0 ? floor(100/$columns) : 100; + $float = is_rtl() ? 'right' : 'left'; + $selector = "gallery-{$instance}"; $gallery_style = $gallery_div = ''; + if (apply_filters('use_default_gallery_style', true)) { - $gallery_style = ""; + $gallery_style = ''; } - $size_class = sanitize_html_class($size); + + $size_class = sanitize_html_class($size); $gallery_div = "