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 #113 from oskosk/add/code-snippets-feature
Browse files Browse the repository at this point in the history
Add ability to launch sites with the Code Snippets plugin installed
  • Loading branch information
oskosk authored Apr 10, 2018
2 parents 96103e6 + 02c8051 commit 8337523
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
40 changes: 40 additions & 0 deletions features/code-snippets.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 = [
'code-snippets' => false,
];
add_filter( 'jurassic_ninja_rest_feature_defaults', function( $defaults ) {
return array_merge( $defaults, [
'code-snippets' => false
] );
} );

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

add_action( 'jurassic_ninja_add_features_before_auto_login', function( &$app, $features, $domain ) use ( $defaults ) {
$features = array_merge( $defaults, $features );
if ( $features['code-snippets'] ) {
debug( '%s: Adding Code Snippets', $domain );
add_code_snippets_plugin();
}
}, 10, 3 );

} );

/**
* Installs and activates Code Snippets Plugin on the site.
*/
function add_code_snippets_plugin() {
$cmd = 'wp plugin install code-snippets --activate';
add_filter( 'jurassic_ninja_feature_command', function ( $s ) use ( $cmd ) {
return "$s && $cmd";
} );
}
2 changes: 1 addition & 1 deletion features/gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$defaults = [
'gutenberg' => false,
];
add_filter( 'jurassic_ninja_rest_feature_defaults', function( $defaults ) {
add_filter( 'jurassic_ninja_rest_feature_defaults', function( $defaults ) {
return array_merge( $defaults, [
'gutenberg' => false
] );
Expand Down
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: 3.2.1
* Version: 3.3
* Author: Osk
**/

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 require_feature_files() {
'/features/multisite.php',
'/features/ssl.php',
'/features/plugins.php',
'/features/code-snippets.php',
'/features/config-constants.php',
'/features/gutenberg.php',
'/features/jetpack-beta.php',
Expand Down

0 comments on commit 8337523

Please sign in to comment.