Syntax

get_post_type( int|WP_Post|null $post = null )

Usage

It returns a string of the post type of the post ID or the current post, from this value you can check on the post type to decide what you do with it, just like the code.
Add the below code to the wp-includes/post.php

function get_post_type( $post = null ) {
  $post = get_post( $post );
    if ( $post ) {
        return $post->post_type;
  }
    return false;
}
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
100 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %