Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
add_filter( 'manage_posts_columns', 'ws_cutom_columns_head', 20 );
add_action( 'manage_posts_custom_column', 'ws_cutom_columns_content', 10, 2 );
function ws_cutom_columns_head( $columns ) {
$columns['ws_post_id'] = 'ID';
return $columns;
}
function ws_cutom_columns_content( $column_name, $id ) {
if ( 'ws_post_id' == $column_name ) {
echo $id;
}
}
?>
<?php
// post types
$post_types = get_post_types( array(
'public' => true
) );
foreach( $post_types as $post_type ) {
add_action( 'manage_' . $post_type . '_posts_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_' . $post_type . '_posts_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
}
//comments
add_action( 'manage_comments_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_edit-comments_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
// media
add_action( 'manage_media_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_media_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
//taxonomies
$taxonomies = get_taxonomies();
foreach ( $taxonomies as $taxonomy ) {
add_action( 'manage_' . $taxonomy . '_custom_column', array( $this, 'alt_ws_cutom_columns_content' ), 10, 3 );
add_filter( 'manage_edit-' . $taxonomy . '_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
}
//users
add_action( 'manage_users_custom_column', array( $this, 'alt_ws_cutom_columns_content' ), 10, 3 );
add_filter( 'manage_users_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
?>
<?php
add_action( 'admin_head', 'ws_add_css' );
function ws_add_css( $page ) {
?>
<style type="text/css">
#ws_post_id {
width: 74px;
}
</style>
<?php }?>
<?php
// post types
$post_types = get_post_types( array(
'public' => true
) );
foreach( $post_types as $post_type ) {
add_action( 'manage_' . $post_type . '_posts_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_' . $post_type . '_posts_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
}
//comments
add_action( 'manage_comments_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_edit-comments_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
// media
add_action( 'manage_media_custom_column', array( $this, 'ws_cutom_columns_content' ), 10, 2 );
add_filter( 'manage_media_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
//taxonomies
$taxonomies = get_taxonomies();
foreach ( $taxonomies as $taxonomy ) {
add_action( 'manage_' . $taxonomy . '_custom_column', array( $this, 'alt_ws_cutom_columns_content' ), 10, 3 );
add_filter( 'manage_edit-' . $taxonomy . '_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
}
//users
add_action( 'manage_users_custom_column', array( $this, 'alt_ws_cutom_columns_content' ), 10, 3 );
add_filter( 'manage_users_columns', array( $this, 'ws_cutom_columns_head' ), 20 );
function ws_cutom_columns_head( $columns ) {
$checkbox = array_slice( $columns , 0, 1 );
$columns = array_slice( $columns , 1 );
$new['ws_post_id'] = 'ID';
$columns = array_merge( $checkbox, $new, $columns );
return $columns;
}
function ws_cutom_columns_content( $column_name, $id ) {
if ( 'ws_post_id' == $column_name ) {
echo $id;
}
function alt_ws_cutom_columns_content( $value, $column_name, $id ) {
if ( 'ws_post_id' == $column_name ) {
$value = $id;
}
return $value;
}
add_action( 'admin_head', 'ws_add_css' );
function ws_add_css( $page ) {
?>
<style type="text/css">
#ws_post_id {
width: 74px;
}
</style>
<?php }
?>
<?php
function ws_cutom_columns_head( $columns ) {
$checkbox = array_slice( $columns , 0, 1 );
$columns = array_slice( $columns , 1 );
$new['ws_post_id'] = 'ID';
$columns = array_merge( $checkbox, $new, $columns );
return $columns;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment