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_auto_close_then_redirect.php
Last active February 18, 2022 11:13
Launch a Popup Maker popup from a link, automatically close the popup after 8 seconds, and redirect to the link that originally launched the popup
<?php // Ignore this first line when copying to your child theme's functions.php file.
function auto_close_then_redirect()
{ ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// ADD CUSTOM CODE HERE
let myRedirectURL = "/"; // Default to the homepage
@marklchaves
marklchaves / popup_maker_pum_popup_content_filter.php
Created January 18, 2022 05:31
Popup Maker: Filter popup content
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_filter( 'pum_popup_content', function( $message ) {
return '<div><p>Hello, World! This is a popup from Popup Maker :-)</p></div>' . $message;
} );
/**
* You can add the PHP code snippet to your child theme's functions.php file
* or with third-party plugins such as My Custom Functions and Code Snippets.
* /
@marklchaves
marklchaves / popup_create_cookie_when_click.php
Last active January 3, 2022 01:54
Popup Maker: Create a cookie when there's a click inside a popup
@marklchaves
marklchaves / avada-responsive-table.css
Last active January 1, 2022 23:58
Avada Responsive Table for Phones
/**
* The first step is to set the width of the table (or wrapper) to 100%.
* This should take care of desktops, laptops, and tablets depending on
* how many columns you have.
*
* For the second step, you can follow the suggestion from CSS tricks
* to reformat the table for phones. The CSS below will reformat the table
* to:
* - Create logical groups of info for each row
* - For each group, turn each column into a row that belongs to its logical
@marklchaves
marklchaves / avada_forms_hidden_field_set_doc_url.php
Last active June 20, 2022 18:40
Add document.url as a hidden field
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action( 'wp_footer', function () { ?>
<script>
(function() {
if (document.title !== "Test Form – Avada Lab") return; // Run this script on the test form page only.
try {
document.querySelector("#doc-url").setAttribute("value", document.URL);
} catch (e) {
@marklchaves
marklchaves / content-control-shortcodes-for-partial-page-restrictions.md
Last active December 13, 2021 03:13
Content Control Plugin Shortcodes for Partial Page Restrictions

If you leave out the optional message parameter the Default Denial Message under the Content Control Settings will kick in.

Each example below has a custom denial message that overrides the default message.

1) For Logged Out Peeps

Specifying logged_out="1" is what makes the magic happen.

[content_control logged_out="1" message="Please log out."]Whew! We're so glad you're not logged in right now :-)[/content_control]

@marklchaves
marklchaves / add_top_banner.php
Created November 29, 2021 02:20
Example using wp_body_open hook to add a top banner
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action('wp_body_open', function() { ?>
<style>
.top-banner {
background-color: firebrick;
color: white;
display: grid;
font-size: 2rem;
height: 10vmin;
@marklchaves
marklchaves / show_ocean_custom_menu_7_only_to_admins.php
Last active November 16, 2021 03:45
WordPress PHP hook to only show the Ocean Custom Menu 7 widget to administrators
<?php // Ignore this first line when copying to your child theme's functions.php file.
/**
* Only show the Ocean Custom Menu 7 widget to admins.
*/
add_action( 'wp_head', function () {
if ( ( is_user_logged_in() ) && ( in_array( 'administrator', wp_get_current_user()->roles ) ) ) {
return; // Don't hide anything since we're an admin!
}
@marklchaves
marklchaves / avada_my_portfolio_learn_more_link.php
Last active November 14, 2021 22:53
Override Avada Portfolio Learn More Text
@marklchaves
marklchaves / launch_custom_cf7_thank_you_popup.php
Last active November 11, 2021 02:19
Launch a custom CF7 thank you popup
/**
* Add custom JavaScript for Popup Maker to the footer of your site.
*
* Reference https://contactform7.com/dom-events/
*/
function launch_custom_cf7_thank_you_popup() { ?>
<script type="text/javascript">
document.addEventListener( 'wpcf7submit', function( event ) {
PUM.open(123); // Change 123 to your popup's ID.