Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:97a8c62a95c43485c909
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.