Skip to content

Instantly share code, notes, and snippets.

@bsbeeks
Created January 13, 2015 16:18
Show Gist options
  • Save bsbeeks/597c883a687f05b95b41 to your computer and use it in GitHub Desktop.
Save bsbeeks/597c883a687f05b95b41 to your computer and use it in GitHub Desktop.
Wordpress Snippets
// Custom Logo Link
function wpc_url_login() {
return "http://twentycms.com/";
}
add_filter('login_headerurl', 'wpc_url_login');
// Custom Login Styles (including logo)
function login_css() {
wp_enqueue_style( 'login_css', get_template_directory_uri() . '/css/login.css' );
}
add_action('login_head', 'login_css');
function disable_drag_metabox() {
wp_deregister_script('postbox');
}
add_action( 'admin_init', 'disable_drag_metabox' );
# REMOVE WORDPRESS UPDATE NOTIFICATIONS
# 2.3 to 2.7:
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
# 2.8 to 3.0:
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
add_filter( 'pre_transient_update_core', create_function( '$a', "return null;" ) );
# 3.0:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
# REMOVE PLUGIN UPDATE NOTIFICATIONS
# 2.3 to 2.7:
add_action( 'admin_menu', create_function( '$a', "remove_action( 'load-plugins.php', 'wp_update_plugins' );") );
# Why use the admin_menu hook? It's the only one available between the above hook being added and being applied
add_action( 'admin_init', create_function( '$a', "remove_action( 'admin_init', 'wp_update_plugins' );"), 2 );
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_update_plugins' );"), 2 );
add_filter( 'pre_option_update_plugins', create_function( '$a', "return null;" ) );
# 2.8 to 3.0:
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'wp_update_plugins', 'wp_update_plugins' );
add_filter( 'pre_transient_update_plugins', create_function( '$a', "return null;" ) );
# 3.0:
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" );
function remove_admin_menu_items () {
if (function_exists( 'remove_menu_page' ) && current_user_can( 'editor' )) {
remove_menu_page( 'acf-options' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'pods' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'options-general.php' );
remove_submenu_page( 'themes.php', 'themes.php' );
}
}
add_action( 'admin_menu', 'remove_admin_menu_items', 999 );
function remove_dashboard_widgets() {
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
function remove_admin_bar_items() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('updates');
$wp_admin_bar->remove_menu('new-content');
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_items' );
function showMessage($message, $errormsg = false) {
if ($errormsg) {
echo '<div id="message" class="error">';
}
else {
echo '<div id="message" class="updated fade">';
}
echo "<p><strong>$message</strong></p></div>";
}
function showAdminMessages() {
showMessage("Working on Theme's function.php, Do not touch it till further notice.", true);
}
add_action('admin_notices', 'showAdminMessages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment