I'm using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I'm getting the following notice (wp-debug is on):
Notice: Trying to get property of non-object in C:\wamp\www\WordPress\wp-includes\post-template.php on line 29
I know why this happens, My question is why should this happen? Isn't WordPress supposed to know that there is no $post assigned to 404 and return an empty result?
Do I have to use:
if( !is_object($post) ) return;
Everywhere I use get_the_ID() in order to get rid of that Notice?