Your Class Name:
- I’d prefix the class name to make collisions less likely– something
likeYour_Initials_Today_Video
, or namespace it, but be aware
that PHP namespacing requires a higher versions of PHP than
WordPress requires. That could cause issues.
Your Constructor:
- You can use
__construct
instead ofToday_video
for your
constructor. WordPress no longer supports PHP 4, so you shouldn’t
have to either.
In your widget
function:
$instance
should always be set. You don’t need to check for it
explicitly, and even if not setisset( $instance[ 'title' ] )
would still operate correctly and without error. That “wrapper”
conditional is unnecessary.
In your form
function:
- Embedding that markup in the
template
argument is going to be
prone to markup error. I would add a set of individual parameters–
height
,width
,src
, whatever you need– and generate the
iframe
dynamically.
While I might do a few things differently, I wouldn’t call the code “messy” and I didn’t spot any major issues, nor does it trigger any warning or notices.