remove_node( 'wp-logo' );
$wp_admin_bar->remove_menu( 'edit' );
$wp_admin_bar->remove_menu( 'new-user' );
$wp_admin_bar->remove_menu( 'new-post' );
$wp_admin_bar->remove_menu( 'new-page' );
$wp_admin_bar->remove_node( 'new-media' );
$wp_admin_bar->remove_menu( 'edit-profile' );
$wp_admin_bar->remove_menu( 'comments' );
}
function dwp_remove_new_content(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'new-content' );
}
add_action( 'wp_before_admin_bar_render', 'dwp_remove_new_content' );
/*************************************************
// ############ admin footer ############## //
**************************************************/
add_filter('admin_footer_text', '__return_empty_string', 1000);
add_filter('update_footer', '__return_empty_string', 1000);
/*************************************************
// ############ dashboard items ################ //
**************************************************/
remove_action('welcome_panel', 'wp_welcome_panel');
add_filter('screen_options_show_screen', '__return_false');
add_action('admin_head', 'dwp_remove_help_tabs');
function dwp_remove_help_tabs() {
$screen = get_current_screen();
$screen->remove_help_tabs();
}
add_action( 'admin_init', 'dwp_remove_dashboard_meta' );
function dwp_remove_dashboard_meta() {
remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
}
/*************************************************
// ####### comments on attachments ############# //
**************************************************/
add_action( 'pre_comment_on_post', 'dwp_remove_comments_from_attachments', 10, 2 );
function dwp_remove_comments_from_attachments( $open, $post_id ){
return ( 'attachment' == get_post_type( $post_id ) ) ? false : $open;
}
add_filter( 'comments_open', 'dwp_filter_media_comment_status', 10 , 2 );
function dwp_filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
/*************************************************
// ####### menus for logged in/out ############# //
create two menus named 'logged-in' & 'logged-out
in top-navigation location of theme
**************************************************/
add_filter( 'wp_nav_menu_args', 'dwp_nav_menu_args' );
function dwp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {
if( 'top-navigation' == $args['theme_location'] ) {
$args['menu'] = 'logged-in';
}
} else {
if( 'top-navigation' == $args['theme_location'] ) {
$args['menu'] = 'logged-out';
}
}
return $args;
}
/*************************************************
// ############ user last login ################ //
**************************************************/
add_action( 'wp_login', 'dwp_login_timestamp', 20, 2 );
function dwp_login_timestamp( $user_login, $user ) {
update_user_meta( $user->ID, 'last_login', time() );
}
add_filter( 'manage_users_columns', 'dwp_user_last_login_column' );
function dwp_user_last_login_column( $columns ) {
$columns['last_login'] = 'Last Login';
return $columns;
}
add_filter( 'manage_users_custom_column', 'dwp_last_login_column', 10, 3 );
function dwp_last_login_column( $output, $column_id, $user_id ){
if( $column_id == 'last_login' ) {
$last_login = get_user_meta( $user_id, 'last_login', true );
$date_format = 'j M, Y';
$output = $last_login ? date( $date_format, $last_login ) : '-';
}
return $output;
}
add_filter( 'manage_users_sortable_columns', 'dwp_sortable_columns' );
function dwp_sortable_columns( $columns ) {
return wp_parse_args( array(
'last_login' => 'last_login'
), $columns );
}
add_action( 'pre_get_users', 'dwp_sort_last_login_column' );
function dwp_sort_last_login_column( $query ) {
if( !is_admin() ) {
return $query;
}
$screen = get_current_screen();
if( isset( $screen->id ) && $screen->id !== 'users' ) {
return $query;
}
if( isset( $_GET[ 'orderby' ] ) && $_GET[ 'orderby' ] == 'last_login' ) {
$query->query_vars['meta_key'] = 'last_login';
$query->query_vars['orderby'] = 'meta_value';
}
return $query;
}
/*************************************************
// ########## Howdy email/adminbar ############# //
**************************************************/
add_filter( 'gettext', 'dwp_change_howdy_text', 10, 2 );
function dwp_change_howdy_text( $translation, $original ) {
if( 'Howdy, %1$s' == $original )
$translation = '%1$s';
return $translation;
}
add_filter( 'admin_bar_menu', 'dwp_replace_howdy', 25 );
function dwp_replace_howdy( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node('my-account');
$newtext = str_replace( 'Howdy,', '', $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtext,
) );
}
/*************************************************
// ############### user profile ################ //
**************************************************/
if(is_admin()){
remove_action("admin_color_scheme_picker", "admin_color_scheme_picker");
}
add_action( 'personal_options_update', 'dwp_save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'dwp_save_extra_user_profile_fields' );
add_action( 'show_user_profile', 'dwp_extra_user_profile_fields' );
add_action( 'edit_user_profile', 'dwp_extra_user_profile_fields' );
function dwp_extra_user_profile_fields( $user ) { ?>
This information is useful for adminstrative purposes
|
|
|
|
|
|
|
This information is useful for the OpenGraph Protocol
|
|
|