Skip to content

Instantly share code, notes, and snippets.

@ankitnetwork18
Created January 11, 2013 07:28
Show Gist options
  • Save ankitnetwork18/4508701 to your computer and use it in GitHub Desktop.
Save ankitnetwork18/4508701 to your computer and use it in GitHub Desktop.
wordpress: modify admin panel post section items
/*
Plugin Name: Admin mods
Description: This plugin removes unwanted items from wordpress admin panel
Version: 1.0
Author: Ankit Agrawal
*/
//function to add custom coloumns
add_filter( 'manage_edit-post_columns', 'my_columns_filter', 10, 1 );
add_action( 'manage_posts_custom_column', 'my_column_action', 10, 1 );
//add_filter("manage_edit-post_sortable_columns", 'my_columns_sort');
function my_columns_filter( $columns ) {
$column_thumbnail = array( 'media' => 'Media Type' );
$columns = array_slice( $columns, 0, 5, true ) + $column_thumbnail + array_slice( $columns, 1, NULL, true );
return $columns;
}
function my_column_action( $column ) {
global $post;
switch ( $column ) {
case 'media':
echo get_content_type_by_post_id($post->ID);
break;
}
}
// function to get content type in posts
function get_content_type_by_post_id($postid)
{
$metaarr=get_post_meta($postid);
if($metaarr['content_type'][0]=='image')
{
$content_type="Image";
}
if($metaarr['content_type'][0]=='video')
{
$content_type="Video";
}
if($metaarr['content_type'][0]=='mixed')
{
$content_type="Image/Video";
}
if($metaarr['content_type'][0]=='text')
{
$content_type="Text/Image";
}
if($metaarr['content_type'][0]=='patti')
{
$content_type="Patti";
}
return $content_type;
}
//remove update messages
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment