Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #160 from Automattic/add/content
Browse files Browse the repository at this point in the history
Add ability to launch with pregenerated content
  • Loading branch information
oskosk authored Jan 24, 2019
2 parents 98a5423 + 054ff17 commit d081583
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions features/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace jn;

add_action( 'jurassic_ninja_init', function() {
$defaults = [
'content' => false,
];

add_action( 'jurassic_ninja_add_features_before_auto_login', function( &$app = null, $features, $domain ) use ( $defaults ) {
$features = array_merge( $defaults, $features );
if ( $features['content'] ) {
debug( '%s: Adding pre-generated content', $domain );
add_content();
}
}, 1, 3 );

add_filter( 'jurassic_ninja_rest_create_request_features', function( $features, $json_params ) {
if ( isset( $json_params['content'] ) ) {
$features['content'] = $json_params['content'];
}
return $features;
}, 10, 2 );
} );

function add_content() {
$cmd = 'wget https://github.com/manovotny/wptest/archive/master.zip'
. ' && unzip master.zip'
. ' && echo "$(pwd) y $(pwd)/wptest-master/wptest.xml" | wptest-master/wptest-cli-install.sh';
add_filter( 'jurassic_ninja_feature_command', function ( $s ) use ( $cmd ) {
return "$s && $cmd";
} );
}
2 changes: 1 addition & 1 deletion jurassic.ninja.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* Plugin Name: Jurassic Ninja
* Description: Launch ephemeral instances of WordPress + Jetpack using ServerPilot and an Ubuntu Box.
* Version: 4.9
* Version: 4.10
* Author: Automattic
**/

Expand Down
1 change: 1 addition & 0 deletions lib/stuff.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function add_auto_login( $password, $sysuser ) {
function require_feature_files() {
$available_features = [
'/features/logged-in-user-email-address.php',
'/features/content.php',
'/features/multisite.php',
'/features/ssl.php',
'/features/plugins.php',
Expand Down

0 comments on commit d081583

Please sign in to comment.