WP Popups includes several Javascript functions that can be used to control the popups programmatically. While you can check all the available ones in the window.wppopups object, we are going to list the most useful ones.
wppopups.showPopup(popup_id, force?): This function will let you open a popup programmatically
- popup_id: The ID of the popup you want to open.
- force (optional): “force” argument in case you want to force the opening even is one of the cookies is set.
wppopups.hidePopup(popup_id, conversion, time?, cookie?): This function will close the popup but it won’t destroy it, meaning that you could open it again later.
- popup_id: The ID of the popup you want to close.
- conversion: Boolean that indicates if you are closing because popup converted or not.
- time (optional): Milliseconds until the popup it’s finally close. Default to 0.
- cookie (optional): Boolean that indicates if you want to save cookies or not. Default to true
wppopups.removePopup(popup_id): Close and destroy a popup removing it from the DOM. Popup won’t open again until you refresh the page
- popup_id: The ID of the popup you want to remove.
wppopups.popupConverted(popup_id): Fires the conversion event and saves a cookie. This is called in hidePopup() but can be launched individually.
- popup_id: The ID of the popup you want to fire a conversion.
wppopups.popupClosed(popup_id): Fires the closing event and saves a cookie. This is called in hidePopup() but can be launched individually.
- popup_id: The ID of the popup you want to fire a closing event.
wppopups.togglePopups(show, conversion?): Show or hide all popups in the page.
- show: Boolean that indicates if the popups will be shown or closed. Default to close
- conversion (optional): Boolean to indicate if this is a conversion if popup it’s closing. Default to false.