Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / close-popup-when-element-is-scrolled-into-view.js
Last active April 13, 2019 21:11
Close a popup if element is scrolled into view, reopen when it goes offscreen.
var was_closed = false;
jQuery(window).on('scroll', function () {
var footer = jQuery('#footer'),
footer_is_visible = footer.offset().top - jQuery(window).scrollTop() < footer.height(),
popup = PUM.getPopup(123),
popup_is_open = popup.hasClass('pum-active');
if (popup_is_open && footer_is_visible) {
PUM.close(123);
@danieliser
danieliser / hide-header-footer-in-iframe.css
Last active April 12, 2023 11:11
Automatically hide elements on your site if its loaded in an iframe. JavaScript is used to detect when in a frame and add a class to the <html> element. CSS can then be used to hide or show elements.
@danieliser
danieliser / togge-element-class-while-popup-open.js
Created November 28, 2018 07:30
Toggle a class on an element when a Popup Maker popup opens and closes.
jQuery('#pum-123')
.on('pumAfterOpen', function () {
jQuery('#some-button-id').addClass('popup-is-open');
})
.on('pumAfterClose', function () {
jQuery('#some-button-id').removeClass('popup-is-open');
});
@danieliser
danieliser / Counter.php
Created August 20, 2018 03:28
Simple & reusable PHP counter class & methods add, increase, decrease, subtract, and of course ability to run a callback when the value changes for permanat storage. Includes example usage for WordPress Post types and share count, like counts etc.
<?php
/******************************************************************************
* @Copyright (c) 2018, Code Atlantic *
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
<?php
add_action( 'init', 'my_custom_function' );
function my_custom_function () {
$popups = get_posts( array( 'post_type' => 'popup' ) );
foreach( $popups as $popup ) {
$popup = pum_get_popup( $popup->ID );
// Do stuff with $popup.
@danieliser
danieliser / plugin-privacy-privacy-policy-generator.php
Last active May 22, 2018 19:21
Add support to your plugin or theme for WordPress Privacy Policy Generator (GDPR Compliance).
<?php
/**
* Return the default suggested privacy policy content.
*
* @return string The default policy content.
*/
function plugin_get_default_privacy_content() {
return
'<h2>' . __( 'What personal data we collect and why we collect it' ) . '</h2>' .
@danieliser
danieliser / plugin-privacy-user-data-eraser.php
Created May 7, 2018 07:48
Add support to your plugin or theme for WordPress Personal Data Exporter (GDPR Compliancy).
<?php
/**
* Register eraser for Plugin user data.
*
* @param array $erasers
*
* @return array
*/
function plugin_register_erasers( $erasers = array() ) {
@danieliser
danieliser / plugin-privacy-user-data-exporter.php
Last active May 17, 2018 03:42
Add support to your plugin or theme for WordPress Personal Data Exporter (GDPR Compliancy).
<?php
/**
* Register exporter for Plugin user data.
*
* @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md
*
* @param $exporters
*
* @return array
@danieliser
danieliser / non-integrated-ajax-form-success.js
Last active December 3, 2020 06:15
Add support for non integrated form plugins inside Popup Maker. Methods for AJAX & Non-AJAX forms available.
/**
* If your forms process submissions via ajax/javascript this is the method you will need to use.
*
* The following function will handle everything on the Popup Maker side.
* You just need to get your form plugin to call this function when succesffully submitted with the popup ID field.
*
* Example usages. Read below to learn how to complete the full solution for your form plugin.
*
* Mileage will vary as every form & plugin does this in a different way.
* You will need to find out how to do something on successful submission.
@danieliser
danieliser / custom-mass-link-trigger.js
Last active May 27, 2021 19:59
Add a mass click trigger to many links and insert that links url into the popup forms field, then on submission redirect to specific url.