Changeset 10692
- Timestamp:
- 02/17/2021 10:13:23 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/cli-commands.php
r10279 r10692 14 14 * ## OPTIONS 15 15 * 16 * <path>16 * [--src_path=<src_path>] 17 17 * : The path to a copy of WordPress to be parsed. Should not be code used in 18 * an active install. 18 * an active install. If not defined, then the latest version of WordPress will 19 * be downloaded to a temp directory and parsed. 19 20 * 20 21 * [--user_id=<user_id>] … … 23 24 * ## EXAMPLES 24 25 * 25 * # Parse WP 4.9.5 into DevHub. 26 * $ wp devhub /home/wporgdev/developer/wp495 26 * # Parse lastest WP. 27 * $ wp devhub parse 28 * 29 * # Parse specific copy of WP. 30 * $ wp devhub parse --src_path=/path/to/wordpress 27 31 * 28 32 * @when after_wp_load 29 33 */ 30 34 public function parse( $args, $assoc_args ) { 31 list( $path ) = $args; 32 35 $path = $assoc_args['src_path'] ?? null; 36 37 // Verify path is a file or directory. 38 if ( $path ) { 39 if ( file_exists( $path ) ) { 40 WP_CLI::log( 'Parsing WordPress source from specified directory: ' . $path ); 41 } else { 42 WP_CLI::error( 'Provided path for WordPress source to parse does not exist.' ); 43 } 44 } 45 46 // If no path provided, use a temporary path. 47 if ( ! $path ) { 48 $path = WP_CLI\Utils\get_temp_dir() . 'devhub_' . time(); 49 50 // @todo Attempt to reuse an existing temp dir. 51 if ( mkdir( $path ) ) { 52 WP_CLI::log( "Installing latest WordPress into temporary directory ({$path})..." ); 53 $cmd = "core download --path={$path}"; 54 // Install WP into the temp directory. 55 WP_CLI::runcommand( $cmd, [] ); 56 } else { 57 $path = null; 58 } 59 } 60 61 if ( ! $path ) { 62 WP_CLI::error( 'Unable to create temporary directory for downloading WordPress. If retrying fails, consider obtaining the files manually and supplying that path via --src_path argument.' ); 63 } 64 65 // Determine importing user's ID. 33 66 $user_id = $assoc_args['user_id'] ?? 5911429; // 5911429 = ID for wordpressdotorg 34 67 $user = get_user_by( 'id', $user_id ); … … 42 75 'posts-to-posts' => 'posts-to-posts/posts-to-posts.php', 43 76 ]; 44 45 // Verify path is a file or directory.46 if ( ! file_exists( $path ) ) {47 WP_CLI::error( 'Path for WordPress source to parse does not exist.' );48 }49 77 50 78 // Verify path is not a file.
Note: See TracChangeset
for help on using the changeset viewer.