Skip to content

Instantly share code, notes, and snippets.

@adczk
Created May 17, 2023 10:17
Show Gist options
  • Select an option

  • Save adczk/81bf22bafd856e81d7d4fefae3e64429 to your computer and use it in GitHub Desktop.

Select an option

Save adczk/81bf22bafd856e81d7d4fefae3e64429 to your computer and use it in GitHub Desktop.
Forminator - fix scroll issue for Guten Modal Block
<?php
/**
* Plugin Name: [Forminator Pro] - Fix Scroll Issue for forms inside Guten Modal Block plugin modal
* Description: [Forminator Pro] - Fix Scroll Issue
* Author: adczk based on Prashant Singh's solution for mobiles
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*
* USE A MU PLUGIN
*
* FORM MUST BE SET TO LOAD USING AJAX (otherwise this solution doesn't work)
*/
if ( ! defined( 'ABSPATH' ) ) { exit; } elseif ( defined( 'WP_CLI' ) && WP_CLI ) { return; }
add_action( 'wp_footer', function(){
?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$(document).on("after.load.forminator", function (e, id) {
$(document).on('click', '.forminator-pagination-footer .forminator-button', function(e){
var wpmu_scroll_top = $(window).scrollTop();
if (wpmu_scroll_top>0){
$("html,body").stop();
}
});
});
});
</script>
<?php
},9999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment