public static function extractPostId($postOrPostId = null)
    {
        if (is_object($postOrPostId)) {
            return property_exists($postOrPostId, 'ID')
                ? (int) $postOrPostId->ID
                : null;
        }

        if ($postOrPostId > 0) {
            return (int) $postOrPostId;
        }

        return get_the_ID();
    }
public static function extractPostId($postOrPostId = null)
    {
        if (is_object($postOrPostId)) {
            return property_exists($postOrPostId, 'ID')
                ? (int) $postOrPostId->ID
                : null;
        }

        if ($postOrPostId > 0) {
            return (int) $postOrPostId;
        }

        return get_the_ID();
    }
public static function extractPostId ( $ postOrPostId = null ) { if ( is_object ( $ postOrPostId ) ) { return property_exists ( $ postOrPostId , 'ID' ) ? ( int ) $ postOrPostId -> ID : null ; } if ( $ postOrPostId > 0 ) { return ( int ) $ postOrPostId ; } return get_the_ID ( ) ; }
Get the post ID from the given post or post ID.
If none is passed in, then it grabs the current ID.

@since 3.1.3

@param WP_Post|int|null $postOrPostId Given post or post ID

@return int|null
Get the post ID from the given post or post ID . If none is passed in then it grabs the current ID .