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