Skip to content

Instantly share code, notes, and snippets.

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

mark l chaves marklchaves

🏄‍♂️
View GitHub Profile
@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
@marklchaves
marklchaves / only_one_mobile_submenu_at_a_time.php
Last active March 25, 2022 12:47
Open One Avada Mobile Submenu Item at a Time
<?php // Ignore this first line when copying to your child theme's functions.php file.
function only_one_mobile_submenu_at_a_time() { ?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$( 'button.fusion-open-submenu' ).on( 'click', function() {
$( 'button.fusion-open-submenu' ).not( $( this ) ).removeClass( 'chevron--up' );
$( this ).toggleClass( 'chevron--up' );
$( this ).parent( 'li.menu-item-has-children' ).siblings().find( '.sub-menu' ).removeClass( 'fusion-sub-menu-open' ).attr( 'style', 'display: none;' );
} ); // Click
@marklchaves
marklchaves / popup_name_sc.php
Last active September 29, 2022 22:38
Make a shortcode for a popup's name (not the title)
<?php // Ignore this first line when copying to your child theme's functions.php file.
/**
* Make a shortcode for a popup's name (not the title)
*
* Note: The popup's internal name is actually the CPT's title.
* The internal name is different from the popup's title.
*
* The popup's title is optional. If you enter a popup title,
* it displays as the heading of your popup (external title).
@marklchaves
marklchaves / set_never_see_again_cookie.php
Last active March 10, 2022 23:41
Example for Manually Setting a Cookie for a Popup Maker Popup
@marklchaves
marklchaves / avada-make-weekday-tab-active.php
Last active March 24, 2022 22:49
Make Today's Weekday Tab Active in the Avada WordPress Theme
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action('wp_footer', function () {
// Only do for a post called Weekday Tabs just to avoid page bloat. Change to your
// post or page (is_page()) or remove this check if wanted.
if (!is_single('weekday-tabs')) return; ?>
<script>
(function() {
// Init some consts.
const weekDays = [
"Monday",
@marklchaves
marklchaves / popup-maker-test-rest-api-call.php
Last active June 29, 2022 11:12
Check if adblockers like Ghostery block Popup Maker REST API calls
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action( 'wp_footer', function () { ?>
<script>
(function () {
function testRestApi(url, cb) {
jQuery.ajax({
url: url,
dataType: "text",
type: "GET",
@marklchaves
marklchaves / open_delayed_popup_after_cookie_confirmation.php
Last active February 25, 2022 04:24
Open a Delayed Popup After Cookie Confirmation
@marklchaves
marklchaves / add-favorite-menu-items-to-top-right-menubar.php
Created February 22, 2022 03:49
Put my go-to menu items in the top-right admin toolbar ;-)
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action('admin_bar_menu', function(WP_Admin_Bar $admin_bar) {
// Plugins
$admin_bar->add_menu( array(
'id' => 'my-plugins',
'parent' => 'top-secondary',
'title' => 'Plugins',
'href' => 'plugins.php',
'meta' => array(