Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Created July 20, 2012 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zodiac1978/3151032 to your computer and use it in GitHub Desktop.
Save Zodiac1978/3151032 to your computer and use it in GitHub Desktop.
My standard functions.php with many useful features
<?php
/* http://codex.wordpress.org/Customizing_the_Read_More */
function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');
/* hide admin bar */
function hide_admin_bar(){ return false; }
add_filter( 'show_admin_bar', 'hide_admin_bar' );
/* remove unncessary header infos */
function remove_header_info() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');
}
add_action('init', 'remove_header_info');
/* remove generator */
add_filter('the_generator', create_function('', 'return "";'));
/* Security: Hide Usernames from Classes */
/* Source: http://www.drweb.de/magazin/eine-wordpress-installation-korrekt-absichern/ */
function remove_comment_author_class ( $classes ) {
foreach ( $classes as $key=>$class ) {
if ( strstr ( $class,"comment-author-" ) ) {
unset ( $classes[$key] );
}
}
return $classes;
}
add_filter('comment_class','andys_remove_comment_author_class');
/* more secure login error message */
function explain_less_login_issues() { return 'FEHLER: Login falsch!';}
add_filter( 'login_errors', 'explain_less_login_issues' );
/* remove capital_P_dangit */
foreach( array( 'the_content', 'the_title', 'comment_text' ) as $filter )
remove_filter( $filter, 'capital_P_dangit' );
/* Link zur eigener Website im Footer des Adminbereichs */
add_filter( 'admin_footer_text', 'mein_admin_footer_text' );
function mein_admin_footer_text( $mein_text ) {
return 'Diese Website wird betreut von <a href="http://www.torstenlandsiedel.de">Torsten Landsiedel</a> | Powered by <a href="http://wpde.org">WordPress Deutschland</a>';
}
/* Update-Nachricht für Nicht-Admins ausblenden */
add_action( 'admin_init', 'hide_update_msg', 1 );
function hide_update_msg()
{
! current_user_can( 'install_plugins' )
and remove_action( 'admin_notices', 'update_nag', 3 );
}
/* Login-Logo anpassen */
function fb_custom_login_logo() {
$style = '<style type="text/css"> h1 a { background: transparent url(' . get_template_directory_uri() . '/images/IMAGENAME.png) no-repeat left top !important; margin-bottom: 15px;} </style>';
echo $style;
}
add_action( 'login_head', 'fb_custom_login_logo' );
/* Login-Header-Titel anpassen */
function fb_login_headertitle() {
$name = 'Torsten Landsiedel | Webwork';
return $name;
}
add_filter( 'login_headertitle', 'fb_login_headertitle' );
/* Login-Header-URL anpassen */
function the_url( $url ) {
return home_url();
}
add_filter( 'login_headerurl', 'the_url' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment