Skip to content

Instantly share code, notes, and snippets.

View chasecmiller's full-sized avatar

Crumbls chasecmiller

View GitHub Profile
@chasecmiller
chasecmiller / thePermalinkPDF.php
Created November 1, 2017 22:03
WordPress: Change PDF links in WordPress to link directly to the PDF instead of the attachment page
<?php
defined('ABSPATH') || exit(1);
add_filter('the_permalink', 'thePermalinkPDF');
add_filter('attachment_link', 'thePermalinkPDF');
// Automatically convert permalinks to PDFs in search results to the PDF itself, not the Attachment page
function thePermalinkPDF($permalink){
global $post;
if (get_post_mime_type($post->ID) != 'application/pdf') {
@chasecmiller
chasecmiller / plugin_debug.php
Last active September 9, 2019 23:03
Proof of concept of a WordPress mu-plugin to automatically disable plugins that start throwing errors.
<?php
/*
Plugin Name: Plugin Debugging Tool
Description: Attempt to automatically de-activate plugins that are causing errors. Doesn't always work. This must be installed in the mu-plugins directory.
Author: Chase C. Miller
Version: 1.0
Author URI: http://crumbls.com
*/
namespace Crumbls\Debug\Plugins;
@chasecmiller
chasecmiller / Example.php
Last active August 11, 2017 03:08
Move WordPress pre-existing attachments to S3 using WP Offload S3 Lite.
<?php
/**
* You can include this snippet anywhere.
* Just remove the reference once you're done.
* It checks to make sure files exist and are readable.
*
* If WP Offload S3 Lite is not installed, this won't do anything other than waste resources.
*
* Love the full plugin? Buy it!
@chasecmiller
chasecmiller / plugin.php
Last active November 1, 2017 22:22
Extending Category Meta Box in WordPress admin
<?php
namespace Crumbls\Plugins\MetaBoxAlternate;
defined('ABSPATH') or exit(1);
/*
Plugin Name: Allow a filterd list for bloated category lists in the admin meta box
Plugin URI: http://crumbls.com
Description: Example of creating a third tab on the category selection box. We used it to give our Editorial department the categories that we use for news stories, not similar category names.
@chasecmiller
chasecmiller / Plugin.php
Last active February 6, 2018 00:08
Wordpress - Materialized Path for Custom Post Types ( CPT ) and Built In Post Types
<?php
/*
Plugin Name: Materialized Paths
Plugin URI: http://crumbls.com
Description: Implement materialized paths for WordPress to enable simple searching for child and parent paths.
Author: Chase C. Miller
Version: 2.0.1a
Author URI: http://crumbls.com
Text Domain: Crumbls\Plugins\Materialized
*/
/**
* Here is a patch to bring Visual Composer into Event Espresso 4.
*
* Tested on Visual Composer 4.11 and Event Espresso 4.
*
* Instructions:
* 1) Add this to the end of functions.php or any is_admin() included file.
**/
add_action('admin_print_scripts', function() {