Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Add jetpack-beta-blocks feature
Browse files Browse the repository at this point in the history
  • Loading branch information
oskosk committed Jul 12, 2022
1 parent 7090947 commit 9457dd1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions features/jetpack-beta-blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Jetpack Beta Blocks.
*
* @package jurassic-ninja
*/

namespace jn;

add_action(
'jurassic_ninja_init',
function () {
$defaults = array(
'jetpack-beta-blocks' => false,
);

add_action(
'jurassic_ninja_add_features_before_auto_login',
function ( &$app = null, $features, $domain ) use ( $defaults ) {
$features = array_merge( $defaults, $features );
if ( $features['jetpack-beta-blocks'] ) {
debug( '%s: Setting JETPACK_BETA_BLOCKS to true', $domain );
set_jetpack_beta_blocks();
}
},
1,
3
);

add_filter(
'jurassic_ninja_rest_feature_defaults',
function ( $defaults ) {
return array_merge(
$defaults,
array(
'jetpack-beta-blocks' => false,
)
);
}
);

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

/**
* Sets the JETPACK_BETA_BLOCKS constant.
*/
function set_jetpack_beta_blocks() {
$cmd = 'wp config --type=constant set JETPACK_BETA_BLOCKS true';
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 @@ -120,6 +120,7 @@ function require_feature_files() {
'/features/jetpack-debug-helper.php',
'/features/client-example.php',
'/features/my-jetpack.php',
'/features/jetpack-beta-blocks.php',
'/features/wp-debug-log.php',
'/features/block-xmlrpc.php',
'/features/language.php',
Expand Down

0 comments on commit 9457dd1

Please sign in to comment.