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 with latest stable WordPress 4 (#150)
Browse files Browse the repository at this point in the history
* Add ability to launch with latest stable WordPress 4

* Bump version to 4.6
  • Loading branch information
oskosk authored Dec 6, 2018
1 parent af80fdf commit 0747672
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
61 changes: 61 additions & 0 deletions features/wordpress-4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* This feature provides the ability to launch with latest stabel WordPress 4.
*/
namespace jn;

add_action( 'jurassic_ninja_init', function() {
$defaults = [
'wordpress-4' => 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-4'] ) {
debug( '%s: Updating core to latest WordPress 4 latest stable release', $domain );
update_to_wordpress_4_latest();
}
}, 10, 3 );

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

add_filter( 'jurassic_ninja_rest_create_request_features', function( $features, $json_params ) {
if ( isset( $json_params['wordpress-4'] ) ) {
$features['wordpress-4'] = $json_params['wordpress-4'];
}
return $features;
}, 11, 2 );

} );

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

/**
* Updates WordPress to latest tag available for WordPress 4.
*/
function update_to_wordpress_4_latest() {
$wordpress_4_latest = settings( 'wordpress_4_latest', '4.9.8' );
// We need --force because this may be a downgrade
$cmd = "wp core update --version=$wordpress_4_latest --force && 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.5
* Version: 4.6
* Author: Automattic
**/

Expand Down
2 changes: 1 addition & 1 deletion lib/stuff.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function require_feature_files() {
'/features/gutenpack.php',
'/features/gutenberg-master.php',
'/features/gutenberg-nightly.php',
'/features/wordpress-4.php',
];

$available_features = apply_filters( 'jurassic_ninja_available_features', $available_features );
Expand Down Expand Up @@ -632,4 +633,3 @@ function subdomain_is_used( $subdomain ) {
$results = db()->get_results( "select * from sites where domain='$domain' limit 1", \ARRAY_A );
return count( $results ) !== 0;
}

0 comments on commit 0747672

Please sign in to comment.