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 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from oskosk/add/code-snippets-feature
Add ability to launch sites with the Code Snippets plugin installed
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 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 = [ | ||
'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"; | ||
} ); | ||
} |
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
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
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