secret
Created

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?php
 
function my_get_current_post_type() {
 
if ( function_exists( 'get_current_screen' ) and is_object( get_current_screen() ) )
$post_type = get_current_screen()->post_type;
else
$post_type = '';
 
if ( empty( $post_type ) ) {
if ( isset( $_REQUEST['post_type'] ) )
$post_type = $_REQUEST['post_type'];
else if ( isset( $_REQUEST['post'] ) )
$post_type = get_post_type( $_REQUEST['post'] );
else if ( isset( $_REQUEST['post_id'] ) )
$post_type = get_post_type( $_REQUEST['post_id'] );
else if ( isset( $_REQUEST['attachment_id'] ) )
$post_type = get_post_type( get_post( $_REQUEST['attachment_id'] )->post_parent );
}
 
return $post_type;
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.