No Right Click Images Plugin - Version 3.0

Version Description

  • Completely rewrote the plugin javascript. It uses a different set of functions to stop the right click.
  • Major rewrite of the plugin loading method.
  • Removed javascript that did nothing. Just the bare bones settings are included now.
Download this release

Release Info

Developer willjenkins
Plugin Icon wp plugin No Right Click Images Plugin
Version 3.0
Comparing to
See all releases

Code changes from version 2.5 to 3.0

includes/nrci_options.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit; // just in case
4
+
5
+
6
+ function kpg_no_rc_img_control_2() {
7
+
8
+ if(!current_user_can('manage_options')) {
9
+ die('Access Denied');
10
+ }
11
+ $drag="Y";
12
+ $touch="Y";
13
+ $gesture="Y";
14
+ $allowforlogged="N";
15
+ $options=kpg_nrci_get_options();
16
+ extract($options);
17
+ // check for update submit
18
+ if (array_key_exists('kpg_nrci_update',$_POST)&&wp_verify_nonce($_POST['kpg_nrci_update'],'kpg_nrci_update')) {
19
+ // need to update replace
20
+ if (array_key_exists('kpg_drag',$_POST)) {
21
+ $drag=stripslashes($_POST['kpg_drag']);
22
+ } else {
23
+ $drag='N';
24
+ }
25
+ if (array_key_exists('kpg_touch',$_POST)) {
26
+ $touch=stripslashes($_POST['kpg_touch']);
27
+ } else {
28
+ $touch='N';
29
+ }
30
+ if (array_key_exists('kpg_gesture',$_POST)) {
31
+ $gesture=stripslashes($_POST['kpg_gesture']);
32
+ } else {
33
+ $gesture='N';
34
+ }
35
+ if (array_key_exists('kpg_allowforlogged',$_POST)) {
36
+ $allowforlogged=stripslashes($_POST['kpg_allowforlogged']);
37
+ } else {
38
+ $allowforlogged='N';
39
+ }
40
+ // update options
41
+ $options['drag']=$drag;
42
+ $options['touch']=$touch;
43
+ $options['gesture']=$gesture;
44
+ $options['allowforlogged']=$allowforlogged;
45
+ update_option('kpg_no_right_click_image',$options);
46
+
47
+ }
48
+ $nonce=wp_create_nonce('kpg_nrci_update');
49
+
50
+ ?>
51
+
52
+ <div class="wrap" style="position:relative;">
53
+ <h2>No Right Click Images Plugin</h2>
54
+ <h4>The No Right Click Images Plugin is installed and working correctly.</h4>
55
+ <div style="float:left;width:calc(100% - 245px);">
56
+ <p>&nbsp;</p>
57
+ <form method="post" action="">
58
+ <input type="hidden" name="action" value="update" />
59
+ <input type="hidden" name="kpg_nrci_update" value="<?php echo $nonce;?>" />
60
+ <fieldset style="border:thin solid black;padding:6px;width:100%;">
61
+ <legend> <span style="font-weight:bold;font-size:1.5em">Options</span> </legend>
62
+ Allow Right Click for Logged Users:
63
+ <input type="checkbox" <?php if ($allowforlogged=='Y') {echo 'checked="true"';} ?> value="Y" name="kpg_allowforlogged" />
64
+ You may wish to allow logged in users to copy images. You can do this by checking this box. <br />
65
+ Disable Dragging of images:
66
+ <input type="checkbox" <?php if ($drag=='Y') {echo 'checked="true"';} ?> value="Y" name="kpg_drag" />
67
+ This will prevent images from being dragged to the desktop or image software <br />
68
+ Disable Touch events:
69
+ <input type="checkbox" <?php if ($touch=='Y') {echo 'checked="true"';} ?> value="Y" name="kpg_touch" />
70
+ Prevents touch events on images, but if images are used as links or buttons this may cause problems. <br />
71
+ Disbale Gesture events:
72
+ <input type="checkbox" <?php if ($gesture=='Y') {echo 'checked="true"';} ?> value="Y" name="kpg_gesture" />
73
+ Prevents some gestures. If you site uses image gestures for images this may cause problems. <br />
74
+ </fieldset>
75
+ <br>
76
+ <input type="submit" name="Submit" class="button-primary" value="<?php echo("Save Changes"); ?>" />
77
+ </form>
78
+ <p>This plugin installs a little javascript in your pages. When your page finishes loading, the javascript sets properties the images to supress the context menu. This prevents casual users from using the copy function to grab an image.</p>
79
+ <p>There are many ways to bypass this plugin and it is impossible to prevent a determined and resourceful user from stealing images, but this plugin will prevent casual users from glomming your images.</p>
80
+ <p>The context menu is disabled on images and simple elements with background images, but will not work in some cases depending on which element receives the mouse click.</p>
81
+ <p>If you have uploaded your images to WordPress so that the images from the gallery can be opened in their own window, then this plugin will not work on the clicked image.</p>
82
+ <br>
83
+ <fieldset style="border:thin solid black;padding:6px;width:100%;">
84
+ <legend> <span style="font-weight:bold;font-size:1.5em">Support the Programmer</span> </legend>
85
+ <p>If you feel that you"d like to encourage me, you could <a href="https://www.amazon.com/default/e/B004C64N24">buy one of my books</a>. I write short stories for fun and I have sold about 50 stories to various
86
+ magazines. The books are cheap and very interesting.</p>
87
+ <p>You can also donate a few dollars. Cash is a little short right now, so my wife convinced me to go the low road and ask for money. There are three levels of donations.
88
+ <br>First, at $2.50 you can support me. I like this level because it does not put any stress on you. I think everyone can afford this without any pain.
89
+ <br>Second, for those who think they owe a little more, I have a $9.99 level. This is for those who have money to burn and drive expensive sports cars.
90
+ <br>Last, there is the $29.99 level. I don"t expect anyone to use this level, but there are possibly a few sysops with a company credit card, and an unlimited budget who might sympathize with a fellow coder and click this button.</p>
91
+ <p>You can pay using PayPal. All you need is a credit card. There is no account required. Just click and follow the instructions. You can request a refund and I will gladly comply.</p>
92
+ <table style="border:grey solid thin;min-width:50%">
93
+ <thead>
94
+ <tr style="background-color:ivory;">
95
+ <th>Support Level</th>
96
+ <th>PayPal</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td>Level 1) $2.50 <br />
102
+ Grateful User</td>
103
+ <td><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
104
+ <input name="cmd" type="hidden" value="_s-xclick" />
105
+ <input name="hosted_button_id" type="hidden" value="9V4ZE99S2VYQA" />
106
+ <input alt="PayPal - The safer, easier way to pay online!" name="submit"
107
+ src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" />
108
+ <img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
109
+ </form></td>
110
+ </tr>
111
+ <tr>
112
+ <td>Level 2) $9.99 <br />
113
+ Generous Benefactor</td>
114
+ <td><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
115
+ <input name="cmd" type="hidden" value="_s-xclick" />
116
+ <input name="hosted_button_id" type="hidden" value="2UCJBHR44HQAJ" />
117
+ <input alt="PayPal - The safer, easier way to pay online!" name="submit"
118
+ src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" />
119
+ <img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
120
+ </form></td>
121
+ </tr>
122
+ <tr>
123
+ <td>Level 3) $29.99 <br />
124
+ Wealthy patron</td>
125
+ <td><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
126
+ <input name="cmd" type="hidden" value="_s-xclick" />
127
+ <input name="hosted_button_id" type="hidden" value="EG83EZCTGYYQQ" />
128
+ <input alt="PayPal - The safer, easier way to pay online!" name="submit"
129
+ src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" />
130
+ <img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
131
+ </form></td>
132
+ </tr>
133
+ </tbody>
134
+ </table>
135
+ </fieldset>
136
+ </div>
137
+ <div style="width:220px;float:right;">Powered By <a href="http://www.siteground.com/recommended?referrer_id=6975888" target="_blank">SiteGround.com</a>
138
+ <?php
139
+ echo "<h4>Plugin Support Forum</h4>";
140
+ echo '<ol>';
141
+ display_feed('https://wordpress.org/support/rss/plugin//no-right-click-images-plugin');
142
+ echo '</ol>';
143
+ ?>
144
+ </div>
145
+ <div style="width:220px;float:right;clear:right">
146
+ <?php
147
+ echo "<h4>Posts at BlogsEye.com</h4>";
148
+ echo '<ol>';
149
+ display_feed('http://www.blogseye.com/feed.xml');
150
+ echo '</ol>';
151
+ ?>
152
+ </div>
153
+ </div>
154
+ <?php }
155
+
156
+
157
+ function display_feed($url) {
158
+ // quick and dirty get_rss replacement
159
+ include_once( ABSPATH . WPINC . '/feed.php' );
160
+
161
+ // Get a SimplePie feed object from the specified feed source.
162
+ $rss = fetch_feed( $url );
163
+ $maxitems=0;
164
+ if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
165
+
166
+ // Figure out how many total items there are, but limit it to 5.
167
+ $maxitems = $rss->get_item_quantity( 10 );
168
+
169
+ // Build an array of all the items, starting with element 0 (first element).
170
+ $rss_items = $rss->get_items( 0, $maxitems );
171
+
172
+ }
173
+ ?>
174
+ <ul>
175
+ <?php if ( $maxitems == 0 ) { ?>
176
+ <li>
177
+ <?php _e( 'No items', 'my-text-domain' ); ?>
178
+ </li>
179
+ <?php } else { ?>
180
+ <?php // Loop through each feed item and display each item as a hyperlink. ?>
181
+ <?php foreach ( $rss_items as $item ) { ?>
182
+ <li> <a href="%3C?php%20echo%20esc_url(%20$item-%3Eget_permalink()%20);%20?%3E"
183
+ title="<?php printf( __( "Posted %s", "my-text-domain" ), $item->get_date("j F Y | g:i a") ); ?>"> <?php echo esc_html( $item->get_title() ); ?> </a> </li>
184
+ <?php } ?>
185
+ <?php } ?>
186
+ </ul>
187
+ <?php
188
+
189
+ }
190
+ // end of module
191
+
192
+ ?>
no-right-click-images-plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: No Right Click Images Plugin
4
  Plugin URI: http://www.BlogsEye.com/
5
  Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
6
- Version: 2.5
7
  Author: Keith P. Graham
8
  Author URI: http://www.BlogsEye.com/
9
 
@@ -13,172 +13,45 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
  */
14
  if (!defined('ABSPATH')) exit; // just in case
15
 
16
- // (second time updating WordPress repository)
17
 
18
- /************************************************************
19
- * kpg_no_rc_img_fixup()
20
- * Shows the javascript in the footer so that the image events can be adjusted
21
- *
22
- *************************************************************/
23
- function kpg_no_rc_img_fixup() {
24
- // this is the No Right Click Images functionality.
25
- // now we have to get the options
26
-
27
- $options=get_option('kpg_no_right_click_image');
28
- if (empty($options)||!is_array($options)) $options=array();
29
- $replace='N';
30
- $drag='Y';
31
- $allowforlogged='N';
32
- $altimg='';
33
- extract($options);
34
- if ($replace!='Y') $replace='N';
35
- if ($drag!='Y') $drag='N';
36
- if ($allowforlogged!='Y') $allowforlogged='N';
37
- if (empty($cell)) $cell='N';
38
- if ($cell!='Y') $cell='N';
39
- // if the user is logged in and the option is set, let them copy images
40
- if ($allowforlogged=='Y' && is_user_logged_in() ) { return; }
41
- $dir = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
42
- $img = addslashes($dir.'not.gif');
43
- $js = addslashes($dir.'no-right-click-images.js');
44
- $altimg=trim($altimg);
45
- if (!empty($altimg)) $img=$altimg;
46
-
47
- ?>
48
- <script language="javascript" type="text/javascript">var kpg_cell="<?php echo $cell; ?>";var kpg_nrci_image="<?php echo $img; ?>";var kpg_nrci_extra="<?php echo $replace; ?>";var kpg_nrci_drag="<?php echo $drag; ?>";</script>
49
- <script language="javascript" type="text/javascript" src="<?php echo $js; ?>"></script>
50
 
51
- <?php
52
- }
53
- function kpg_no_rc_img_control() {
54
- $options=get_option('kpg_no_right_click_image');
55
- if (empty($options)||!is_array($options)) $options=array();
56
- $replace='N';
57
- $drag='Y';
58
- $allowforlogged='N';
59
- $altimg='';
60
- extract($options);
61
- if ($replace!='Y') $replace='N';
62
- if (empty($drag)) $drag='Y';
63
- if ($drag!='Y') $drag='N';
64
- if (empty($cell)) $cell='N';
65
- if ($cell!='Y') $cell='N';
66
- if ($allowforlogged!='Y') $allowforlogged='N';
67
- if (array_key_exists('kpg_no_rc_nonce',$_POST)&&wp_verify_nonce($_POST['kpg_no_rc_nonce'],'kpg_no_rc')) {
68
- // need to update replace
69
- if (array_key_exists('kpg_replace_image',$_POST)) {
70
- $replace=stripslashes($_POST['kpg_replace_image']);
71
- } else {
72
- $replace='N';
73
- }
74
- if (array_key_exists('kpg_prevent_drag',$_POST)) {
75
- $drag=stripslashes($_POST['kpg_prevent_drag']);
76
- } else {
77
- $drag='N';
78
- }
79
- if (array_key_exists('kpg_allowforlogged',$_POST)) {
80
- $allowforlogged=stripslashes($_POST['kpg_allowforlogged']);
81
- } else {
82
- $allowforlogged='N';
83
- }
84
- if (array_key_exists('kpg_cell',$_POST)) {
85
- $cell=stripslashes($_POST['kpg_cell']);
86
- } else {
87
- $cell='N';
88
- }
89
- if (array_key_exists('altimg',$_POST)) {
90
- $altimg=stripslashes($_POST['altimg']);
91
- } else {
92
- $altimg='';
93
- }
94
- if ($replace!='Y') $replace='N';
95
- if ($drag!='Y') $drag='N';
96
- if ($allowforlogged!='Y') $allowforlogged='N';
97
- if (empty($cell)) $cell='N';
98
- if ($cell!='Y') $cell='N';
99
- $options['replace']=$replace;
100
- $options['drag']=$drag;
101
- $options['cell']=$cell;
102
- $options['altimg']=$altimg;
103
- $options['allowforlogged']=$allowforlogged;
104
- update_option('kpg_no_right_click_image', $options);
105
-
106
- }
107
- $nonce=wp_create_nonce('kpg_no_rc');
108
- $dir = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
109
- $img = addslashes($dir.'not.gif');
110
- $altimg=trim($altimg);
111
- if (!empty($altimg)) $img=$altimg;
112
 
113
- ?>
114
 
115
- <div class="wrap">
116
- <h2>No Right Click Images Plugin</h2>
117
-
118
- <div style="position:relative;float:right;width:35%;background-color:ivory;border:#333333 medium groove;padding:4px;margin-left:4px;">
119
- <p>This plugin is free and I expect nothing in return. If you would like to support my programming effforts, please <a target="_blank" href="http://www.blogseye.com/donate/">donate a small amount</a> to help keep me interested in this project.</p>
120
- </div>
121
- <h4>The No Right Click Images Plugin is installed and working correctly.</h4>
122
- <p>This plugin installs some javascript in the footer of every page. When your page finishes loading, the javascript sets properties on the images to stop them from being dragged or right clicked. </p>
123
- <p>This is a major revision in the way the plugin works. <a href="mailto:bugs@blogseye.com">Please report all bugs</a> as soon as possible. </p>
124
- <p>There are many ways to bypass this plugin and it is impossible to prevent a determined and resourceful user from stealing images, but this plugin will prevent casual users from glomming your images. </p>
125
- <p>The context menu is disabled on simple elements with background images, but will not work in some cases depending on which element receives the mouse click. </p>
126
- <p>If you have uploaded your images to WordPress so that the images from the gallery can be opened in their own window, then this plugin will not work on the clicked image. Always upload images using FTP and insert the image via URL with no link to the image other than the IMG tag. </p>
127
- <form method="post" action="">
128
- <input type="hidden" name="action" value="update" />
129
- <input type="hidden" name="kpg_no_rc_nonce" value="<?php echo $nonce;?>" />
130
- <table cellpadding="2">
131
- <tr>
132
- <td>Replace image on right mouse click</td>
133
- <td><input type="checkbox" <?php if ($replace=='Y') {echo 'checked="true"';} ?>value="Y" name="kpg_replace_image"></td>
134
- <td><p>This temporarily replaces the target image with the image above. FireFox users can prevent the plugin from stopping the default context menu. Use this to prevent FireFox users from right clicking the image. <br />
135
- This may interfere with other plugins, especially jquery sliders and galleries. Check your blog pages for functionality and turn this off if your images are not behaving correctly. The original image will reappear in about 10 seconds or when the mouse is clicked. </p>
136
- </td>
137
- </tr>
138
- <tr>
139
- <td>Prevent Drag and Drop</td>
140
- <td><input type="checkbox" <?php if ($drag=='Y') {echo 'checked="true"';} ?>value="Y" name="kpg_prevent_drag"></td>
141
- <td>Users may be able to drag an image to the desktop. If you wish to prevent this, check the box. If this conflicts with a plugin that uses drag and drop, you may wish to uncheck this.
142
- </td>
143
- </tr>
144
- <tr>
145
- <td>Allow for Logged Users</td>
146
- <td><input type="checkbox" <?php if ($allowforlogged=='Y') {echo 'checked="true"';} ?>value="Y" name="kpg_allowforlogged"></td>
147
- <td>You may wish to allow logged in users to copy images. You can do this by checking this box.
148
- </td>
149
- </tr>
150
- <tr>
151
- <td>Stop saving on Smart Phones</td>
152
- <td><input type="checkbox" <?php if ($cell=='Y') {echo 'checked="true"';} ?>value="Y" name="kpg_cell"></td>
153
- <td>You can stop users from pressing and holding an image to get a save menu, but it may interfere with other gestures on some phones. Test this before allowing it on your site.
154
- </td>
155
- </tr>
156
-
157
- <tr>
158
- <td align="top">Use an alternate replacement image</td>
159
- <td align="top"><input type="text" name="altimg" value="<?php echo $altimg; ?>"></td>
160
- <td>If you don't like the alternate image then put the url of an alternat image here.<br/>
161
- The image will display below after you save your changes. If no image displays then you typed the URL wrong.
162
- <img width="80" src="<?php echo $img; ?>" style="margin:2px;"/>
163
- </td>
164
- </tr>
165
-
166
-
167
-
168
- </table>
169
- <p>
170
- <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
171
- </p>
172
- </form>
173
- </div>
174
- <?php
175
  }
 
 
 
 
176
  function kpg_no_rc_img_init() {
 
 
 
177
  add_options_page('No Right Click Images', 'No Right Click Images', 'manage_options',__FILE__,'kpg_no_rc_img_control');
178
  }
179
- // Plugin added to Wordpress plugin architecture
180
- add_action('admin_menu', 'kpg_no_rc_img_init');
181
- add_action( 'wp_footer', 'kpg_no_rc_img_fixup' );
182
  // uninstall
183
  function kpg_no_rc_img_uninstall() {
184
  if(!current_user_can('manage_options')) {
@@ -187,9 +60,23 @@ function kpg_no_rc_img_uninstall() {
187
  delete_option('kpg_no_right_click_image');
188
  return;
189
  }
190
- if ( function_exists('register_uninstall_hook') ) {
191
- register_uninstall_hook(__FILE__, 'kpg_no_rc_img_uninstall');
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  // bottom
195
  ?>
3
  Plugin Name: No Right Click Images Plugin
4
  Plugin URI: http://www.BlogsEye.com/
5
  Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
6
+ Version: 3.0
7
  Author: Keith P. Graham
8
  Author URI: http://www.BlogsEye.com/
9
 
13
  */
14
  if (!defined('ABSPATH')) exit; // just in case
15
 
 
16
 
17
+ // add scripts to page
18
+ add_action( 'wp_enqueue_scripts', 'nrci_scripts' ); // enqueue the scripts
19
+ add_action('admin_menu', 'kpg_no_rc_img_init');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
22
 
23
+ function nrci_scripts() {
24
+ if (function_exists('is_user_logged_in')) { // for non wp versions
25
+ if(is_user_logged_in()) {
26
+ // check to see if we should load js
27
+ $options=kpg_nrci_get_options();
28
+ extract($options);
29
+ //if ($allowforlogged=='Y') return;
30
+ }
31
+ }
32
+ wp_enqueue_script( 'nrci_methods', plugin_dir_url( __FILE__ ) . 'no-right-click-images.js', array(), null, false );
33
+ $opts=array(
34
+ 'gesture'=>$gesture,
35
+ 'drag'=>$drag,
36
+ 'allowforlogged'=>$allowforlogged,
37
+ 'touch'=>$touch
38
+ );
39
+ wp_localize_script( 'nrci_methods', 'nrci_opts', $opts );
40
+ }
41
+ function kpg_no_rc_img_control() {
42
+ nrci_load_control();
43
+ kpg_no_rc_img_control_2();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
+ function nrci_load_control() {
46
+ require_once('includes/nrci_options.php');
47
+ }
48
+
49
  function kpg_no_rc_img_init() {
50
+ if ( function_exists('register_uninstall_hook') ) {
51
+ register_uninstall_hook(__FILE__, 'kpg_no_rc_img_uninstall');
52
+ }
53
  add_options_page('No Right Click Images', 'No Right Click Images', 'manage_options',__FILE__,'kpg_no_rc_img_control');
54
  }
 
 
 
55
  // uninstall
56
  function kpg_no_rc_img_uninstall() {
57
  if(!current_user_can('manage_options')) {
60
  delete_option('kpg_no_right_click_image');
61
  return;
62
  }
63
+ function kpg_nrci_get_options() {
64
+ // before we begin we need to check if we need to redirect the options to blog 1
65
+ $opts=get_option('kpg_no_right_click_image');
66
+ if (empty($opts)||!is_array($opts)) $opts=array();
67
+ $options=array(
68
+ 'gesture'=>'Y',
69
+ 'drag'=>'Y',
70
+ 'allowforlogged'=>'N',
71
+ 'touch'=>'Y'
72
+ );
73
+ $ansa=array_merge($options,$opts);
74
+ if ($ansa['gesture']!='Y') $ansa['gesture']='N';
75
+ if ($ansa['drag']!='Y') $ansa['drag']='N';
76
+ if ($ansa['allowforlogged']!='Y') $ansa['allowforlogged']='N';
77
+ if ($ansa['touch']!='Y') $ansa['touch']='N';
78
+ return $ansa;
79
+ }// done
80
 
81
  // bottom
82
  ?>
no-right-click-images.js CHANGED
@@ -1,252 +1,84 @@
1
- /**************************************************************************
2
- This javascript is used by the no-right-click-images plugin for wordpress.
3
- Version 2.5 (second time updating WordPress repository)
4
- Please give credit as no-right-click-images.js by Keith P. Graham
5
- http://www.blogseye.com
6
- **************************************************************************/
7
- var kpg_nrci_targImg=null;
8
- var kpg_nrci_targSrc=null;
9
- var kpg_nrci_inContext=false;
10
- var kpg_nrci_notimage=new Image();
11
- var kpg_nrci_limit=0;
12
- function kpg_nrci_dragdropAll(event) {
13
- try {
14
- var ev=event||window.event;
15
- var targ=ev.srcElement||ev.target;
16
- if (targ.tagName.toUpperCase()=="A") {
17
- // is this IE and are we dragging a link to the image?
18
- var hr=targ.href;
19
- hr=hr.toUpperCase();
20
- if (hr.indexOf('.JPG')||hr.indexOf('.PNG')||hr.indexOf('.GIF')) {
21
- ev.returnValue=false;
22
- if (ev.preventDefault) {
23
- ev.preventDefault();
24
- }
25
- kpg_nrci_inContext=false;
26
- return false;
27
- }
28
- }
29
- if (targ.tagName.toUpperCase()!="IMG") return true;
30
- ev.returnValue=false;
31
- if (ev.preventDefault) {
32
- ev.preventDefault();
33
- }
34
- kpg_nrci_inContext=false;
35
- return false;
36
- } catch (er) {
37
- //alert(er);
38
  }
39
- return true;
40
- }
41
- function kpg_nrci_dragdrop(event) {
42
- // I am beginning to doubt if this event ever fires
43
- try {
44
- var ev=event||window.event;
45
- var targ=ev.srcElement||ev.target;
46
- ev.returnValue=false;
47
- if (ev.preventDefault) {
48
- ev.preventDefault();
49
- }
50
- ev.returnValue=false;
51
- kpg_nrci_inContext=false;
52
- return false;
53
- } catch (er) {
54
- //alert(er);
55
  }
56
- return true;
57
- }
58
- function kpg_nrci_context(event) {
59
- try {
60
- kpg_nrci_inContext=true;
61
- var ev=event||window.event;
62
- var targ=ev.srcElement||ev.target;
63
- kpg_nrci_replace(targ);
64
- ev.returnValue=false;
65
- if (ev.preventDefault) {
66
- ev.preventDefault();
67
- }
68
- ev.returnValue=false;
69
- kpg_nrci_targImg=targ;
70
- } catch (er) {
71
- //alert(er);
72
  }
73
  return false;
74
  }
75
- function kpg_nrci_contextAll(event) {
76
  try {
77
- if (kpg_nrci_targImg==null) {
78
- return true;
79
- }
80
- kpg_nrci_inContext=true;
81
- var ev=event||window.event;
82
- var targ=ev.srcElement||ev.target;
83
- if (targ.tagName.toUpperCase()=="IMG") {
84
- ev.returnValue=false;
85
- if (ev.preventDefault) {
86
- ev.preventDefault();
87
  }
88
- kpg_nrci_replace(targ);
 
 
 
89
  return false;
90
  }
91
- return true;
92
- } catch (er) {
93
- //alert(er);
94
  }
95
- return false;
96
-
97
- }
98
 
99
- function kpg_nrc1_mousedown(event) {
100
  try {
101
- kpg_nrci_inContext=false;
102
- var ev=event||window.event;
103
- var targ=ev.srcElement||ev.target;
104
- if (ev.button==2) {
105
- kpg_nrci_replace(targ);
106
- return false;
107
  }
108
- kpg_nrci_targImg=targ;
109
- if (kpg_nrci_drag=='Y') {
110
- if (ev.preventDefault) {
111
- ev.preventDefault();
112
- }
113
- }
114
- return true;
115
- } catch (er) {
116
- //alert(er);
117
- }
118
- return true;
119
- }
120
- function kpg_nrc1_mousedownAll(event) {
121
- try {
122
- kpg_nrci_inContext=false;
123
- var ev=event||window.event;
124
- var targ=ev.srcElement||ev.target;
125
- if (targ.style.backgroundImage!=''&&ev.button==2) {
126
- targ.oncontextmenu=function(event) { return false;} //iffy - might not work
127
- }
128
- if (targ.tagName.toUpperCase()=="IMG") {
129
- if (ev.button==2) {
130
- kpg_nrci_replace(targ);
131
  return false;
132
- }
133
- if (kpg_nrci_drag=='Y') {
134
- if (ev.preventDefault) {
135
- ev.preventDefault();
136
- }
137
- }
138
- kpg_nrci_targImg=targ;
139
  }
140
- return true;
141
- } catch (er) {
142
- //alert(er);
143
  }
144
  return true;
 
145
  }
146
- function kpg_nrci_replace(targ) {
147
- if (kpg_nrci_targImg!=null && kpg_nrci_targImg.src==kpg_nrci_notimage.src) {
148
- // restore the old image before hiding this one
149
- kpg_nrci_targImg.src=kpg_nrci_targSrc;
150
- kpg_nrci_targImg=null;
151
- kpg_nrci_targSrc=null;
152
- }
153
- kpg_nrci_targImg=targ;
154
- if (kpg_nrci_extra!='Y') return;
155
- var w=targ.width+'';
156
- var h=targ.height+'';
157
- if (w.indexOf('px')<=0) w=w+'px';
158
- if (h.indexOf('px')<=0) h=h+'px';
159
- kpg_nrci_targSrc=targ.src;
160
- targ.src=kpg_nrci_notimage.src;
161
- targ.style.width=w;
162
- targ.style.height=h;
163
- kpg_nrci_limit=0;
164
- var t=setTimeout("kpg_nrci_restore()",500);
165
- return false;
166
- }
167
- function kpg_nrci_restore() {
168
- if (kpg_nrci_inContext) {
169
- if (kpg_nrci_limit<=20) {
170
- kpg_nrci_limit++;
171
- var t=setTimeout("kpg_nrci_restore()",500);
172
- return;
173
- }
174
- }
175
- kpg_nrci_limit=0;
176
- if (kpg_nrci_targImg==null) return;
177
- if (kpg_nrci_targSrc==null) return;
178
- kpg_nrci_targImg.src=kpg_nrci_targSrc;
179
- kpg_nrci_targImg=null;
180
- kpg_nrci_targSrc=null;
181
- return;
182
- }
183
- // sets the image onclick event
184
- // need to check for dblclick to see if there is a right double click in IE
185
- function kpg_nrci_action(event) {
186
- try {
187
- document.onmousedown=function(event) { return kpg_nrc1_mousedownAll(event);}
188
- document.oncontextmenu=function(event) { return kpg_nrci_contextAll(event);}
189
- document.oncopy=function(event) { return kpg_nrci_contextAll(event);}
190
- if (kpg_nrci_drag=='Y') document.ondragstart=function(event) { return kpg_nrci_dragdropAll(event);}
191
- var b=document.getElementsByTagName("IMG");
192
- for (var i = 0; i < b.length; i++) {
193
- b[i].oncontextmenu=function(event) { return kpg_nrci_context(event);}
194
- b[i].oncopy=function(event) { return kpg_nrci_context(event);}
195
- b[i].onmousedown=function(event) { return kpg_nrc1_mousedown(event);}
196
- if (kpg_cell=='Y') {
197
- b[i].onlongpress=function(event) { return kpg_nrci_context(event);} // ?
198
- b[i].ontouchstart = b[i].onclick;
199
- //b[i].ontouchstart=function(event) { return kpg_nrc1_mousedown(event);}
200
- b[i].ontouchmove=function(event) { return kpg_nrci_context(event);}
201
- b[i].ontouchend=function(event) { return kpg_nrci_context(event);}
202
- b[i].ontouchcancel=function(event) { return kpg_nrci_context(event);}
203
- /* set the styles to prevent actions on cell */
204
- b[i].style.webkitUserSelect='none';
205
- b[i].style.MozUserSelect='none';
206
- b[i].style.khtmlUserSelect='none';
207
- b[i].style.msUserSelect='none';
208
- b[i].style.oUserSelect='none';
209
- b[i].style.userSelect='none';
210
-
211
- b[i].style.webkitTouchCallout='none';
212
- b[i].style.MozTouchCallout='none';
213
- b[i].style.khtmlTouchCallout='none';
214
- b[i].style.msTouchCallout='none';
215
- b[i].style.oTouchCallout='none';
216
- b[i].style.touchCallout='none';
217
 
218
- b[i].style.webkitUserDrag='none';
219
- b[i].style.MozUserDrag='none';
220
- b[i].style.khtmlUserDrag='none';
221
- b[i].style.msUserDrag='none';
222
- b[i].style.oUserDrag='none';
223
- b[i].style.userDrag='none';
224
 
225
- b[i].setAttribute("unselectable", "on");
226
-
227
- }
228
- if (kpg_nrci_drag=='Y') b[i].ondragstart=function(event) { return kpg_nrci_dragdrop(event);}
229
- }
230
- } catch (er) {
231
- return false;
232
- }
233
- }
234
-
235
- if (typeof(kpg_nrci_image) == 'undefined' || kpg_nrci_image=='' || typeof(kpg_nrci_extra) == 'undefined'|| typeof(kpg_nrci_drag) == 'undefined') {
236
- //alert("vars not found: "+kpg_nrci_image+","+kpg_nrci_extra);
237
- } else {
238
- kpg_nrci_notimage.src=kpg_nrci_image;
239
- if (document.addEventListener) {
240
- document.addEventListener("DOMContentLoaded", function(event) { kpg_nrci_action(event); }, false);
241
- } else if (window.attachEvent) {
242
- window.attachEvent("onload", function(event) { kpg_nrci_action(event); });
243
- } else {
244
- var oldFunc = window.onload;
245
- window.onload = function() {
246
- if (oldFunc) {
247
- oldFunc();
248
- }
249
- kpg_nrci_action('load');
250
- };
251
- }
252
- }
1
+ /**********************************************
2
+
3
+ No Right Click Images plugin
4
+ by Keith P. Graham
5
+
6
+ Plugin URI: http://www.BlogsEye.com/
7
+ Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
8
+ Version: 3.0
9
+ Author: Keith P. Graham
10
+ Author URI: http://www.BlogsEye.com/
11
+
12
+ This software is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
+
16
+
17
+ ***********************************************/
18
+ document.addEventListener("contextmenu",kpg_nrci_cm, false);
19
+
20
+ if (nrci_opts['drag']=='Y') {
21
+ document.addEventListener("dragstart",kpg_nrci_cm, false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
+ if (nrci_opts['touch']=='Y') {
24
+ document.addEventListener("touchstart",kpg_nrci_cm, false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
+ if (nrci_opts['gesture']=='Y') {
27
+ document.addEventListener("gesturestart",kpg_nrci_cm, false);
28
+ }
29
+
30
+
31
+ function kpg_nrci_block(event) {
32
+ event.cancelBubble = true;
33
+ if(event.preventDefault != undefined) {
34
+ event.preventDefault();
35
+ }
36
+ if(event.stopPropagation != undefined) {
37
+ event.stopPropagation();
 
 
 
 
38
  }
39
  return false;
40
  }
41
+ function kpg_nrci_cm(event) {
42
  try {
43
+ if (event.target.tagName == "IMG") {
44
+ //alert("in IMG");
45
+ event.cancelBubble = true;
46
+ if(event.preventDefault != undefined) {
47
+ event.preventDefault();
 
 
 
 
 
48
  }
49
+ if(event.stopPropagation != undefined) {
50
+ event.stopPropagation();
51
+ }
52
+ //console.log('in img tag');
53
  return false;
54
  }
55
+ } catch(error) {
56
+ console.log("NRI error:"+error);
 
57
  }
 
 
 
58
 
 
59
  try {
60
+ if(event.target.getAttribute("style")==null ||
61
+ event.target.getAttribute("style")=="") {
62
+ return true;
 
 
 
63
  }
64
+ if (event.target.style.backgroundImage != null
65
+ && event.target.style.backgroundImage != 'none'
66
+ && event.target.style.backgroundImage != '') {
67
+ event.cancelBubble = true;
68
+ if(event.preventDefault != undefined) {
69
+ event.preventDefault();
70
+ }
71
+ if(event.stopPropagation != undefined) {
72
+ event.stopPropagation();
73
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  return false;
 
 
 
 
 
 
 
75
  }
76
+ } catch(error) {
77
+ console.log("NRI error:"+error);
 
78
  }
79
  return true;
80
+
81
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
+
 
 
 
 
 
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
not.gif DELETED
Binary file
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Tags: images, image, right click, stealing
3
  Donate link: http://www.blogseye.com/buy-the-book/
4
  Requires at least: 3.0
5
- Tested up to: 3.5
6
  Contributors: Keith Graham
7
- Stable tag: 2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -13,6 +13,8 @@ Disables right click context menu on images to help deter leeches from glomming
13
  == Description ==
14
  The No Right Click Images Plugin Plugin uses JavaScript to change the right click action on IMG tags to disable the context menu. It disables the context menu on images only so other right click actions, such as links, should work normally.
15
 
 
 
16
  Since it uses JavaScript, it targets more images than using plugins that filter pages and rewrite the tag. The plugin will find many images generated in scripts or pasted into posts and comments, that similar plugins will not find.
17
 
18
  It is impossible to keep people from stealing images that appear in web pages, but this plugin will deter casual theft from surfers who do not want to interpret HTML or dig into the browser cache.
@@ -21,8 +23,10 @@ Smart Phone support is hit or miss. Some web pages rely very much on clickable i
21
 
22
  Images uploaded via the Wordpress Media uploader will open in a window if clicked. The image will not be protected, so be sure to indicate that there should be no action if the image is clicked at the time you upload the image.
23
 
24
- Some browsers prevent javascript from altering the context menu behaviour. The plugin tries to get around this by using a replacement image that briefly replaces the clicked image.
25
-
 
 
26
  == Installation ==
27
  1. Download the plugin.
28
  2. Upload the plugin to your wp-content/plugins directory.
@@ -30,41 +34,46 @@ Some browsers prevent javascript from altering the context menu behaviour. The p
30
 
31
  == Changelog ==
32
 
33
- = 1.0 =
34
- * initial release
 
 
35
 
36
- = 1.1 =
37
- * deleted some unused code in the javascript
38
 
39
- = 1.2 =
40
- * Added code that works when javascript creates or loads a new image. Disabled drag and drop on images so images can't be dragged to desktop.
 
 
41
 
42
- = 1.3 =
43
- * Disabled links to local images (png, gif, jpg) in wp-content, preventing them from opening in a new window. This would allow these images to be saved or copied.
44
 
45
- = 1.4 =
46
- * Backed out click check on images because it broke galleries. I left it in as an option if you want to change the code.
 
 
 
47
 
48
  = 2.0 =
49
  * Separated javascript into a loadable file. Added an option to replace images on right click in order to thwart FireFox users who choose to block javascript from controlling the context menu. Made drag and drop blocking optional.
50
 
51
- = 2.1 =
52
- * Added option so that logged in users are allowed to copy images. Disables the plugin for logged in users. Captured copy to clipboard events to prevent another way of copying in some browsers. Fixed a problem in image replacement that prevented an image from being restored when another image was right clicked before the image times out.
53
 
54
- = 2.2 =
55
- * Changed the default so that logged in users cannot copy images. Too many people tested the plugin without checking the settings and assumed that the plugin was broken. They did not read the documentation, try the settings, or check the WordPress forums. I am sorry that I had to do this, but users were indicating on the WordPress plugin page that it didn't work.
56
 
57
- = 2.3 =
58
- * Added support for longclick and touch interface for android and ipad/iphone.
59
 
60
- = 2.4 =
61
- * Added alternate replacement image url for webmasters who don't like the o-slash
62
- * Added an option to turn off IOS Android events that screwed up some web sites.
63
- * Added an extra Security check on plugin load.
 
64
 
65
- = 2.5 =
66
- * added Cell phone styles to javascript for Cell phones. I hope that his helps with Cell phone images. Tested on an old iPad - it may work. Works mostly in iPad, android phone works on some images.
67
- * This readme file did not update on the WordPress site so I have reloaded it.
68
 
69
  == Frequently Asked Questions ==
70
  = I click on an image to open it and then I can save it =
2
  Tags: images, image, right click, stealing
3
  Donate link: http://www.blogseye.com/buy-the-book/
4
  Requires at least: 3.0
5
+ Tested up to: 5.0
6
  Contributors: Keith Graham
7
+ Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
13
  == Description ==
14
  The No Right Click Images Plugin Plugin uses JavaScript to change the right click action on IMG tags to disable the context menu. It disables the context menu on images only so other right click actions, such as links, should work normally.
15
 
16
+ Optionally the plugin can be disabled for logged in users.
17
+
18
  Since it uses JavaScript, it targets more images than using plugins that filter pages and rewrite the tag. The plugin will find many images generated in scripts or pasted into posts and comments, that similar plugins will not find.
19
 
20
  It is impossible to keep people from stealing images that appear in web pages, but this plugin will deter casual theft from surfers who do not want to interpret HTML or dig into the browser cache.
23
 
24
  Images uploaded via the Wordpress Media uploader will open in a window if clicked. The image will not be protected, so be sure to indicate that there should be no action if the image is clicked at the time you upload the image.
25
 
26
+ Some browsers prevent JavaScript from changing the browser context menu and this plugin will not be effective in those cases. At best, this plugin will prevent right clicking or dragging images on some browsers.
27
+
28
+ The plugin no longer tries to replace images with a dummy image. This method hardly ever worked and broke many web pages. If you want to go back, the 2.5 version is available in the WordPress archive.
29
+
30
  == Installation ==
31
  1. Download the plugin.
32
  2. Upload the plugin to your wp-content/plugins directory.
34
 
35
  == Changelog ==
36
 
37
+ = 3.0 =
38
+ * Completely rewrote the plugin javascript. It uses a different set of functions to stop the right click.
39
+ * Major rewrite of the plugin loading method.
40
+ * Removed javascript that did nothing. Just the bare bones settings are included now.
41
 
42
+ = 2.5 =
43
+ * added Cell phone styles to javascript for Cell phones. I hope that his helps with Cell phone images. Tested on an old iPad - it may work. Works mostly in iPad, android phone works on some images.
44
 
45
+ = 2.4 =
46
+ * Added alternate replacement image url for webmasters who don't like the o-slash
47
+ * Added an option to turn off IOS Android events that screwed up some web sites.
48
+ * Added an extra Security check on plugin load.
49
 
50
+ = 2.3 =
51
+ * Added support for longclick and touch interface for android and ipad/iphone.
52
 
53
+ = 2.2 =
54
+ * Changed the default so that logged in users cannot copy images. Too many people tested the plugin without checking the settings and assumed that the plugin was broken. They did not read the documentation, try the settings, or check the WordPress forums. I am sorry that I had to do this, but users were indicating on the WordPress plugin page that it didn't work.
55
+
56
+ = 2.1 =
57
+ * Added option so that logged in users are allowed to copy images. Disables the plugin for logged in users. Captured copy to clipboard events to prevent another way of copying in some browsers. Fixed a problem in image replacement that prevented an image from being restored when another image was right clicked before the image times out.
58
 
59
  = 2.0 =
60
  * Separated javascript into a loadable file. Added an option to replace images on right click in order to thwart FireFox users who choose to block javascript from controlling the context menu. Made drag and drop blocking optional.
61
 
62
+ = 1.4 =
63
+ * Backed out click check on images because it broke galleries. I left it in as an option if you want to change the code.
64
 
65
+ = 1.3 =
66
+ * Disabled links to local images (png, gif, jpg) in wp-content, preventing them from opening in a new window. This would allow these images to be saved or copied.
67
 
68
+ = 1.2 =
69
+ * Added code that works when javascript creates or loads a new image. Disabled drag and drop on images so images can't be dragged to desktop.
70
 
71
+ = 1.1 =
72
+ * deleted some unused code in the javascript
73
+
74
+ = 1.0 =
75
+ * initial release
76
 
 
 
 
77
 
78
  == Frequently Asked Questions ==
79
  = I click on an image to open it and then I can save it =