Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion includes/class-static-site-importer-companion-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,13 @@ public static function scaffold( array $payload ) {
foreach ( $preserved as $island ) {
$files[ $plugin_slug . '/' . $island['relative_src'] ] = $island['content'];
}
$provider_form_runtime = file_get_contents( __DIR__ . '/class-static-site-importer-provider-form-runtime.php' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Reads the plugin-owned runtime source carried into generated companions.
if ( ! is_string( $provider_form_runtime ) || '' === $provider_form_runtime ) {
return new WP_Error( 'static_site_importer_companion_plugin_provider_form_runtime_missing', 'Provider form runtime projection file is unavailable.' );
}
$files[ $plugin_slug . '/includes/class-static-site-importer-provider-form-runtime.php' ] = $provider_form_runtime;

$inventory_hash = substr( hash( 'sha256', (string) wp_json_encode( array( $block_names, $preserved ) ) ), 0, 16 );
$inventory_hash = substr( hash( 'sha256', (string) wp_json_encode( array( $block_names, $preserved, hash( 'sha256', $provider_form_runtime ) ) ) ), 0, 16 );
$registration_callback = str_replace( '-', '_', $plugin_slug ) . '_' . $inventory_hash . '_register_blocks';
$main_file = $plugin_slug . '/' . $plugin_slug . '.php';
$files = array_merge(
Expand Down Expand Up @@ -678,6 +683,9 @@ private static function main_plugin_file(
$lines[] = sprintf( "define( '%s_DIR', plugin_dir_path( __FILE__ ) );", $const_prefix );
$lines[] = sprintf( "define( '%s_URL', plugin_dir_url( __FILE__ ) );", $const_prefix );
$lines[] = '';
$lines[] = "require_once __DIR__ . '/includes/class-static-site-importer-provider-form-runtime.php';";
$lines[] = 'Static_Site_Importer_Provider_Form_Runtime::register();';
$lines[] = '';
$lines[] = '/**';
$lines[] = ' * Register generated blocks from their metadata directories.';
$lines[] = ' */';
Expand Down
Loading
Loading