Skip to content

Instantly share code, notes, and snippets.

View danieliser's full-sized avatar

Daniel L. Iser danieliser

View GitHub Profile
@danieliser
danieliser / popup-content.html
Created December 30, 2019 19:10
Never show popup again checkbox
<label>
<input type="checkbox" onclick="PUM.close(123); jQuery.pm_cookie('pum-123', true, '10 years', '/');" />
Never Show Again
</label>
@danieliser
danieliser / Get Popup ID from slug.js
Created November 13, 2019 08:02
Get Popup ID from slug
function getPopupIDFromSlug(slug) {
var popups = Object.values(pum_vars.popups);
for(var i = 0; i < popups.length; i++) {
if (popups[i].slug === slug) {
return popups[i].id;
}
}
return null;
}
@danieliser
danieliser / subscribe-to-download-popup-maker-ninja-forms.js
Last active November 24, 2024 05:15
Javascript used to set the value of a hidden form field inside a popup based on the url of a click trigger.
(function ($) {
var popupID = 123,
hiddenFieldSelector = '#nf-field-1';
$(document).on('pumBeforeOpen', '#pum-'+popupID, function () {
var trigger = $.fn.popmake.last_open_trigger[0],
field = $(hiddenFieldSelector);
if (trigger && "" !== trigger.href) {
field.val(trigger.href);
@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 August 6, 2024 18:22
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() ) {