Skip to content

Instantly share code, notes, and snippets.

View heyfletch's full-sized avatar
🏠
Working from home

Joe Fletcher heyfletch

🏠
Working from home
View GitHub Profile
git archive --output="../plugin-name.zip" HEAD
# files to exclude, put in .gitattributes in the root dir. Syntax:
# /.gitattributes export-ignore
# /.gitignore export-ignore
# /LICENSE export-ignore
# /README.md export-ignore
"files.exclude": {
"wp-admin/": true,
"wp-includes/": true,
"index.php": true,
"license.txt": true,
"readme.html": true,
"wp-activate.php": true,
"wp-blog-header.php": true,
"wp-comments-post.php": true,
"wp-config-sample.php": true,
/* Update here: https://gist.github.com/heyfletch/8f5931292d3148bb64bc6e5e3a0235bc/ */
#wp-admin-bar-happy-addons,
.googlesitekit-cta,
#footer-left,
#cpt_info_box,
.notice.elementor-message,
div#autoptimize_admin_feed,
a[href="?page=ao_partners"],
#c2c,
@heyfletch
heyfletch / fd_purge_all_cache.php
Created January 27, 2022 18:53
Purge Multiple WordPress Caches in Ideal Order
<?php
// Clears Page Cache at key moments, e.g., after plugin updates
// Importantly, it clears the page when WP Rocket clears cache
// If Cloudflare page caching is enabled, this clears the nginx page cache before Cloudflare's cache
add_action( 'before_rocket_clean_domain', 'fd_purge_all_cache', 10, 0 ); // Before WP Rocket Cache
add_action( 'upgrader_process_complete', 'fd_purge_all_cache', 10, 0 ); // After plugin updates
add_action( 'activated_plugin', 'fd_purge_all_cache', 10, 0 ); // After plugin activated, doesn't work?
add_action( 'deactivated_plugin', 'fd_purge_all_cache', 10, 0 ); // After plugin deactivated, broken?
@heyfletch
heyfletch / click-scroll.js
Last active March 3, 2022 14:54
jQuery On Click Scroll to Element and Click
jQuery(function($){ // use $
let myClick = 'a[href^="#guidelines"]';
let myTarget = '#elementor-tab-title-1356';
let mySpeed = 'fast';
let myOffset = 20;
$(myClick).click(function() {
let toScroll = $(myTarget).offset().top - myOffset;
$(myTarget).click();
$('html, body').animate({scrollTop: toScroll}, mySpeed);