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 / functions.php
Created April 6, 2014 16:26
WordPress - Genesis: Modify breadcrumbs
// Modify breadcrumb arguments
add_filter( 'genesis_breadcrumb_args', 'sp_breadcrumb_args' );
function sp_breadcrumb_args( $args ) {
// $args['home'] = 'Home';
$args['sep'] = ' <span>&rsaquo;</span> ';
// $args['list_sep'] = ', '; // Genesis 1.5 and later
// $args['prefix'] = '<div class="breadcrumb">';
// $args['suffix'] = '</div>';
// $args['heirarchial_attachments'] = true; // Genesis 1.5 and later
// $args['heirarchial_categories'] = true; // Genesis 1.5 and later
@joshuafredrickson
joshuafredrickson / .htaccess
Last active August 7, 2017 21:05
.htaccess: Site speed improvements
# Expires Caching #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
@joshuafredrickson
joshuafredrickson / functions.php
Last active August 29, 2015 14:25 — forked from bitfade/gist:4555047
Remove empty p tags for custom shortcodes
// Remove empty p tags for custom shortcodes
add_filter('the_content', 'op_content_filter');
function op_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join('|',array('shortcode1'));
// opening tag
$rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
// closing tag
@joshuafredrickson
joshuafredrickson / functions.php
Created October 12, 2015 14:16
WordPress: Disable XML-RPC
// Disable XML-RPC
add_filter( 'xmlrpc_enabled', '__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 / 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 / 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 / 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 / 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 / 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);