Skip to content

Instantly share code, notes, and snippets.

Avatar
🏄‍♂️

mark l chaves marklchaves

🏄‍♂️
View GitHub Profile
@marklchaves
marklchaves / custom_url_contains_condition.php
Last active Sep 30, 2022
Popup Maker Custom Trigger PHP Function for Loading a Popup Based URL contains using the ATC extension
View custom_url_contains_condition.php
<?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 word "test" in it.
*
* Usage:
* 1) Install the Popup Maker Advanced Targeting Conditions extension.
* 2) Edit a popup.
* 3) Go to Popup Settings > Targeting.
@marklchaves
marklchaves / set_conditional_see_again_cookie.php
Last active Sep 21, 2022
Popup Maker: Manually Set a Conditional Cookie for a Popup
View set_conditional_see_again_cookie.php
@marklchaves
marklchaves / force_focus_on_name_field.php
Last active Jul 25, 2022
Force the focus on the name field in a CF7 form
View force_focus_on_name_field.php
<?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 Jul 22, 2022
Disable Popup Maker on a Product Archive Page
View disable-popup-maker-woocommerce-archive-page.php
<?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 Jul 15, 2022
Use CSS to specifically target only link text color that's inside a Popup Maker popup
View popup-maker-content-link-color-override.css
@marklchaves
marklchaves / send_video_link_to_popup.php
Last active Jul 13, 2022
Open a popup that plays a video based on the click open trigger using a query parameter
View send_video_link_to_popup.php
@marklchaves
marklchaves / replace_compliments_button.php
Last active Jun 23, 2022
Replace an HTML element if logged in as a subscriber
View replace_compliments_button.php
<?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 Jun 15, 2022
Randomly Display Banner Popups or Display Banner Popups for A/B (Split) Testing
View display_random_banner_popups.php
<?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 Jun 9, 2022
Send a link to a popup and use that link in the popup as a button
View send_link_to_popup.php
@marklchaves
marklchaves / launch_a_popup_if_cookie_consent_accepted.php
Created Jun 7, 2022
Launch a popup after cookie consent accepted
View launch_a_popup_if_cookie_consent_accepted.php