Skip to content

Instantly share code, notes, and snippets.

@rgadon107
Created June 27, 2017 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgadon107/bf504a9fbcc8c11da3a02f6620746f84 to your computer and use it in GitHub Desktop.
Save rgadon107/bf504a9fbcc8c11da3a02f6620746f84 to your computer and use it in GitHub Desktop.
Popup Maker Code Snippet - Footer Script to Reclick Last Clicked Link
<?php
add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );
/**
* Reclick the last clicked link upon form submission.
*
* @since v1.0.0
*
* @return void
*/
function my_custom_popup_scripts() { ?>
<script type="text/javascript">
(function ($, document, undefined) {
$('#pum-245').on('pumAfterClose', function() {
var $last_trigger = $();
try {
$last_trigger = $($.fn.popmake.last_open_trigger);
if ($last_trigger.length) {
$last_trigger.click();
}
} catch (error) { }
});
}(jQuery, document))
</script><?php
}
@rgadon107
Copy link
Author

From @danieliser (notes to Ticket #4581): Add some custom code like below to handle reclicking the last clicked link so they don't have to reclick it themselves after submission. The following code needs to be updated replacing #pum-245 with his popup ID #. Add it to his functions.php file.

Enable for interaction, or the function I gave will just retrigger the popup when they try to close it by reclicking the link again which triggers the popup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment