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 wp-rollback installed (#109)
Browse files Browse the repository at this point in the history
WP Rollback adds the ability to install an old version of any plugin if
it's still on the Plugin Directory.
  • Loading branch information
oskosk authored Apr 6, 2018
1 parent f14aaa6 commit f10d758
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions features/wp-rollback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace jn;

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

add_action( 'jurassic_ninja_add_features_before_auto_login', function( &$app, $features, $domain ) use ( $defaults ) {
$features = array_merge( $defaults, $features );
if ( $features['wp-rollback'] ) {
debug( '%s: Adding Wp Rollback', $domain );
add_wp_rollback_plugin();
}
}, 10, 3 );

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

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

/**
* Installs and activates Wp Rollback on the site.
*/
function add_wp_rollback_plugin() {
$cmd = 'wp plugin install wp-rollback --activate' ;
add_filter( 'jurassic_ninja_feature_command', function ( $s ) use ( $cmd ) {
return "$s && $cmd";
} );
}
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/wordpress-beta-tester.php',
'/features/wp-debug-log.php',
'/features/wp-log-viewer.php',
'/features/wp-rollback.php',
];

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

0 comments on commit f10d758

Please sign in to comment.