Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress functions for tweaking the admin.
<?php
/**
* Admin customizations
*/
// Change the goofy "Howdy" greeting
function remove_howdy( $translated, $text, $domain ) {
if ( !is_admin() || 'default' != $domain )
return $translated;
if ( false !== strpos($translated, 'Howdy') )
return str_replace( 'Howdy', 'Welcome', $translated );
return $translated;
}
add_filter( 'gettext', __NAMESPACE__ . '\\remove_howdy', 10, 3 );
// Update footer text AND add the damn current WP version!
function update_admin_footer() {
global $wp_version;
echo 'Custom theme designed &amp; developed by <a href="http://vandigroup.com">Vandigroup</a>. Current WP version: <strong style="color: #0073aa">' . $wp_version . '</strong>';
}
add_filter( 'admin_footer_text', __NAMESPACE__ . '\\update_admin_footer' );
// Update logo URL
function login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', __NAMESPACE__ . '\\login_logo_url' );
// Update logo Title
function login_logo_url_title() {
return 'Welcome to Speed Society';
}
add_filter( 'login_headertitle', __NAMESPACE__ . '\\login_logo_url_title' );
// Remove login error details (for better security)
function login_error_msg()
{
return 'Incorrect login credentials. Please try again.';
}
add_filter('login_errors', __NAMESPACE__ . '\\login_error_msg');
// Remove unwanted dashboard widgets for relevant users
function remove_dashboard_widgets() {
$user = wp_get_current_user();
if ( ! $user->has_cap( 'manage_options' ) ) {
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
}
}
add_action( 'wp_dashboard_setup', __NAMESPACE__ . '\\remove_dashboard_widgets' );
// Add stylesheets
function load_login_styles() {
wp_enqueue_style( 'admin_css', get_template_directory_uri() . '/assets/styles/admin/login.css', FALSE, '1.0.0' );
}
add_action( 'login_head', __NAMESPACE__ . '\\load_login_styles' );
function load_admin_styles() {
wp_enqueue_style( 'admin_css', get_template_directory_uri() . '/assets/styles/admin/admin.css', FALSE, '1.0.0' );
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\load_admin_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.