evasivesoftware/PrettyPress — pull request #2 by richardtape (2013-12-31 01:44:21+00:00)
Title: CHANGE enqueue the PP js in the admin so that we’re able to localize them in the future

Instead of directly injecting script tags into the edit screens, we load them via wp_enqueue_scripts this affords us several things such as: ability to dequeue them externally, ability to enqueue items before/after them, easier versioning and, importantly, the ability to easily localize these scripts.

My main reasoning behind this was to have a way to pass PHP data to the javascript with relative ease (often done via wp_localize_script) so that it's possible for the JS to know which custom fields to fetch. As there are several different methods custom meta can be added (and manipulated) to a post (core/standard post meta, Advanced Custom Fields, or other plugins) we need the JS to be aware of where to fetch the custom meta from, so I was considering having a filter which people can add to so they can register support for custom fields to the PP edit screen (i.e. the LHS of the split window)

Either way, it's better practice to load JS via this method.

Notes
--------

CHANGE enqueue the PP js in the admin so that we’re able to localize them in the future
REMOVE the direct loading of the scripts
ADD filter for which pages (hook slugs) the scripts are loaded on
CHANGE remove some stray whitespace (auto by ST2 plugin)