Skip to content

Instantly share code, notes, and snippets.

@pedrobachiega
Last active August 29, 2015 13:57
Show Gist options
  • Save pedrobachiega/9906863 to your computer and use it in GitHub Desktop.
Save pedrobachiega/9906863 to your computer and use it in GitHub Desktop.
Conjunto de utilidades para temas do Wordpress
<?php
// remove junk from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
// removes detailed login error information for security
add_filter('login_errors', create_function('$a', "return null;"));
// excludes pages from search results
function exclude_pages_from_search($query) {
if ( $query->is_search ) { $query->set('post_type', 'post'); }
return $query;
}
add_filter('pre_get_posts','exclude_pages_from_search');
// post thumbnail support
if ( function_exists('add_theme_support') ) {
add_theme_support('post-thumbnails');
set_post_thumbnail_size(240, 180, true);
}
// add featured image in RSS feeds
function featured_image_in_rss($content) {
global $post;
if ( has_post_thumbnail($post->ID) ) {
$content = '<div class="featured_image_post_rss">' . get_the_post_thumbnail($post->ID, array(240,9999), array('class' => ' alignleft')) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featured_image_in_rss'); //Add the filter for RSS feeds Excerpt
add_filter('the_content_feed', 'featured_image_in_rss'); //Add the filter for RSS feed content
// enables wigitized sidebars
if ( function_exists('register_sidebar') ) {
register_sidebar(array('name'=>'Sidebar',
'before_widget' => '<div id="%1$s" class="widget-area widget-sidebar">',
'after_widget' => '</div> <!-- widget #%1$s -->',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
// custom menu support
add_theme_support('menus');
if ( function_exists('register_nav_menus') ) {
register_nav_menus(array(
'header-menu' => 'Header Menu',
'footer-menu' => 'Footer Menu',
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment