Skip to content

Instantly share code, notes, and snippets.

View mmirus's full-sized avatar

Matt Mirus mmirus

  • Front Royal, VA, USA
View GitHub Profile
@chrisguitarguy
chrisguitarguy / proper.php
Last active May 22, 2019 16:39
How to properly do a `save_post` callback
<?php
add_action('save_post', 'cgg_proper_save_post', 10, 2);
// first off: it doesn't matter if you return anything from this function
// `save_post` is an action, nothing is done with the return values of its
// callbacks. You're free to return $post_id if you want, obviously, but
// it's not a filter.
function cgg_proper_save_post($post_id, $post)
{
@mkrdip
mkrdip / remove-gf-divi.php
Last active January 13, 2021 13:32
Remove Google Fonts from Divi
<?php
function wpse_dequeue_google_fonts() {
wp_dequeue_style( 'divi-fonts' );
}
add_action( 'wp_enqueue_scripts', 'wpse_dequeue_google_fonts', 20 );
@prasetyop
prasetyop / admin.css
Last active March 13, 2023 13:33
Flexible Content Preview Pop Up
.acf-fc-popup .preview {
position: absolute;
right: 100%;
margin-right: 0px;
top: 0;
background: #383c44;
min-height: 100%;
border-radius: 5px;
align-content: center;
display: grid;
@mtx-z
mtx-z / wp-bootstrap4.4-pagination.php
Last active April 4, 2023 12:55
Wordpress 5.4 Bootstrap 4.4 pagination (with custom WP_Query() and global $wp_query support) (UPDATED for Bootstrap 5: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* UPDATE for Bootstrap 5.0: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507
*
#!/bin/bash
# Regolith aka Un-Bedrock
# "But what if we need to hand it off to another agency?" No more!
# This script converts a Bedrock site to a normal WordPress structure.
# Run it from the root of a Bedrock project.
# Created by Nathan Knowler and Daniel Roe
echo "Converting Bedrock to a normal WordPress file structure..."
@austinpray
austinpray / bad.jsx
Last active September 19, 2018 19:43
PostListing Refactor. I'm using .jsx filenames so I can get proper filenames in the gist use .js or typescript in your project
import React from 'react'
const PostListing = ({post}) => (
<article>
<h3>{post.frontmatter.title}</h3>
<span>{post.frontmatter.date}</span>
<p>{post.excerpt}</p>
</article>
)
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active October 24, 2024 18:10
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@bikubi
bikubi / README.md
Created March 1, 2019 12:39
Simple Purgecss setup for Roots Sage WordPress starter theme

Why

  1. Sage doesn't come with Purgecss (or uncss, etc.)
  2. Say, we use Bulma -- suddenly dist/main.css grows by 400K!
  3. Let's purge it!
  4. Oh dang, we need to whitelist /\.wp-/, /\.post-type/, /myfancylightbox/...
  5. Wait we are whitelisting pretty much everything from /resource/assets/styles!
  6. Isn't there an option to purge /node_modules/**/* only?
  7. Nope.
  8. purgecss start ignore, strategically placed, to the rescue!
@castwide
castwide / rails.rb
Last active October 24, 2024 16:26
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
@Log1x
Log1x / windows.md
Last active March 13, 2022 13:33
Some stuff I use on Windows

Windows Setup

Screenshot

This contains various software and tools I use for customizing Windows.

Warning: Installing a bad Windows theme can render your system unusable (dwm.exe crash-loop – "black screen of death") due to resource map changes.

  • Always match your winver.exe build to the theme you're installing.
  • Before major build updates, always change back to a default windows theme.