-
-
Save tomjn/a7036d369d6f8082dd1eb256c651696e to your computer and use it in GitHub Desktop.
Turns off the Unsplash CDN hotlinking when using the Unsplash plugin ( for paranoid people )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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