Skip to content

Instantly share code, notes, and snippets.

View joshuafredrickson's full-sized avatar
🍊
Orange pineapple

Joshua Fredrickson joshuafredrickson

🍊
Orange pineapple
View GitHub Profile
@joshuafredrickson
joshuafredrickson / blocks.php
Created April 29, 2019 17:28
Updated config/blocks.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Register theme color palette
|--------------------------------------------------------------------------
|
| Colors defined in this array will be registered with the
@joshuafredrickson
joshuafredrickson / remove-exif.php
Last active December 21, 2023 10:10
WordPress Plugin: Automatically remove EXIF data from .jpgs when uploaded
<?php
/**
* Plugin Name: Remove EXIF data
* Plugin URI: https://gist.github.com/joshuafredrickson/cd5ab346992f533ecbe976d365fa36dd
* Version: 1.0.0
* Description: Remove EXIF data from .jpg when uploaded.
* Author: Joshua Fredrickson
* Author URI: https://joshuafredrickson.com
* License: GNU General Public License v2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@joshuafredrickson
joshuafredrickson / functions.php
Created February 12, 2019 17:13
WordPress: Create column-based add_image_sizes using Laravel collect()
<?php
/**
* Image sizes
* Finds the width for each column size based on a max container width (1600) and column count.
*/
collect([3, 6, 9, 12])->map(function($column) {
return add_image_size($column . '/12', $column / 12 * 1600);
});
@joshuafredrickson
joshuafredrickson / functions.php
Created February 12, 2019 16:05
WordPress: Generate @2x image sizes automatically.
<?php
/**
* @2x image sizes
*/
function make_it_retina($file, $width, $height, $crop = false) {
if ($width || $height) {
$resized_file = wp_get_image_editor($file);
if (!is_wp_error($resized_file)) {
$resized_file->resize($width * 2, $height * 2, $crop);
@joshuafredrickson
joshuafredrickson / no-nags.php
Created January 29, 2019 14:46
WordPress: Move all admin notices and plugin nags to console
add_action('plugins_loaded', function() {
$action = is_user_admin() ? 'user_admin_notices' : 'admin_notices';
add_action($action, function () {
ob_start();
});
add_action('all_admin_notices', function () {
$log = strip_tags(trim(ob_get_clean()));
@joshuafredrickson
joshuafredrickson / index.html
Last active August 7, 2017 16:49 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<html>
<head>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
@joshuafredrickson
joshuafredrickson / jqueryi-ui-fluid-dialog.js
Last active May 11, 2017 18:04
jQuery UI Dialog - Fluid on resize and scroll - Works with 1.11.4
$dialog.dialog({
draggable: false,
modal: true,
resizable: false,
maxWidth: 600,
width: 500,
fluid: true, // Enables fluidDialog()
});
function fluidDialog() {
@joshuafredrickson
joshuafredrickson / intuitive-custom-post-order.php
Created February 1, 2017 23:53
hijiriworld/intuitive-custom-post-order -- Scrap existing menu_order values after reordering.
// Fixes duplicate items showing up if the same menu_order is shared between two items across a page break.
// Replace update_menu_order() with the code below.
function update_menu_order()
{
global $wpdb;
parse_str( $_POST['order'], $data );
if ( !is_array( $data ) ) return false;
@joshuafredrickson
joshuafredrickson / functions.php
Created December 12, 2015 21:55
WordPress: Remove Edit Link
// Remove edit link
add_filter ( 'genesis_edit_post_link' , '__return_false' );
@joshuafredrickson
joshuafredrickson / functions.php
Created October 12, 2015 14:16
WordPress: Disable XML-RPC
// Disable XML-RPC
add_filter( 'xmlrpc_enabled', '__return_false' );