I’m one of the Event Espresso core developers who primarily worked on the forms system. I’ve scanned over the code and it looks very similar to our ideal for what an addon would look like. Thanks!
Is there a Github repo for this? That would be nice for collaboration IMO.
FYI we’ve recently added a better way for enqueuing scripts and CSS with form inputs.
You should basically put the contents of
EE_SSA_FILE::ssa_enqueue_scripts()inside a new method
EE_File_Display_Strategy::enqueue_js()(which overrides the parent’s
enqueue_js()method). That way you’ll only enqueue js and css when the input will actually be displayed. Right now, you’ll be enqueueing the JS and CSS as soon as the input is created, regardless of whether it’s actually displayed during this request or not. This change may make it work not work with older versions of EE4, before the
enqueue_jsmethod on fields was called consistently.
For that you might want to follow the model of our mock addon a little more closely, ie actually use
EE_Register_Addon::register()to register your addon, register a module (eg name it something like
EED_SSA_File_Inputwhich sets up all the actions and filters your addon needs), and also set a minimum EE core version. This way, if someone tries to run your add-on with an older version of EE, they’ll get a notice saying it’s too old and then the actions/filters won’t be executed.
But for the most part, this seems to work great.
- The topic ‘Nicely coded’ is closed to new replies.