Skip to content
Merged
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
36 changes: 36 additions & 0 deletions gp-page-transitions/gppt-disable-auto-height.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Gravity Perks // Page Transitions // Disable Auto Height
* https://gravitywiz.com/documentation/gravity-forms-page-transitions/
*
* This snippet disables Swiper's auto height and forces all slides to match the height of the tallest slide.
*/
// Update "123" to your form ID
$target_form_id = 123;

add_filter( "gppt_script_args_{$target_form_id}", function( $args, $form ) {
$args['transitionSettings']['autoHeight'] = false;
return $args;
}, 10, 2 );

add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
add_action( 'wp_head', 'disable_auto_height_styles' );
return $form;
});
Comment on lines +16 to +19
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix timing: wp_head hook is registered after wp_head fires

On a normal front-end render the gform_pre_render_* filter runs while the form markup is being output—long after wp_head has already fired. Registering the callback at this point means the CSS never prints for live forms (only previews, where you call the function directly). Please hook into something that executes after the filter but before the closing body tag—wp_footer is a safe choice for inline styles, or alternatively output the <style> block immediately from this callback.

Applying the following change will ensure the styles execute on the same request:

-add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
-	add_action( 'wp_head', 'disable_auto_height_styles' );
+add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
+	add_action( 'wp_footer', 'disable_auto_height_styles' );
 	return $form;
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
add_action( 'wp_head', 'disable_auto_height_styles' );
return $form;
});
add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
add_action( 'wp_footer', 'disable_auto_height_styles' );
return $form;
});
🤖 Prompt for AI Agents
In gp-page-transitions/gppt-disable-auto-height.php around lines 16 to 19, the
code attaches disable_auto_height_styles() to wp_head during gform_pre_render
which runs after wp_head has already fired on normal front-end renders; change
the registration so the styles are emitted during the same request by either (A)
hooking disable_auto_height_styles() to wp_footer instead of wp_head (register
the action inside the gform_pre_render callback using 'wp_footer'), or (B)
outputting the required <style> block directly from the gform_pre_render
callback and returning the form immediately—pick one approach and remove the
late wp_head registration so the CSS is present for live forms.


add_action( 'gform_preview_footer', function( $form_id ) use ( $target_form_id ) {
if ( $form_id == $target_form_id ) {
disable_auto_height_styles();
}
});

function disable_auto_height_styles() {
?>
<style>
.gppt-has-page-transitions .swiper-slide {
height: auto;
align-self: stretch;
}
</style>
<?php
}
Loading