Last active
September 29, 2016 23:55
-
-
Save shizhua/d1832f2b94b61996620a to your computer and use it in GitHub Desktop.
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 | |
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; | |
} | |
} | |
?> |
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 | |
// 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 ); | |
?> |
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 | |
add_action( 'admin_head', 'ws_add_css' ); | |
function ws_add_css( $page ) { | |
?> | |
<style type="text/css"> | |
#ws_post_id { | |
width: 74px; | |
} | |
</style> | |
<?php }?> |
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 | |
// 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 } | |
?> |
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 | |
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