Controller
6 days ago
Helper
3 weeks ago
Model
6 days ago
external
6 days ago
view
6 days ago
.gitignore
5 years ago
BuildAutoLoader.php
3 weeks ago
Controller.php
3 weeks ago
Model.php
3 weeks ago
ViewController.php
3 weeks ago
plugin.json
1 month ago
BuildAutoLoader.php
91 lines
| 1 | <?php |
| 2 | namespace ShortPixel; |
| 3 | |
| 4 | /** |
| 5 | * Utility class for generating the plugin's Composer-style autoloader JSON manifest. |
| 6 | * |
| 7 | * Used during development/build processes to regenerate the plugin.json file that |
| 8 | * maps namespaces and individual files for the PSR-4 autoloader. |
| 9 | * |
| 10 | * @package ShortPixel |
| 11 | */ |
| 12 | class BuildAutoLoader |
| 13 | { |
| 14 | |
| 15 | /** |
| 16 | * Builds and writes the plugin.json autoloader manifest to class/plugin.json. |
| 17 | * |
| 18 | * Constructs a Composer-style package descriptor with PSR-4 namespace mapping |
| 19 | * and the explicit file list returned by getFiles(), then serialises it as JSON. |
| 20 | * |
| 21 | * @return void |
| 22 | */ |
| 23 | public static function buildJSON() |
| 24 | { |
| 25 | echo 'Building Plugin.JSON'; |
| 26 | $plugin = array( |
| 27 | 'name' => 'ShortPixel/Plugin', |
| 28 | 'description' => 'ShortPixel AutoLoader', |
| 29 | 'type' => 'function', |
| 30 | 'autoload' => array('psr-4' => array('ShortPixel' => 'class'), |
| 31 | 'files' => self::getFiles(), |
| 32 | ), |
| 33 | ); |
| 34 | |
| 35 | $f = fopen('class/plugin.json', 'w'); |
| 36 | $result = fwrite($f, json_encode($plugin)); |
| 37 | |
| 38 | if ($result === false) |
| 39 | echo "!!! Error !!! Could not write Plugin.json"; |
| 40 | |
| 41 | fclose($f); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the list of plugin PHP files that must be explicitly included by the autoloader. |
| 46 | * |
| 47 | * Combines main plugin files, model files, and external integration files into a |
| 48 | * single flat array. Entries for disabled integrations are commented out inline. |
| 49 | * |
| 50 | * @return string[] Array of relative file paths to include. |
| 51 | */ |
| 52 | public static function getFiles() |
| 53 | { |
| 54 | $main = array( |
| 55 | ); |
| 56 | |
| 57 | $models = array( |
| 58 | ); |
| 59 | |
| 60 | $externals = array( |
| 61 | 'class/external/cloudflare.php', |
| 62 | 'class/external/nextgen/nextGenController.php', |
| 63 | 'class/external/nextgen/nextGenViewController.php', |
| 64 | 'class/external/visualcomposer.php', |
| 65 | 'class/external/offload/Offloader.php', |
| 66 | 'class/external/offload/wp-offload-media.php', |
| 67 | 'class/external/offload/virtual-filesystem.php', |
| 68 | 'class/external/offload/InfiniteUploads.php', |
| 69 | 'class/external/wp-cli/wp-cli-base.php', |
| 70 | 'class/external/wp-cli/wp-cli-single.php', |
| 71 | 'class/external/wp-cli/wp-cli-bulk.php', |
| 72 | 'class/external/image-galleries.php', |
| 73 | 'class/external/pantheon.php', |
| 74 | 'class/external/spai.php', |
| 75 | 'class/external/cache.php', |
| 76 | 'class/external/uncode.php', |
| 77 | 'class/external/query-monitor.php', |
| 78 | 'class/external/Woocommerce.php', |
| 79 | 'class/external/themes/total-theme.php', |
| 80 | 'class/external/MediaFileRenamer.php', |
| 81 | 'class/external/formidable.php', |
| 82 | 'class/external/wpml.php', |
| 83 | |
| 84 | ); |
| 85 | |
| 86 | echo "Build Plugin.JSON "; |
| 87 | return array_merge($main,$models,$externals); |
| 88 | } |
| 89 | |
| 90 | } |
| 91 |