Skip to content

Instantly share code, notes, and snippets.

View marklchaves's full-sized avatar
🏄‍♂️

mark l chaves marklchaves

🏄‍♂️
View GitHub Profile
@marklchaves
marklchaves / increment_gravity_forms_view_counter.php
Last active March 13, 2023 13:20
Bypass the default GF view counter logic so we count views for forms inside a popup only when the popup shows the form
<?php // Ignore this first line when copying to your child theme's functions.php file.
/**
* According to Gravity Forms Support on 9 March 2023, "The views column records the number of times the
* form markup is generated ... including when the form is redisplayed following validation errors.
* It's not strictly how many times the form was actually viewed."
*
* That means the Gravity Forms form view counter gets bumped up even if the form is hidden in a tab, popup, slider, and
* accordion (to name a few). Bottom line: don't trust the form view counter as a valid impression stat.
*/
@marklchaves
marklchaves / display-popup-trigger-settings-chrome-snippet.js
Last active March 2, 2023 08:45
Prompt for a popup ID number and then display the trigger settings for that popup ID in a table format.
const popupID = prompt("What's the popup ID number?");
if (typeof PUM !== 'undefined') {
let triggers = PUM.getSettings(popupID).triggers[0];
if (typeof triggers !== 'undefined') {
console.log(`%cTrigger Settings for Popup ID ${popupID}`,
"color: #b92099; font-size: 20px;");
console.table(triggers); // Triggers
if (typeof triggers.settings !== 'undefined') {
console.table(triggers.settings); // Cookies
//console.table(PUM.getSettings(input).triggers[0][1].settings); // Displays cookie name`
@marklchaves
marklchaves / create_wildcard_domain_cookie.php
Last active January 31, 2023 02:08
Create a wildcard domain cookie when a Popup Maker popup opens
@marklchaves
marklchaves / archive.php
Last active January 8, 2023 13:07
WP ULike Proof of Concept
<?php
/**
* Override the theme template for displaying archive pages.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Twenty_One
* @since Twenty Twenty-One 1.0
*/
@marklchaves
marklchaves / wrapImagesWithLink.js
Created November 6, 2022 07:43
Wrap images with an a (link) tag
@marklchaves
marklchaves / set_popup_cookie_on_confirmation.php
Last active December 8, 2022 22:54
Set Popup Maker Cookie after Form Submission Redirect
@marklchaves
marklchaves / custom_url_contains_condition.php
Last active May 15, 2023 00:01
Popup Maker Custom Trigger PHP Function for Loading a Popup Based URL contains using the ATC extension
<?php // Ignore this first line when copying to your child theme's functions.php file.
/**
* This PHP function will load a popup on a post or page only if the URL
* contains the string "yourstringgoeshere" in it.
*
* Usage:
* 1) Install the code snippet below. Make sure you change "yourstringgoeshere" to the string that'll
* be in your URL that you want to launch the popup. Example: https://twenty-twentyone.test/yourstringgoeshere/
* 2) Install the Popup Maker Advanced Targeting Conditions extension.
@marklchaves
marklchaves / set_conditional_see_again_cookie.php
Last active September 21, 2022 08:25
Popup Maker: Manually Set a Conditional Cookie for a Popup
@marklchaves
marklchaves / force_focus_on_name_field.php
Last active July 25, 2022 13:11
Force the focus on the name field in a CF7 form
<?php // Ignore this first line when copying to your child theme's functions.php file.
<style>
/** For testing only. Remove for production. */
:focus {
outline: 3px solid hotpink !important;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function ($) {
@marklchaves
marklchaves / disable-popup-maker-woocommerce-archive-page.php
Created July 22, 2022 00:04
Disable Popup Maker on a Product Archive Page
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action( 'wp', function() {
if ( is_product_category() ) { // echo '<h4>This is an archive page.</h4>';
add_filter ( 'pum_popup_is_loadable', function( $is_loadable ) {
$is_loadable = false;
return $is_loadable;
} );
}
}, 9 );