Skip to content
Open
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
4 changes: 4 additions & 0 deletions projects/packages/forms/changelog/fix-forms-styles-ciab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fixed

Forms: fix block styles not loading in CIAB environment.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
add_filter( 'pre_render_block', array( __CLASS__, 'pre_render_contact_form' ), 10, 3 );

add_filter( 'block_editor_rest_api_preload_paths', array( __CLASS__, 'preload_endpoints' ) );

// Load scripts for the editing interface
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'load_editor_scripts' ), 9 );
}
/**
* Register the contact form block feature flag.
Expand Down Expand Up @@ -826,22 +829,11 @@

/**
* Load editor styles for the block.
* These are loaded via enqueue_block_assets to ensure proper loading in the editor iframe context.
*
* @deprecated $$next-version$$ This function is deprecated and will be removed in a future version.
*/
public static function load_editor_styles() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a public function I think we should add a deprecation notice before removing it.
Since it could cause fatal errors or any plugin that also calls it.


$handle = 'jp-forms-blocks';

Assets::register_script(
$handle,
'../../../dist/blocks/editor.js',
__FILE__,
array(
'css_path' => '../../../dist/blocks/editor.css',
'textdomain' => 'jetpack-forms',
)
);
wp_enqueue_style( 'jp-forms-blocks' );
_deprecated_function( __METHOD__, 'jetpack-15.5', null );

Check failure on line 836 in projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php

View workflow job for this annotation

GitHub Actions / Static analysis

TypeError PhanTypeMismatchArgumentProbablyReal Argument 3 ($replacement) is null of type null but \_deprecated_function() takes string (no real type) defined at /home/runner/work/jetpack/jetpack/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php:112897 (the inferred real argument type has nothing in common with the parameter's phpdoc type) FAQ on Phan issues: pdWQjU-Jb-p2
}

/**
Expand All @@ -856,6 +848,8 @@

$handle = 'jp-forms-blocks';

wp_enqueue_style( 'jp-forms-blocks' );

Comment on lines +851 to +852
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be removed. The wp_enqueue_style() call is attempting to enqueue a style that hasn't been registered yet. The Assets::register_script() call below (with 'enqueue' => true and 'css_path' => '../../../dist/blocks/editor.css') will automatically register and enqueue both the script and its associated stylesheet, making this manual enqueue call unnecessary and incorrect.

Suggested change
wp_enqueue_style( 'jp-forms-blocks' );

Copilot uses AI. Check for mistakes.
Assets::register_script(
$handle,
'../../../dist/blocks/editor.js',
Expand All @@ -865,8 +859,7 @@
'in_footer' => true,
'textdomain' => 'jetpack-forms',
'enqueue' => true,
// Editor styles are loaded separately, see load_editor_styles().
'css_path' => null,
'css_path' => '../../../dist/blocks/editor.css',
)
);

Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-forms-styles-ciab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Forms: fix block styles not loading in CIAB environment.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@

// Register the block
add_action( 'init', array( Contact_Form_Block::class, 'register_block' ), 9 );

// Load scripts for the editing interface
add_action( 'enqueue_block_editor_assets', array( Contact_Form_Block::class, 'load_editor_scripts' ), 9 );

// Load styles in the editor iframe context
if ( is_admin() ) {
add_action( 'enqueue_block_assets', array( Contact_Form_Block::class, 'load_editor_styles' ), 9 );
}
Loading