Skip to content

Instantly share code, notes, and snippets.

@tomjn

tomjn/splishsplosh.php Secret

Last active Aug 10, 2020
Embed
What would you like to do?
Turns off the Unsplash CDN hotlinking when using the Unsplash plugin ( for paranoid people )
<?php
/**
* Plugin Name: Splish Splosh
* Version: 1.0.1
* Author: Tom J Nowell
* Author URI: https://tomjn.com/
* Description: Turns off the Unsplash CDN when using the Unsplash plugin
* Requires PHP: 5.6
* Requires at least: 4.9
* License: GPLv2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
**/
add_action(
'plugins_loaded',
function () {
$plugin = \Unsplash\get_plugin_instance();
$hotlink = $plugin->hotlink;
remove_filter( 'content_save_pre', [ $hotlink, 'wp_get_attachment_url' ], 10 );
remove_filter( 'image_downsize', [ $hotlink, 'image_downsize' ], 10 );
remove_filter( 'the_content', [ $hotlink, 'hotlink_images_in_content' ], 99 );
remove_filter( 'wp_calculate_image_srcset', [ $hotlink, 'wp_calculate_image_srcset' ], 99 );
remove_filter( 'wp_get_attachment_image_src', [ $hotlink, 'wp_get_attachment_image_src' ], 10 );
},
1000,
0
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.