Skip to content

Instantly share code, notes, and snippets.

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

mark l chaves marklchaves

🏄‍♂️
View GitHub Profile
@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 );
@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_data_attribute.php
Last active March 3, 2025 09:35
Open a popup that dynamically loads a video based on the click open trigger using 1) data attribute or 2) 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 February 17, 2025 12:49
Send a query parameter to a form inside a Popup Maker popup