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