Skip to content

Instantly share code, notes, and snippets.

@joeyblake
joeyblake / .htaccess
Created December 11, 2019 21:54
WordPress cache enabler plugin
# BEGIN Cache Enabler
#
# This version is meant for Apache 2.3.9 or later.
#
# Reference: https://www.keycdn.com/support/wordpress-cache-enabler-plugin#apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# set blog sub path
@joeyblake
joeyblake / filters.php
Created June 5, 2020 12:15
Filter for correcting carbonfields file field type metadata lookup
<?php
add_filter( 'carbon_fields_attachment_id_from_url' , __NAMESPACE__ . '\get_attachment_id_from_url', 10, 2 );
function get_attachment_id_from_url( $attachment_id, $url ) {
if ( 0 === $attachment_id ) {
$dir = wp_upload_dir();
$filename = basename( $url );
$filename = str_replace( [ '.doc', '.pdf', '.xls' ], [ '-doc', '-pdf', '-xls' ], $filename );
$filename .= '.jpg';