WORDPRESS HOOKS AND FILTERS FOR YOUR FUNCTIONS.PHP
ADD BACKGROUND IMAGE UPLOADER
add_custom_background();
BEST HIDE DASHBOARD FUNCTION
add_action( 'admin_menu', 'isa_remove_menus', 999 );
function isa_remove_menus() {
INSERT MENU ITEMS TO REMOVE FOR EVERYONE
remove for editor and below, but not administratorif ( ! current_user_can('manage_options') ) {
INSERT MENU ITEMS TO REMOVE FOR EDITOR AND BELOW
}
remove only for author and belowif ( ! current_user_can('delete_others_posts') ) {
INSERT MENU ITEMS TO REMOVE FOR AUTHOR AND BELOW
remove_menu_page( 'edit.php' ); // Posts
remove_menu_page( 'edit-comments.php' ); // Comments
remove_menu_page('tools.php'); // Tools
remove_menu_page('upload.php'); // Media
remove_menu_page('link-manager.php'); // Links
remove_menu_page('edit.php?post_type=page'); // Pages
remove_menu_page('edit.php?post_type=ditty_news_ticker'); //ditty_news_ticker YOU CAN FIND THIS DIRECTORY IN PLUGIN URL
remove_menu_page('a-to-z-listing-by-alphabet/alphabet_listing_settings.php'); // A TO Z
// To remove custom post types,
// replace 'custom-post-type-name' with the name
remove_menu_page('edit.php?post_type=custom-post-type-name');
// Don't remove Posts, but remove Category submenu under Posts
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' );
// Don't remove Posts, but remove Tags submenu under Posts
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' );
}
}
ISOLATES PLUGIN TO HIDE IN DASHBOARD
add_action( 'admin_menu', 'remove_links_menu' );
function remove_links_menu() {
remove_menu_page('PLUGIN NAME.php'); // Dashboard
}
ANOTHER REMOVE DASHBOARD FUNCTION
function remove_the_dashboard () {
if (current_user_can('level_10')) {
return;
} else {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);
if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]);
reset($menu); $page = key($menu);
while (!$the_user->has_cap($menu[$page][1]) && next($menu))
$page = key($menu);
if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]))
wp_redirect(get_option('siteurl') . ' ');
}
}
add_action('admin_menu', 'remove_the_dashboard');
REMOVE EXCESS STUFF BELOW COMMENT FORM
function mytheme_init() {
add_filter('comment_form_defaults',
'mytheme_comments_form_defaults');
}
add_action('after_setup_theme',
'mytheme_init');
function mytheme_comments_form_defaults($default) {
unset($default['comment_notes_after']);
return $default;
}
REGISTER TAG CLOUD FILTER CALLBACK: LIMITS TAGS THIS EXAMPLE TO 10
add_filter('widget_tag_cloud_args', 'tag_widget_limit');
//Limit number of tags inside widgetfunction tag_widget_limit($args){
//Check if taxonomy option inside widget is set to tagsif(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){
$args['number'] = 10; //Limit number of tags
}
return $args;
}
LOGIN FILTER: CREATES CUSTOM LOGIN/REGISTER PAGE
FIRST MAKE DIRECTORY IN CHILD THEME NAME IT LOGIN AND CREATE CUSTOM STYLE SHEET login-styles.CSS
function custom_login_css() {
echo 'link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().
'/login/login-styles.css" ';
}
add_action('login_enqueue_scripts', 'custom_login_css');
add_filter( 'login_headerurl', 'custom_login_header_url' );
function custom_login_header_url($url) {
return 'http://www.yoursite.com/wp-login.php';
}
add_filter( 'login_headertitle', 'namespace_login_headertitle' );
/**
* Replaces the login header logo title
*
* @param $title
*/
function namespace_login_headertitle( $title ) {
$title = get_bloginfo( 'name' );
return $title;
}
HIDES WP ADMIN BAR LINKS
function wps_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('dashboard');
}
add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );
REMOVES SPECIFIED MEMBER LINKS IN THIS CASE (forum) FROM ADMINBAR
function your_bp_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'my-account-forums' );
}
add_action( 'bp_setup_admin_bar', 'your_bp_admin_bar_remove', 301 );
HIDES WP FOOTER COPY RIGHT REPLACES IT WITH YOUR OWN
function remove_footer_admin () {
echo 'Copywrite 2015 YOUR SITE. All Rights Reserved.';
}
add_filter('admin_footer_text', 'remove_footer_admin');
REPLACES HOWDY GREETING WITH WELCOME BACK
function replace_howdy( $wp_admin_bar ) {
$my_account=$wp_admin_bar->get_node('my-account');
$newtitle = str_replace( 'Howdy,', 'Welcome Back', $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );
RECOMMENDED PLUG-INS
google-language-translator: Translates text on your site to various languages.
delete-me: Creates option for user to delete account from user profile page.
dynamic-to-top: Creates a scroll to top button. Good for long pages.
jquery-collapse-o-matic: Creates a button to collapse and expand text.
wp-smushit: Crunches/minify uploaded items to Media Library.
member-access: Limits Access to Pages, Posts and Categories.
w3-total-cache: Caches website/blog. Good for optimizing site speed.
wordfence: Gives site admin the ability to monitor users, see hack attempts, block user VIA IP addresses and more.
wp-maintenance-mode: Creates Maintenance Mode Splash Page. Good for when your conducting updates and site maintenance.
Front-end Editor: Edit your posts on the front-end of your site.
Google Language Translator: This plugin adds Google Translator to your website by using a single shortcode, [google-translator].