Skip to content

Instantly share code, notes, and snippets.

@spigists
spigists / functions.php
Created June 10, 2013 21:19
Re-enable the built in WordPress links manager in in 3.5+ installs
/**
* Re-enable the built in WordPress links manager
*/
add_filter( 'pre_option_link_manager_enabled', '__return_true' );
@spigists
spigists / functions.php
Created June 10, 2013 21:33
Replace the default WordPress dashboard footer text and link with a custom message
/**
* Replace the default WordPress dashboard footer text and link with a custom message
*/
function footer_admin () {
echo 'Website designed and developed by <a href="http://go-spi.com/" target="_blank">Schmitt ProfiTools, Inc.</a>';
}
add_filter('admin_footer_text', 'footer_admin');
@spigists
spigists / functions.php
Created June 10, 2013 21:37
Keep WordPress from putting the version number in the page header
/**
* Remove WordPress version number from header
*/
remove_action('wp_head', 'wp_generator');
@spigists
spigists / functions.php
Created June 10, 2013 21:34
Stop images from getting wrapped in <p> tags when they are displayed with the_content()
/**
* Stop images from getting wrapped in the_content()'s <p> tags
*/
function remove_img_ptags($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'remove_img_ptags');
@spigists
spigists / functions.php
Created June 10, 2013 21:39
Obscure log in screen error messages
/**
* Obscure log in screen error messages
*/
function wpfme_login_obscure(){ return '<strong>Oh no... </strong>It looks like the user name and password combination that you entered is wrong.';}
add_filter( 'login_errors', 'wpfme_login_obscure' );
@spigists
spigists / functions.php
Created June 10, 2013 21:40
Remove the built in theme/plugin editor from the dashboard
/**
* Remove the built in theme/plugin editor from the dashboard
*/
define('DISALLOW_FILE_EDIT', true);
@spigists
spigists / functions.php
Created June 10, 2013 21:41
Change the default from and from name on WordPress emails
/**
* Change the default from and from name on WordPress emails
*/
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_fom($old) {
return 'noreply@go-spi.com';
}
function new_mail_from_name($old) {
@spigists
spigists / functions.php
Created June 10, 2013 21:42
Remove useless dashboard widgets from the start screen
/**
* Remove useless dashboard widgets
*/
function remove_dashboard_widgets(){
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
@spigists
spigists / functions.php
Created June 10, 2013 21:49
Use Google's version of HTML5 shim but only for old versions of IE
/**
* Use Google's version of HTML5 shim but only for old versions of IE
*/
function iehtml5_shim () {
global $is_IE;
if ($is_IE)
echo '<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->';
}
add_action('wp_head', 'iehtml5_shim');
@spigists
spigists / functions.php
Created June 10, 2013 21:50
Use Google's CDN version of jQuery
/**
* Custom functions
*/
function jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
}
if (!is_admin()) add_action("wp_enqueue_scripts", "jquery_enqueue", 11);