Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
aaronsummers / reset-acf-metabox.php
Last active March 19, 2021 14:09 — forked from electricbrick/reset-acf-metabox.php
Reset ACF Metabox Positions
<?php
$user_id = 1;
$custom_post_type = 'my_post_type';
function prefix_reset_metabox_positions(){
delete_user_meta( $user_id, 'meta-box-order_post' ); // Posts
delete_user_meta( $user_id, 'meta-box-order_page' ); // Pages
delete_user_meta( $user_id, 'meta-box-order_' . $custom_post_type ); // Custom post types
}
add_action( 'admin_init', 'prefix_reset_metabox_positions' );
@aaronsummers
aaronsummers / wp-post_status-change.SQL
Created March 9, 2021 21:39 — forked from micjamking/wp-post_status-change.SQL
Bulk update ALL WordPress post statuses in SQL
# Change post_type value if targeting 'page' or a custom post type
# Change ALL posts status from 'publish' to 'draft'
UPDATE wp_posts SET post_status = 'publish' WHERE (post_type = 'post' and post_status = 'draft')
@aaronsummers
aaronsummers / page-scroll.js
Created February 5, 2021 16:06
page scroll js
const body = document.body;
const scrollUp = "scroll-up";
const scrollDown = "scroll-down";
let lastScroll = 0;
window.addEventListener("scroll", () => {
const currentScroll = window.pageYOffset;
if (currentScroll <= 0) {
body.classList.remove(scrollUp);
return;
@aaronsummers
aaronsummers / mutation-observer.js
Created February 5, 2021 16:03
waypoint - scroll into view - mutation observer
// https://usefulangle.com/post/113/javascript-detecting-element-visible-during-scroll
var observer = new IntersectionObserver(function(entries) {
const body = document.body;
const scrollUp = "scroll-up";
const scrollDown = "scroll-down";
// isIntersecting is true when element and viewport are overlapping
// isIntersecting is false when element and viewport don't overlap
if(entries[0].isIntersecting === true) {
body.classList.add(scrollDown);
@aaronsummers
aaronsummers / custom-walker.php
Created January 15, 2021 15:29
Custom walker with nav icon ( presuming the nav icon is an SVG using file_get_contents() )
<?php
// In your functions.php
class Menu_Icon_Walker extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent\n";
@aaronsummers
aaronsummers / mailhog-mamp.md
Created November 5, 2020 14:50 — forked from jaredatch/mailhog-mamp.md
Install MailHog with MAMP Pro

Install MailHog with MAMP Pro, using HomeBrew.

MailHog

First let's make sure HB is updated. Open up terminal for the following steps.

$ brew update
@aaronsummers
aaronsummers / Remove .DS_Store from GIT repository.md
Last active October 1, 2020 14:55
Remove .DS_Store from GIT repository
@aaronsummers
aaronsummers / browser-back-button-fire-js.js
Created August 12, 2020 09:42
watch for back button page loads
/*
https://stackoverflow.com/questions/37838430/detect-if-page-is-load-from-back-button#answer-53317159
*/
/* CHROME */
if (window.performance) {
var navEntries = window.performance.getEntriesByType('navigation');
if (navEntries.length > 0 && navEntries[0].type === 'back_forward') {
console.log('As per API lv2, this page is load from back/forward');
} else if (window.performance.navigation
@aaronsummers
aaronsummers / plugin-directorys.php
Created July 31, 2020 10:00
Navigate Plugin Directory URL's WordPress
Let’s say current URL is: http://example.com/wp-content/plugins/my-plugin/includes/
Get the URL directory path (with trailing slash) for the plugin __FILE__ passed in.
<?php
echo plugin_dir_url( __FILE__ ) . 'images/placeholder.png';
// will output: http://example.com/wp-content/plugins/my-plugin/includes/images/placeholder.png
?>