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

Commit

Permalink
Add ability to launch sites with latest beta release of WordPress 5.0 (
Browse files Browse the repository at this point in the history
…#141)

* bump versino to 4.2

* Add wordpress-5-beta feature

* Fix whitespace issue

* omit Gutenberg if WordPress 5.0 beta requested
  • Loading branch information
oskosk authored Oct 24, 2018
1 parent ff7ae8b commit 849bbd7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
63 changes: 63 additions & 0 deletions features/wordpress-5-beta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace jn;

add_action( 'jurassic_ninja_init', function() {
$defaults = [
'wordpress-5-beta' => false,
];

add_action( 'jurassic_ninja_add_features_before_auto_login', function( &$app = null, $features, $domain ) use ( $defaults ) {
$features = array_merge( $defaults, $features );
if ( $features['wordpress-5-beta'] ) {
debug( '%s: Updating core to latest WordPress 5 beta release', $domain );
update_to_wordpress_5_beta_latest();
}
}, 10, 3 );

add_filter( 'jurassic_ninja_rest_feature_defaults', function( $defaults ) {
return array_merge( $defaults, [
'wordpress-5-beta' => false,
] );
} );

add_filter( 'jurassic_ninja_rest_create_request_features', function( $features, $json_params ) {
if ( isset( $json_params['wordpress-5-beta'] ) ) {
$features['wordpress-5-beta'] = $json_params['wordpress-5-beta'];
// Disable launching with Gutenberg if WordPress 5.0 is requested
// Just in case they collide at some point
if ( isset( $json_params['gutenberg'] ) ) {
$features['gutenberg'] = false;
}
}
return $features;
}, 11, 2 );

} );

add_action( 'jurassic_ninja_admin_init', function() {
add_filter( 'jurassic_ninja_settings_options_page_default_plugins', function( $fields ) {
$field = [
'wordpress_5_beta_latest' => [
'id' => 'wordpress_5_beta_latest',
'title' => __( 'Latest beta tag for WordPress 5.0', 'jurassic-ninja' ),
'text' => __( 'Which version to run when wordpress-5-beta requested', 'jurassic-ninja' ),
'placeholder' => '5.0-beta1',
'value' => '5.0-beta1',
'checked' => false,
],
];
return array_merge( $fields, $field );
}, 10 );
} );

/**
* Updates WordPress to latest Beta available for 5.0.
*/
function update_to_wordpress_5_beta_latest() {
$wordpress_5_beta_latest = settings( 'wordpress_5_beta_latest', '5.0-beta1' );
$cmd = "wp core update --version=$wordpress_5_beta_latest && wp core update-db";
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.2-beta4
* Version: 4.2
* 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 @@ -68,6 +68,7 @@ function require_feature_files() {
'/features/woocommerce-beta-tester.php',
'/features/wp-debug-log.php',
'/features/gutenpack.php',
'/features/wordpress-5-beta.php',
];

$available_features = apply_filters( 'jurassic_ninja_available_features', $available_features );
Expand Down

0 comments on commit 849bbd7

Please sign in to comment.