Fix PHP 5.4 related errors and correct the previewer logic for widgets (3.4 - 3.5.1 compatible)