PluginProbe ʕ •ᴥ•ʔ
WP Content Copy Protection & No Right Click / 3.7.1
WP Content Copy Protection & No Right Click v3.7.1
3.7.1 trunk 1.0 1.2 1.3 1.5.0.3 1.5.0.4 1.6 1.7 1.7.3 1.9 2.3 2.6 2.8.1 2.9 3.1 3.1.5 3.4 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.9 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7
wp-content-copy-protector / preventer-index.php
wp-content-copy-protector Last commit date
css 6 days ago images 6 days ago js 6 days ago languages 6 days ago admin-core.php 6 days ago notifications.php 6 days ago preventer-index.php 6 days ago readme.txt 6 days ago right-click-protection.jpg 6 days ago the_globals.php 6 days ago watermark-adv.jpg 6 days ago watermarking-adv-examples.png 6 days ago
preventer-index.php
815 lines
1 <?php ob_start();
2 /*
3 Plugin Name: WP Content Copy Protection & No Right Click
4 Plugin URI: http://wordpress.org/plugins/w-p-content-copy-protector/
5 Description: This wp plugin protect the posts content from being copied by any other web site author , you dont want your content to spread without your permission!!
6 Version: 3.7.1
7 Author: wp-buy
8 Text Domain: wp-content-copy-protector
9 Domain Path: /languages
10 Author URI: http://www.wp-buy.com/
11 License: GPL-2.0-or-later
12 License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 */
14 ?>
15 <?php
16 //delete_option('wccp_settings'); //Just for testing purposes
17 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18 //define all variables the needed alot
19 include 'the_globals.php';
20 include_once('notifications.php');
21 $wccp_settings = wccp_read_options();
22
23 //---------------------------------------------------------<!-- SimpleTabs -->
24 function wccp_enqueue_scripts($hook) {
25
26 // Only load on your plugin's menu page
27 if ($hook !== 'toplevel_page_wccpoptionspro') {
28 return;
29 }
30 if (!current_user_can('editor') && !current_user_can('administrator')) {
31 return;
32 }
33 // Register and enqueue scripts
34 wp_enqueue_script('jquery');
35
36 wp_register_script(
37 'simpletabsjs',
38 plugins_url('js/simpletabs_1.3.js', __FILE__),
39 array('jquery'),
40 '1.3',
41 true
42 );
43 wp_enqueue_script('simpletabsjs');
44
45 // Register and enqueue styles
46 wp_register_style(
47 'simpletabscss',
48 plugins_url('css/simpletabs.css', __FILE__),
49 array(),
50 '1.0'
51 );
52 wp_enqueue_style('simpletabscss');
53 }
54 add_action('admin_enqueue_scripts', 'wccp_enqueue_scripts');
55
56 function wccp_free_enqueue_front_end_scripts() {
57 wp_enqueue_script('jquery');
58 }
59 add_action('wp_enqueue_scripts', 'wccp_free_enqueue_front_end_scripts');
60 //------------------------------------------------------------------------
61 function wpcp_disable_Right_Click()
62 {
63 ?>
64 <script id="wpcp_disable_Right_Click" type="text/javascript">
65 document.ondragstart = function() { return false;}
66 function nocontext(e) {
67 return false;
68 }
69 document.oncontextmenu = nocontext;
70 </script>
71 <?php
72 }
73 //////////////////////////////////////////////////////////////////////////////////////
74 function wpcp_disable_selection()
75 {
76 global $wccp_settings;
77 ?>
78 <script id="wpcp_disable_selection" type="text/javascript">
79 var image_save_msg='You are not allowed to save images!';
80 var no_menu_msg='Context Menu disabled!';
81 var smessage = "<?php echo esc_js( $wccp_settings['smessage'] ); ?>";
82
83 function disableEnterKey(e)
84 {
85 var elemtype = e.target.tagName;
86
87 elemtype = elemtype.toUpperCase();
88
89 if (elemtype == "TEXT" || elemtype == "TEXTAREA" || elemtype == "INPUT" || elemtype == "PASSWORD" || elemtype == "SELECT" || elemtype == "OPTION" || elemtype == "EMBED")
90 {
91 elemtype = 'TEXT';
92 }
93
94 if (e.ctrlKey){
95 var key;
96 if(window.event)
97 key = window.event.keyCode; //IE
98 else
99 key = e.which; //firefox (97)
100 //if (key != 17) alert(key);
101 if (elemtype!= 'TEXT' && (key == 97 || key == 65 || key == 67 || key == 99 || key == 88 || key == 120 || key == 26 || key == 85 || key == 86 || key == 83 || key == 43 || key == 73))
102 {
103 if(wccp_free_iscontenteditable(e)) return true;
104 show_wpcp_message('You are not allowed to copy content or view source');
105 return false;
106 }else
107 return true;
108 }
109 }
110
111 /*For contenteditable tags*/
112 function wccp_free_iscontenteditable(e)
113 {
114 var e = e || window.event; // also there is no e.target property in IE. instead IE uses window.event.srcElement
115
116 var target = e.target || e.srcElement;
117
118 var elemtype = e.target.nodeName;
119
120 elemtype = elemtype.toUpperCase();
121
122 var iscontenteditable = "false";
123
124 if(typeof target.getAttribute!="undefined" ) iscontenteditable = target.getAttribute("contenteditable"); // Return true or false as string
125
126 var iscontenteditable2 = false;
127
128 if(typeof target.isContentEditable!="undefined" ) iscontenteditable2 = target.isContentEditable; // Return true or false as boolean
129
130 if(target.parentElement.isContentEditable) iscontenteditable2 = true;
131
132 if (iscontenteditable == "true" || iscontenteditable2 == true)
133 {
134 if(typeof target.style!="undefined" ) target.style.cursor = "text";
135
136 return true;
137 }
138 }
139
140 ////////////////////////////////////
141 function disable_copy(e)
142 {
143 var e = e || window.event; // also there is no e.target property in IE. instead IE uses window.event.srcElement
144
145 var elemtype = e.target.tagName;
146
147 elemtype = elemtype.toUpperCase();
148
149 if (elemtype == "TEXT" || elemtype == "TEXTAREA" || elemtype == "INPUT" || elemtype == "PASSWORD" || elemtype == "SELECT" || elemtype == "OPTION" || elemtype == "EMBED")
150 {
151 elemtype = 'TEXT';
152 }
153
154 if(wccp_free_iscontenteditable(e)) return true;
155
156 var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
157
158 var checker_IMG = '<?php echo $wccp_settings['img'];?>';
159 if (elemtype == "IMG" && checker_IMG == 'checked' && e.detail >= 2) {show_wpcp_message(alertMsg_IMG);return false;}
160 if (elemtype != "TEXT")
161 {
162 if (smessage !== "" && e.detail == 2)
163 show_wpcp_message(smessage);
164
165 if (isSafari)
166 return true;
167 else
168 return false;
169 }
170 }
171
172 //////////////////////////////////////////
173 function disable_copy_ie()
174 {
175 var e = e || window.event;
176 var elemtype = window.event.srcElement.nodeName;
177 elemtype = elemtype.toUpperCase();
178 if(wccp_free_iscontenteditable(e)) return true;
179 if (elemtype == "IMG") {show_wpcp_message(alertMsg_IMG);return false;}
180 if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT" && elemtype != "OPTION" && elemtype != "EMBED")
181 {
182 return false;
183 }
184 }
185 function reEnable()
186 {
187 return true;
188 }
189 document.onkeydown = disableEnterKey;
190 document.onselectstart = disable_copy_ie;
191 if(navigator.userAgent.indexOf('MSIE')==-1)
192 {
193 document.onmousedown = disable_copy;
194 document.onclick = reEnable;
195 }
196 function disableSelection(target)
197 {
198 //For IE This code will work
199 if (typeof target.onselectstart!="undefined")
200 target.onselectstart = disable_copy_ie;
201
202 //For Firefox This code will work
203 else if (typeof target.style.MozUserSelect!="undefined")
204 {target.style.MozUserSelect="none";}
205
206 //All other (ie: Opera) This code will work
207 else
208 target.onmousedown=function(){return false}
209 target.style.cursor = "default";
210 }
211 //Calling the JS function directly just after body load
212 window.onload = function(){disableSelection(document.body);};
213
214 //////////////////special for safari Start////////////////
215 var onlongtouch;
216 var timer;
217 var touchduration = 1000; //length of time we want the user to touch before we do something
218
219 var elemtype = "";
220 function touchstart(e) {
221 var e = e || window.event;
222 // also there is no e.target property in IE.
223 // instead IE uses window.event.srcElement
224 var target = e.target || e.srcElement;
225
226 elemtype = window.event.srcElement.nodeName;
227
228 elemtype = elemtype.toUpperCase();
229
230 if(!wccp_pro_is_passive()) e.preventDefault();
231 if (!timer) {
232 timer = setTimeout(onlongtouch, touchduration);
233 }
234 }
235
236 function touchend() {
237 //stops short touches from firing the event
238 if (timer) {
239 clearTimeout(timer);
240 timer = null;
241 }
242 onlongtouch();
243 }
244
245 onlongtouch = function(e) { //this will clear the current selection if anything selected
246
247 if (elemtype != "TEXT" && elemtype != "TEXTAREA" && elemtype != "INPUT" && elemtype != "PASSWORD" && elemtype != "SELECT" && elemtype != "EMBED" && elemtype != "OPTION")
248 {
249 if (window.getSelection) {
250 if (window.getSelection().empty) { // Chrome
251 window.getSelection().empty();
252 } else if (window.getSelection().removeAllRanges) { // Firefox
253 window.getSelection().removeAllRanges();
254 }
255 } else if (document.selection) { // IE?
256 document.selection.empty();
257 }
258 return false;
259 }
260 };
261
262 document.addEventListener("DOMContentLoaded", function(event) {
263 window.addEventListener("touchstart", touchstart, false);
264 window.addEventListener("touchend", touchend, false);
265 });
266
267 function wccp_pro_is_passive() {
268
269 var cold = false,
270 hike = function() {};
271
272 try {
273 const object1 = {};
274 var aid = Object.defineProperty(object1, 'passive', {
275 get() {cold = true}
276 });
277 window.addEventListener('test', hike, aid);
278 window.removeEventListener('test', hike, aid);
279 } catch (e) {}
280
281 return cold;
282 }
283 /*special for safari End*/
284 </script>
285 <?php
286 }
287 //------------------------------------------------------------------------
288 function alert_message()
289 {
290 global $wccp_settings;
291 ?>
292 <div id="wpcp-error-message" class="msgmsg-box-wpcp hideme"><span>error: </span><?php echo $wccp_settings['smessage'];?></div>
293 <script>
294 var timeout_result;
295 function show_wpcp_message(smessage)
296 {
297 if (smessage !== "")
298 {
299 var smessage_text = '<span>Alert: </span>'+smessage;
300 document.getElementById("wpcp-error-message").innerHTML = smessage_text;
301 document.getElementById("wpcp-error-message").className = "msgmsg-box-wpcp warning-wpcp showme";
302 clearTimeout(timeout_result);
303 timeout_result = setTimeout(hide_message, 3000);
304 }
305 }
306 function hide_message()
307 {
308 document.getElementById("wpcp-error-message").className = "msgmsg-box-wpcp warning-wpcp hideme";
309 }
310 </script>
311 <?php
312 global $wccp_settings;
313 if(array_key_exists('prnt_scr_msg', $wccp_settings))
314 {
315 if($wccp_settings['prnt_scr_msg'] != ''){ ?>
316 <style>
317 @media print {
318 body * {display: none !important;}
319 body:after {
320 content: "<?php echo $wccp_settings['prnt_scr_msg']; ?>"; }
321 }
322 </style>
323 <?php }} ?>
324 <style type="text/css">
325 #wpcp-error-message {
326 direction: ltr;
327 text-align: center;
328 transition: opacity 900ms ease 0s;
329 z-index: 99999999;
330 }
331 .hideme {
332 opacity:0;
333 visibility: hidden;
334 }
335 .showme {
336 opacity:1;
337 visibility: visible;
338 }
339 .msgmsg-box-wpcp {
340 border:1px solid #f5aca6;
341 border-radius: 10px;
342 color: #555;
343 font-family: Tahoma;
344 font-size: 11px;
345 margin: 10px;
346 padding: 10px 36px;
347 position: fixed;
348 width: 255px;
349 top: 50%;
350 left: 50%;
351 margin-top: -10px;
352 margin-left: -130px;
353 -webkit-box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
354 -moz-box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
355 box-shadow: 0px 0px 34px 2px rgba(242,191,191,1);
356 }
357 .msgmsg-box-wpcp span {
358 font-weight:bold;
359 text-transform:uppercase;
360 }
361 <?php global $pluginsurl; ?>
362 .warning-wpcp {
363 background:#ffecec url('<?php echo $pluginsurl ?>/images/warning.png') no-repeat 10px 50%;
364 }
365 </style>
366 <?php
367 }
368 //------------------------------------------------------------------------
369 function wccp_css_script()
370 {
371 ?>
372 <style>
373 .unselectable
374 {
375 -moz-user-select:none;
376 -webkit-user-select:none;
377 cursor: default;
378 }
379 html
380 {
381 -webkit-touch-callout: none;
382 -webkit-user-select: none;
383 -khtml-user-select: none;
384 -moz-user-select: none;
385 -ms-user-select: none;
386 user-select: none;
387 -webkit-tap-highlight-color: rgba(0,0,0,0);
388 }
389 </style>
390 <script id="wpcp_css_disable_selection" type="text/javascript">
391 var e = document.getElementsByTagName('body')[0];
392 if(e)
393 {
394 e.setAttribute('unselectable',"on");
395 }
396 </script>
397 <?php
398 }
399 //------------------------------------------------------------------------
400 /* sanitize */
401 function wccp_sanitize($unsafe_val,$type='text')
402 {
403 switch ($type) {
404 case 'text': return stripslashes(htmlentities(sanitize_text_field($unsafe_val),ENT_QUOTES));
405 break;
406 case 'int': return intval($unsafe_val);
407 break;
408 case 'email': return sanitize_email($unsafe_val);
409 break;
410 case 'filename': return sanitize_file_name($unsafe_val);
411 break;
412 case 'title': return sanitize_title($unsafe_val);
413 break;
414 case 'URL': return esc_url($unsafe_val);
415 break;
416 case 'textbox': return stripslashes(htmlentities(sanitize_text_field($unsafe_val),ENT_QUOTES));
417 break;
418 default:
419 return sanitize_text_field($unsafe_val);
420 }
421 }
422 //------------------------------------------------------------------------
423 function wccp_css_settings()
424 {
425 global $wccp_settings;
426 if(!current_user_can( 'manage_options' ) || (current_user_can( 'manage_options' ) && $wccp_settings['exclude_admin_from_protection'] == 'No')){
427 if (((is_home() || is_front_page() || is_archive() || is_post_type_archive() || is_404() || is_attachment() || is_author() || is_category() || is_feed()) && $wccp_settings['home_css_protection'] == 'Enabled'))
428 {
429 wccp_css_script();
430 return;
431 }
432 if (is_single() && $wccp_settings['posts_css_protection'] == 'Enabled')
433 {
434 wccp_css_script();
435 return;
436 }
437 if (is_page() && !is_front_page() && $wccp_settings['pages_css_protection'] == 'Enabled')
438 {
439 wccp_css_script();
440 return;
441 }
442 }
443 }
444 //------------------------------------------------------------------------
445 function wccp_main_settings()
446 {
447 global $wccp_settings;
448 if(!current_user_can( 'manage_options' ) || (current_user_can( 'manage_options' ) && $wccp_settings['exclude_admin_from_protection'] == 'No')){
449 if (((is_home() || is_front_page() || is_archive() || is_post_type_archive() || is_404() || is_attachment() || is_author() || is_category() || is_feed() || is_search()) && $wccp_settings['home_page_protection'] == 'Enabled'))
450 {
451 wpcp_disable_selection();
452 return;
453 }
454 if (is_single() && $wccp_settings['single_posts_protection'] == 'Enabled')
455 {
456 wpcp_disable_selection();
457 return;
458 }
459 if (is_page() && !is_front_page() && $wccp_settings['page_protection'] == 'Enabled')
460 {
461 wpcp_disable_selection();
462 return;
463 }
464 }
465 }
466 //------------------------------------------------------------------------
467 function right_click_premium_settings()
468 {
469 global $wccp_settings;
470 if(!current_user_can( 'manage_options' ) || (current_user_can( 'manage_options' ) && $wccp_settings['exclude_admin_from_protection'] == 'No')){
471 if (((is_home() || is_front_page() || is_archive() || is_post_type_archive() || is_404() || is_attachment() || is_author() || is_category() || is_feed()) && $wccp_settings['right_click_protection_homepage'] == 'checked'))
472 {
473 wpcp_disable_Right_Click();
474 return;
475 }
476 if (is_single() && $wccp_settings['right_click_protection_posts'] == 'checked')
477 {
478 wpcp_disable_Right_Click();
479 return;
480 }
481 if (is_page() && !is_front_page() && $wccp_settings['right_click_protection_posts'] == 'checked')
482 {
483 wpcp_disable_Right_Click();
484 return;
485 }
486 }
487 }
488 //------------------------------------------------------------------------
489 function wccp_find_image_urls( $content ) {
490
491 global $wccp_settings;
492
493 $remove_img_urls = "Yes";
494
495 if($remove_img_urls == "Yes"){
496
497 $regexp = '(href=\"http)(.*)(.jpg|.jpeg|.png)';
498
499 if(preg_match_all("/$regexp/iU", $content, $matches, PREG_SET_ORDER)) {
500
501 if( !empty($matches) ) {
502
503 $srcUrl = get_permalink();
504
505 for ($i=0; $i <= count($matches); $i++)
506 {
507 if (isset($matches[$i]) && isset($matches[$i][0]))
508
509 $tag = $matches[$i][0];
510
511 else
512
513 $tag = '';
514
515 $tag2 = '';
516
517 $content = str_replace($tag,$tag2,$content);
518 }
519 }
520 }
521 }
522 return '<div class="protcted_area">'.$content.'</div>';
523 }
524 //------------------------------------------------------------------------
525 // Add specific CSS class by filter
526 function wccp_class_names($classes) {
527 global $wccp_settings;
528 if(!current_user_can( 'manage_options' ) || (current_user_can( 'manage_options' ) && $wccp_settings['exclude_admin_from_protection'] == 'No'))
529 {
530 if ($wccp_settings['home_css_protection'] == 'Enabled' || $wccp_settings['posts_css_protection'] == 'Enabled' || $wccp_settings['pages_css_protection'] == 'Enabled')
531 {
532 $classes[] = 'unselectable';
533 return $classes;
534 }
535 else
536 {
537 $classes[] = 'none';
538 return $classes;
539 }
540 }else
541 {
542 $classes[] = 'none';
543 return $classes;
544 }
545 }
546
547 //Don't serve actions for live editors & builders
548 global $pagenow;
549 if ($pagenow != 'post.php' && !isset($_GET["elementor-preview"]) && !isset($_GET["siteorigin_panels_live_editor"]) && !isset($_GET["preview_id"]) && !isset($_GET["fl_builder"]) && !isset($_GET["et_fb"])) {
550 add_action('wp_head','wccp_main_settings');
551 add_action('wp_head','right_click_premium_settings');
552 add_action('wp_head','wccp_css_settings');
553 add_action('wp_footer','alert_message');
554 add_filter('body_class','wccp_class_names');
555 //add_filter( 'the_content', 'wccp_find_image_urls');
556 }
557 //-------------------------------------------------------Function to read options from the database
558 function wccp_read_options()
559 {
560 if (get_option('wccp_settings'))
561 $wccp_settings = get_option('wccp_settings');
562 else
563 $wccp_settings = wccp_default_options();
564
565 $wccp_settings = array_merge(wccp_default_options(), $wccp_settings);//Set default value for any unexisted key
566 if ((isset($_GET['page']) && $_GET['page'] != 'wccpoptionspro') || !isset($_GET['page']))
567 {
568 //We don't want this merge to work inside plugin admin panel
569
570 }
571 return $wccp_settings;
572 }
573 //---------------------------------------------------------------------
574 //To use debug console in PHP because its just allowed using JavaScript
575 //---------------------------------------------------------------------
576 function wccp_free_debug_to_console($data)
577 {
578 global $wccp_settings;
579
580 if(array_key_exists("developer_mode", $wccp_settings))
581 {
582 if($wccp_settings['developer_mode'] == "Yes")
583 {
584 $output = $data;
585 if ( is_array( $output ))
586 {
587 foreach ( $output as $element )
588 if(isset($element))
589 {
590 //echo "<script>console.log('Debug Objects: " . $element . "' );</script>";
591 }
592 }
593 }
594 }
595 }
596 //-------------------------------------------------------Set default values to the array
597 function wccp_default_options(){
598 $pluginsurl = plugins_url( '', __FILE__ );
599 $wccp_settings =
600 Array (
601 'single_posts_protection' => 'Enabled', // prevent content copy, take 3 parameters, 1.content: to prevent content copy only 2.all 3.none
602 'home_page_protection' => 'Enabled', //
603 'page_protection' => 'Enabled', //
604 'top_bar_icon_btn' => 'Visible', //
605 'right_click_protection_posts' => 'checked', //
606 'right_click_protection_homepage' => 'checked', //
607 'right_click_protection_pages' => 'checked', //
608 'home_css_protection' => 'Enabled', // premium option
609 'posts_css_protection' => 'Enabled', // premium option
610 'pages_css_protection' => 'Enabled', // premium option
611 'exclude_admin_from_protection' => 'No',
612 'img' => '',
613 'a' => '',
614 'pb' => '',
615 'input' => '',
616 'h' => '',
617 'textarea' => '',
618 'emptyspaces' => '',
619 'smessage' => 'Content is protected !!',
620 'alert_msg_img' => '',
621 'alert_msg_a' => '',
622 'alert_msg_pb' => '',
623 'alert_msg_input' => '',
624 'alert_msg_h' => '',
625 'alert_msg_textarea' => '',
626 'alert_msg_emptyspaces' => '',
627 'prnt_scr_msg' => 'You are not allowed to print preview this page, Thank you'
628 );
629 return $wccp_settings;
630 }
631 //---------------------------------------- Add plugin settings link to Plugins page
632 function wccp_plugin_add_settings_link( $links )
633 {
634 $settings_link = '<a href="admin.php?page=wccpoptionspro">' . __( 'Settings', 'wp-content-copy-protector') . '</a>';
635 array_push( $links, $settings_link );
636
637 $go_pro_link = '<a title="Upgrade to PRO verion Now" target="_blank" style="font-weight:bold;color: chocolate;" href="https://www.wp-buy.com/product/wp-content-copy-protection-pro/">' . __( 'Go PRO', 'wp-content-copy-protector') . '</a>';
638 array_push( $links, $go_pro_link );
639
640 return $links;
641 }
642 $plugin = plugin_basename( __FILE__ );
643 add_filter( "plugin_action_links_$plugin", 'wccp_plugin_add_settings_link' );
644 //------------------------------------------------------------------------
645 //Make a WordPress function to add to the correct menu.
646 function wpccp_after_plugin_row( $plugin_file, $plugin_data, $status ) {
647
648 if ( ! current_user_can('activate_plugins') ) {
649 return;
650 }
651
652 $current_plugin = plugin_basename(__FILE__);
653
654 if ( $plugin_file !== $current_plugin ) {
655 return;
656 }
657
658 $class_name = sanitize_html_class( dirname($plugin_file) );
659 $p_url = 'https://www.wp-buy.com/product/wp-content-copy-protection-pro/';
660
661 $messages = [
662 __('Unlock the full power of WP Content Copy Protection with advanced features, enhanced security, and priority support.', 'wp-content-copy-protector'),
663
664 __('Take your website protection to the next level with powerful PRO features and premium support. Upgrade now and experience the difference.', 'wp-content-copy-protector'),
665
666 __('Get more control, stronger protection, and premium features designed for professionals. Upgrade now to the PRO version.', 'wp-content-copy-protector'),
667
668 __('Upgrade to PRO for stronger protection, more features, and premium support.', 'wp-content-copy-protector'),
669
670 __('Most users miss out on advanced protection and full control. Upgrade now and secure your content like a pro.', 'wp-content-copy-protector'),
671 ];
672
673 $random_message = $messages[array_rand($messages)];
674
675 ?>
676 <tr id="<?php echo esc_attr($class_name); ?>-plugin-update" class="active">
677 <th class="check-column" scope="row"></th>
678 <td colspan="3" class="plugin-update">
679 <div id="wccp-update-message" style="background:#edf4f7;padding:10px;">
680 <?php echo esc_html($random_message); ?>
681 <a href="<?php echo esc_url($p_url); ?>" target="_blank">
682 <strong><?php echo esc_html__('Upgrade Now', 'wp-content-copy-protector'); ?></strong>
683 </a>,
684 <a id="wccp-hide-message" href="#">
685 <strong><?php echo esc_html__('Dismiss', 'wp-content-copy-protector'); ?></strong>
686 </a>.
687 </div>
688 </td>
689 </tr>
690
691 <script>
692 jQuery(function($){
693
694 function wccp_hide_upgrade_message(e){
695 if(e) e.preventDefault();
696
697 $("#wccp-update-message").remove();
698 localStorage.setItem("wccp_upgrade_messages", "hide_upgrade_msg");
699
700 $('#<?php echo esc_js($class_name); ?>-plugin-update').remove();
701 }
702
703 $("#wccp-hide-message").on("click", wccp_hide_upgrade_message);
704
705 if(localStorage.getItem("wccp_upgrade_messages") === "hide_upgrade_msg"){
706 wccp_hide_upgrade_message();
707 }
708
709 });
710 </script>
711 <?php
712 }
713
714 add_action(
715 'after_plugin_row_' . plugin_basename(__FILE__),
716 'wpccp_after_plugin_row',
717 10,
718 3
719 );
720 //---------------------------------------------Add button with icon to the admin bar
721 global $wccp_settings;
722 if (!is_array($wccp_settings)) $wccp_settings = wccp_read_options();
723 if(array_key_exists('top_bar_icon_btn', $wccp_settings))
724 {
725 if($wccp_settings['top_bar_icon_btn'] == 'Visible')
726 {
727 add_action('admin_bar_menu', 'wccp_free_add_items', 40);
728 add_action('wp_enqueue_scripts', 'wccp_free_top_bar_enqueue_style');
729 add_action('admin_enqueue_scripts', 'wccp_free_top_bar_enqueue_style');
730 }
731 }
732
733 // Function to get the current page name
734 function wccp_free_get_current_page_name() {
735 // Get the script name from the server variables
736 return isset($_SERVER['PHP_SELF']) ? basename($_SERVER['PHP_SELF']) : '';
737 }
738
739 function wccp_free_top_bar_enqueue_style() {
740 if (wccp_free_get_current_page_name() === 'customize.php') return;//Stop if you are inside theme customizer
741 ?>
742 <style>
743 #wpadminbar #wp-admin-bar-wccp_free_top_button .ab-icon:before {
744 content: "\f160";
745 color: #02CA02;
746 top: 3px;
747 }
748 #wpadminbar #wp-admin-bar-wccp_free_top_button .ab-icon {
749 transform: rotate(45deg);
750 }
751 </style>
752 <?php
753 }
754 ///////////////////
755 function wccp_free_add_items($admin_bar)
756 {
757 if ( ! current_user_can( 'manage_options' ) ) {
758 return;
759 }
760 global $pluginsurl;
761 //The properties of the new item. Read More about the missing 'parent' parameter below
762 $args = array(
763 'id' => 'wccp_free_top_button',
764 'parent' => null,
765 'group' => null,
766 'title' => '<span class="ab-icon"></span>' . __('Protection', 'wp-content-copy-protector'),
767 'href' => admin_url('admin.php?page=wccpoptionspro'),
768 'meta' => array('title' => __('Copy Protection & No right click', 'wp-content-copy-protector'),//This title will show on hover
769 'class' => '')
770 );
771
772 //This is where the magic works.
773 $admin_bar->add_menu( $args);
774 }
775 //------------------------------------------------------------------------
776 function wccp_options_page_pro() {
777 include 'admin-core.php';
778 }
779 //------------------------------------------------------------------------
780 //Make our function to call the WordPress function to add to the correct menu.
781 function wccp_add_options()
782 {
783 //add_options_page(__('WP Content Copy Protection', 'wp-content-copy-protector'), __('WP Content Copy Protection', 'wp-content-copy-protector'), 'manage_options', 'wccpoptionspro', 'wccp_options_page_pro');
784 add_menu_page
785 (
786 'WP Content Copy Protection', // use null for parent slug to hide it from admin menu
787 'Copy Protection', // page title
788 'manage_options', // capability
789 'wccpoptionspro', // slug
790 'wccp_options_page_pro', // callback
791 'dashicons-lock',
792 6
793 );
794 add_submenu_page('wccpoptionspro', 'Settings', 'Settings', 'manage_options', 'wccpoptionspro', 'wccp_options_page_pro');
795 }
796 //First use the add_action to add onto the WordPress menu.
797 add_action('admin_menu', 'wccp_add_options');
798
799 add_action('admin_menu', 'wccp_free_add_external_links_as_submenu');
800
801 function wccp_free_add_external_links_as_submenu() {
802
803 global $submenu;
804
805 $search_url = "plugin-install.php?s=wp-buy&tab=search&type=author";
806
807 $network_dir_append = "";
808
809 If (is_multisite()) $network_dir_append = "network/";
810
811 $menu_slug = "wccpoptionspro"; // used as "key" in menus
812
813 $submenu[$menu_slug][] = array('<span style="color:#f18500">More Plugins</span>', 'manage_options', admin_url( $network_dir_append . 'plugin-install.php?s=wp-buy&tab=search&type=author' ));
814 }
815 ?>