Created
March 2, 2014 04:05
-
-
Save nicholasohrn/9301743 to your computer and use it in GitHub Desktop.
Ridiculously Naive Image Protection Plugin
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: Ridiculously Naive Image Protection | |
Description: Enables ridiculously naive image protection. Disables contextmenu and dragstart on images using jQuery's event handling. That's it! | |
Version: 1.0.0.B.1 | |
Author: Nick Ohrn | |
Author URI: http://nickohrn.com/ | |
*/ | |
function image_protector_wp_enqueue_scripts() { | |
wp_enqueue_script('jquery'); | |
} | |
add_action('wp_enqueue_scripts', 'image_protector_wp_enqueue_scripts'); | |
function image_protector_output_javascript() { | |
echo '<script type="text/javascript">jQuery(document).ready(function($) { $(document).on("contextmenu dragstart", "img", function(event) { event.preventDefault(); }) });</script>'; | |
} | |
add_action('wp_footer', 'image_protector_output_javascript'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment