Created
September 20, 2013 22:58
-
-
Save tomjn/6645042 to your computer and use it in GitHub Desktop.
in a wordpress environment this will generate a composer.json string, WIP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function get_composer_json() { | |
| $plugins = get_plugins(); | |
| $data = array(); | |
| $data['rarst/wordpress'] = '>='.get_bloginfo( 'version' ); | |
| $data['php'] = '>=5.2.4'; | |
| foreach ( $plugins as $plugin ) { | |
| $key = 'wpackagist/'.sanitize_title( $plugin['Name'] ); | |
| $data[ $key ] = $plugin['Version']; | |
| } | |
| $manifest = array(); | |
| $manifest['name'] = 'wpsite/'.sanitize_title( get_bloginfo( 'name' ) ); | |
| $repositories = array(); | |
| $repositories[] = array( | |
| 'type' => 'vcs', | |
| 'url' => 'http://rarst.net' | |
| ); | |
| $manifest['description'] = get_bloginfo( 'description' ); | |
| $manifest['homepage'] = home_url(); | |
| $manifest['version'] = get_bloginfo( 'version' ); | |
| $manifest['repositories'] = $repositories; | |
| $manifest['extra'] = array( | |
| 'installer-paths' => array( | |
| './' => array( 'rarst/wordpress' ) | |
| ) | |
| ); | |
| $manifest['require'] = $data; | |
| $json = json_encode( $manifest, ( JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) ); | |
| return $json; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment