This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to launch with wp-rollback installed (#109)
WP Rollback adds the ability to install an old version of any plugin if it's still on the Plugin Directory.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters