6 Useful functions for WordPress
To use these functions in WordPress insert the script in function.php

1. Hide your WordPress login error:
Login errors with multiple details can give away the information required to help gain access to the site. With the facility of the code provided below, WordPress will not spot out where the error is made while attempting to log in. The purpose of the code is to not provide any user the hints necessary for logging-in.
function hide_wordpress_errors(){
return ‘Something is gone wrong!’;
}
add_filter( ‘login_errors’, ‘ hide_wordpress_errors’ );2. Enable WordPress to accept any file format:
By default, WordPress allows us to upload limited range of file types, including media formats such as .png and .jpg. With the facility of the code provided below, you’ll be able to force installation to allow more file formats.
function my_myme_types($mime_types){
$mime_types[‘svg’] = ‘image/svg+xml’;
return $mime_types;
}
add_filter(‘upload_mimes’, ‘my_myme_types’, 1, 1);3. Disabling the WordPress search feature:
Almost every site needs a search feature to help users find their way in the website. However, if we are going to build a single-page website, we might not require the search bar feature. Here’s the code that will enable you to turn if off:
function fb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
// to error
if ( $error == true )
$query->is_404 = true;
}
}
add_action( ‘parse_query’, ‘fb_filter_query’ );
add_filter( ‘get_search_form’, create_function( ‘$a’, “return null;” ) );4. Removing of the Admin Toolbar:
As an admin of a page, we might receive a list of notifications and some of us might probably not be interested to check. WordPress makes it all easy by making us allow to disable or remove the toolbar on the page which provides a comfort zone for the users.
add_filter(‘show_admin_bar’, ‘__return_false’);5. Change the Login Logo URL in WordPress:
WordPress now enables us to change the login logo URL as per our likes. Using the provided hook, we can change the logo to make it user friendly and not let the user land up in the WordPress website when clicked on the logo.
add_filter( ‘login_headerurl’, ‘custom_loginlogo_url’ );
function custom_loginlogo_url($url) {
return ‘http://www.example.com';
}6. Disable core updates on WordPress:
This prevents WordPress from checking for core updates, and prevents any notifications from being displayed in the admin area. This is ideal for administrators of multiple WordPress installations. Administrators who maintain multiple installations of WordPress on behalf of other people (eg. clients) may not want update notifications to be shown to the users of these installations. This plugin is for them.
add_action(‘after_setup_theme’,’remove_core_updates’);
function remove_core_updates()
{
 if(! current_user_can(‘update_core’)){return;}
 add_action(‘init’, create_function(‘$a’,”remove_action( ‘init’, ‘wp_version_check’ );”),2);
 add_filter(‘pre_option_update_core’,’__return_null’);
 add_filter(‘pre_site_transient_update_core’,’__return_null’);
}
