Skip to content

Instantly share code, notes, and snippets.

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

mark l chaves marklchaves

🏄‍♂️
View GitHub Profile
@marklchaves
marklchaves / popup-maker-content-link-color-override.css
Last active July 15, 2022 00:13
Use CSS to specifically target only link text color that's inside a Popup Maker popup
@marklchaves
marklchaves / send_video_link_to_popup.php
Last active July 13, 2022 22:38
Open a popup that plays a video based on the click open trigger using a query parameter
@marklchaves
marklchaves / replace_compliments_button.php
Last active June 23, 2022 22:58
Replace an HTML element if logged in as a subscriber
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_filter( 'wp_footer', function() {
if ( !is_user_logged_in() ) return; // Don't do anything if not logged in.
global $current_user;
$user_roles = $current_user->roles;
// var_dump($user_roles); // Uncomment to debug role(s).
$user_role = array_shift( $user_roles ); // Look at the first role. Change this if needed.
if ( $user_role !== "subscriber") return; // Bail early if we don't have a subscriber.
@marklchaves
marklchaves / display_random_banner_popups.php
Last active June 15, 2022 12:49
Randomly Display Banner Popups or Display Banner Popups for A/B (Split) Testing
<?php // Ignore this first line when copying to your child theme's functions.php file.
function display_random_banner_popups() { ?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
// Customize these variables.
// ----------------------------------
const popups = [1100, 1102, 1104], // Comma separated popup IDs.
cookieName = "pum-split-test", // Cookie name for the A/B test only.
cookieTime = "1 minute"; // Cookie timer.
// ------------------------------
@marklchaves
marklchaves / send_link_to_popup.php
Last active June 9, 2022 08:42
Send a link to a popup and use that link in the popup as a button
@marklchaves
marklchaves / launch_a_popup_if_cookie_consent_accepted.php
Created June 7, 2022 04:50
Launch a popup after cookie consent accepted
@marklchaves
marklchaves / html-source-example-click-open-link.html
Last active June 3, 2022 06:46
Send a query parameter to a form inside a Popup Maker popup
@marklchaves
marklchaves / find-all-forms-and-missing-ids.js
Created June 1, 2022 02:44
Find all forms and flag forms with no IDs
let firstNoId = true;
let forms = [];
let noIds = [];
let out = "";
/** Place a border around forms with no ID set. */
document.querySelectorAll("form").forEach((f) => {
if (!f.hasAttribute("id")) {
if (firstNoId) {
firstNoId = false;
@marklchaves
marklchaves / force_signature_width.php
Last active June 1, 2022 02:00
Force Gravity Forms Signature Field Width
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action( 'wp_footer', function() { ?>
<script type="text/javascript">
// Convenience function to wrap multiple functions with timeouts.
function createFunctionWithTimeout(callback, optTimeout) {
let called = false;
function fn() {
if (!called) {
@marklchaves
marklchaves / add_js_cookie_enqueue_script.php
Last active May 27, 2022 01:40
Use the js-cookie API to set a cookie when download page loads