If you were seeing "not ez-page" even on ez-pages, that indicates that the test
if (!isset($ez_page_id))
is not working correctly.
Maybe the variable $ez_page_id is misspelled in the example?
A check in the Developers Toolkit shows no matches in the ZC files for $ez_page_id, but a bunch for $ezpage_id.
Change $ez_page_id to $ezpage_id and this code should work.
Bookmarks