easydigitaldownloads/Easy-Digital-Downloads — pull request #1135 by GaryJones (2013-04-27 10:51:38+00:00)
Title: includes/scripts.php

A tidy up of includes/scripts. See the individual commits for more info.

Other things that could also be added:

1) Fix the `complete_purchasse` array key typo here and wherever else it is used.
2) Extract duplicate `$suffix` check into a new function.
3) Extract duplicate JS / images asset paths into own functions.
4) Extract check for disabled styles into own function e.g.
~~~php
function edd_has_styles_disabled() {
global $edd_options;

if ( isset( $edd_options['disable_styles'] ) ) {
return true;
}
return false;
}

function edd_register_styles() {
if ( edd_has_styles_disabled() )
return;
// ...
}
~~~
Not only does it allow easier re-use by extensions, the but the new function could be improved to allow a programmatic override and so on. It also makes the code easier to read.
5) Extract array of EDD pages (see globals in `edd_load_admin_scripts()`) into own function that then returns a filterable array).
6) Use `get_the_ID()` instead of the global `$post` in `edd_load_scripts()`.