Skip to content

Instantly share code, notes, and snippets.

@ken-muturi
Created November 17, 2013 05:07
Show Gist options
  • Save ken-muturi/7509519 to your computer and use it in GitHub Desktop.
Save ken-muturi/7509519 to your computer and use it in GitHub Desktop.
Base functions.php
<?php
add_theme_support('post-thumbnails');
register_nav_menu('primary', __('Primary Menus'));
add_filter('request', 'this_theme_feed_request');
function this_theme_feed_request($feeds)
{
if (isset($feeds['feed']))
{
$feeds['post_type'] = get_post_types();
}
return $feeds;
}
/**
* Attach a class to linked images' parent anchors
* e.g. a img => a.img img
*/
add_filter('the_content','give_linked_images_class');
function give_linked_images_class($html)
{
$classes = ' pull-right quote_sections_img '; // separated by spaces, e.g. 'img image-link'
$rel = 'rel="prettyPhoto"';
// check if there are already classes assigned to the anchor
if ( preg_match('#<img.*? class=.+?>#', $html) )
{
$html = preg_replace('#(<img.+)(class\=[\".+\"|\'.+\'])(.*>)#', '$1 class="' . $classes .'$3', $html);
}
else
{
$html = preg_replace('#(<img.*?)>#', '$1 class="' . $classes .'" '. $rel.' >', $html);
}
return $html;
}
add_filter( 'excerpt_more', 'this_theme_excerpt_more' );
function this_theme_excerpt_more( $more )
{
return ' <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">Continue reading &rarr;</a>';
}
add_filter( 'excerpt_length', 'this_theme_excerpt_length' );
function this_theme_excerpt_length( $length = null)
{
return (is_front_page()) ? 20 : 90;
}
add_filter( 'pre_get_posts', 'this_theme_add_custom_types' );
function this_theme_add_custom_types( $query )
{
if( is_tag() )
{
// this gets all post types:
$post_types = get_post_types();
// alternately, you can add just specific post types using this line instead of the above:
// $post_types = array( 'post', 'your_custom_type' );
$query->set( 'post_type', $post_types );
return $query;
}
}
function login_styles()
{
echo '<style type="text/css"> h1 a { background:#fbfbfb url('. get_template_directory_uri().'/img/logo.png) !important ; width: 391px !important; height: 86px; }</style>';
}
add_action('login_head', 'login_styles');
function remove_menus ()
{
global $menu;
$restricted = array(__('Links') , __('Settings') );
end ($menu);
while (prev($menu))
{
$value = explode(' ', $menu[key($menu)][0]);
if(in_array($value[0] != NULL ? $value[0]:"" , $restricted)){ unset($menu[key($menu)]); }
}
}
add_action('admin_menu', 'remove_menus');
function disable_default_dashboard_widgets()
{
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
//remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
//remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
remove_meta_box('dashboard_primary', 'dashboard', 'core');
remove_meta_box('dashboard_secondary', 'dashboard', 'core');
}
add_action('admin_menu', 'disable_default_dashboard_widgets');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment