Conquering the functions.php

language: PHP
license: Other

Code for Snippet:

                
//Remove From Header
 
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');
 
// Login Screen Logo
 
function site_custom_login_logo()  
{  
    echo '<style  type="text/css"> h1 a {  background-image:url('.get_bloginfo('template_directory').'/images/logo.png)  !important; } </style>';  
}  
add_action('login_head',  'site_custom_login_logo');
 
// Admin footer modification
 
function remove_footer_admin ()
{
    echo '<span id="footer-thankyou">Developed by <a href="http://www.wpthemesbuilder.com" target="_blank">WP Themes Builder</a></span>';
}
add_filter('admin_footer_text', 'remove_footer_admin');
 
/**
 * Security Options
 */
 //Remove Login Errors 
 
function failed_login () {
    return 'the login information you have entered is incorrect.';
}
add_filter( 'login_errors', 'failed_login' );
 
//Disallow File Editors
define ( 'DISALLOW_FILE_EDIT', true );
 
// Remove Wordpress Version
function remove_wp_version () {
    return '';
}
add_filter ( 'the_generator', 'remove_wp_version' );
 
/**
 * Remove Wordpress Formating
 */
 
function my_formatter($content) {
       $new_content = '';
       $pattern_full = '{(\[raw\].*?\[/raw\])}is';
       $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
       $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
 
       foreach ($pieces as $piece) {
               if (preg_match($pattern_contents, $piece, $matches)) {
                       $new_content .= $matches[1];
               } else {
                       $new_content .= wptexturize(wpautop($piece));
               }
       }
 
       return $new_content;
}
 
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
 
add_filter('the_content', 'my_formatter', 99);
 
//Open Graph
 
function wp_opengraph_for_posts() {
    if ( is_singular() ) {
        global $post;
        setup_postdata( $post );
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . esc_attr( get_the_title() ) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
        $output .= '<meta property="og:description" content="' . esc_attr( get_the_excerpt() ) . '" />' . "\n";
        if ( has_post_thumbnail() ) {
            $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
}
add_action( 'wp_head', 'wp_opengraph_for_posts' );
comments powered by Disqus

Info

Tags: Wordpress

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 1076
Date Added: 2013-03-08 15:49:21
Last Modified: 2013-03-15 10:23:00

Web Analytics