Last active
December 17, 2015 09:39
-
-
Save ramiabraham/5589297 to your computer and use it in GitHub Desktop.
Some wp-login.php and wp-admin customization examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Here are some basic WordPress admin customizations. | |
*/ | |
// load a custom stylesheet for wp-login.php | |
function neato_prefix_custom_login_stylesheet() { | |
wp_enqueue_style( 'custom_login_stylesheet', get_template_directory_uri() . '/css/login.css' ); | |
} | |
add_action('login_head', 'neato_prefix_custom_login_stylesheet'); | |
// change login logo url in wp-login.php | |
function neato_prefix_custom_login_logo_url($url) { | |
return 'http://www.yoursite.com'; | |
} | |
add_filter( 'login_headerurl', 'neato_prefix_custom_login_logo_url' ); | |
// add custom stylesheet for wp-admin | |
function neato_prefix_custom_admin_css() { | |
wp_enqueue_style( 'custom_admin_css', get_template_directory_uri() . '/css/admin.css' ); | |
} | |
add_action('admin_head', 'neato_prefix_custom_admin_css' ); | |
// Removing admin menu pages: | |
function neato_prefix_remove_menu_pages() { | |
remove_menu_page('link-manager.php'); | |
remove_menu_page('edit-comments.php'); | |
} | |
add_action( 'admin_init', 'neato_prefix_remove_menu_pages' ); | |
// Change admin menu order: | |
function neato_prefix_custom_menu_order($menu_order) { | |
if (!$menu_order) return true; | |
return array( | |
'index.php', | |
'edit.php?post_type=page', | |
'edit.php' | |
); | |
} | |
add_filter('custom_menu_order', 'neato_prefix_custom_menu_order'); | |
add_filter('menu_order', 'neato_prefix_custom_menu_order'); | |
// Change 'Enter Title Here' default for post title area: | |
function neato_prefix_custom_default_title($title){ | |
$title = 'Type the title here'; | |
return $title; | |
} | |
add_filter( 'enter_title_here', 'neato_prefix_custom_default_title' ); | |
// Change admin footer text content | |
function neato_prefix_change_footer_content() { | |
echo 'Here is some custom admin footer content'; | |
} | |
add_filter('admin_footer_text', 'neato_prefix_change_footer_content'); | |
// Add a custom dashboard widget | |
function neato_prefix_custom_dashboard_widgets() { | |
global $wp_meta_boxes; | |
wp_add_dashboard_widget('custom_help_widget', 'Open a support request', 'custom_dashboard_help'); | |
} | |
function neato_prefix_custom_dashboard_help() { | |
echo 'To open a support request, just fill in this...'; | |
} | |
add_action('wp_dashboard_setup', 'neato_prefix_custom_dashboard_widgets'); | |
// Remove some dashboard widgets | |
function neato_prefix_disable_default_dashboard_widgets() { | |
remove_meta_box('dashboard_right_now', 'dashboard', 'core'); | |
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core'); | |
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core'); | |
remove_meta_box('dashboard_plugins', 'dashboard', 'core'); | |
remove_meta_box('dashboard_quick_press', 'dashboard', 'core'); | |
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core'); | |
remove_meta_box('dashboard_primary', 'dashboard', 'core'); | |
remove_meta_box('dashboard_secondary', 'dashboard', 'core'); | |
} | |
add_action('admin_menu', 'neato_prefix_disable_default_dashboard_widgets'); | |
// Remove widgets according to user role | |
function neato_prefix_customize_meta_boxes() { | |
global $current_user; | |
get_currentuserinfo(); | |
if ($current_user->user_level < 3) | |
remove_meta_box('postcustom','post','normal'); | |
} | |
add_action('admin_init','neato_prefix_customize_meta_boxes'); | |
// Remove columns from posts list | |
function neato_prefix_columns_filter( $columns ) { | |
unset($columns['author']); | |
unset($columns['tags']); | |
unset($columns['categories']); | |
unset($columns['tags']); | |
return $columns; | |
} | |
add_filter( 'manage_edit-post_columns', 'neato_prefix_columns_filter', 10, 1 ); | |
// Remove author column from pages list | |
function neato_prefix_custom_pages_columns($columns) { | |
unset( | |
$columns['author'] | |
); | |
return $columns; | |
} | |
add_filter( 'manage_pages_columns', 'neato_prefix_custom_pages_columns' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment