wp-content-copy-protector
Last commit date
css
5 years ago
images
5 years ago
js
5 years ago
languages
5 years ago
admin-core.php
5 years ago
notifications.php
5 years ago
preventer-index.php
5 years ago
readme.txt
5 years ago
right-click-protection.jpg
5 years ago
the_globals.php
5 years ago
watermark-adv.jpg
5 years ago
watermarking-adv-examples.png
5 years ago
notifications.php
159 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | // Exit if accessed directly. |
| 4 | exit; |
| 5 | } |
| 6 | // Use your own prefix, i use "wccp_free_", replace it; |
| 7 | $icon_path = plugins_url( '/images/icon-128x128.png' , __FILE__); |
| 8 | $rating_url = "https://wordpress.org/support/plugin/wp-content-copy-protector/reviews/?filter=5#new-post"; |
| 9 | $activation_time = 604800; // 7 days in seconds |
| 10 | $file_version = 2.1; |
| 11 | $development_mode = false; // Put yes to allow development mode, you will see the rating notice without timers |
| 12 | |
| 13 | /** |
| 14 | * @since 1.9 |
| 15 | * @version 1.9 |
| 16 | * @class wccp_free_Notification |
| 17 | */ |
| 18 | |
| 19 | if ( ! class_exists( 'wccp_free_Notification' ) ) : |
| 20 | |
| 21 | class wccp_free_Notification { |
| 22 | |
| 23 | /* * * * * * * * * * |
| 24 | * Class constructor |
| 25 | * * * * * * * * * */ |
| 26 | public function __construct() { |
| 27 | |
| 28 | $this->_hooks(); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Hook into actions and filters |
| 33 | * @since 1.0.0 |
| 34 | * @version 1.2.1 |
| 35 | */ |
| 36 | private function _hooks() { |
| 37 | add_action( 'admin_init', array( $this, 'wccp_free_review_notice' ) ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Ask users to review our plugin on wordpress.org |
| 42 | * |
| 43 | * @since 1.0.11 |
| 44 | * @return boolean false |
| 45 | * @version 1.1.3 |
| 46 | */ |
| 47 | public function wccp_free_review_notice() { |
| 48 | |
| 49 | global $file_version, $activation_time, $development_mode; |
| 50 | |
| 51 | $this->wccp_free_review_dismissal(); |
| 52 | |
| 53 | $this->wccp_free_review_pending(); |
| 54 | |
| 55 | $activation_time = get_site_option( 'wccp_free_active_time' ); |
| 56 | |
| 57 | $review_dismissal = get_site_option( 'wccp_free_review_dismiss' ); |
| 58 | |
| 59 | if ($review_dismissal == 'yes' && !$development_mode) return; |
| 60 | |
| 61 | if ( !$activation_time && !$development_mode ) : |
| 62 | |
| 63 | $activation_time = time(); // Reset Time to current time. |
| 64 | add_site_option( 'wccp_free_active_time', $activation_time ); |
| 65 | |
| 66 | endif; |
| 67 | if ($development_mode) $activation_time = 432001; //This variable used to show the message always for testing purposes only |
| 68 | // 432000 = 5 Days in seconds. |
| 69 | if ( time() - $activation_time > 432000 ) : |
| 70 | |
| 71 | wp_enqueue_style( 'wccp_free_review_stlye', plugins_url( '/css/style-review.css', __FILE__ ), array(), $file_version ); |
| 72 | add_action( 'admin_notices' , array( $this, 'wccp_free_review_notice_message' ) ); |
| 73 | |
| 74 | endif; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Check and Dismiss review message. |
| 79 | * |
| 80 | * @since 1.9 |
| 81 | */ |
| 82 | private function wccp_free_review_dismissal() { |
| 83 | |
| 84 | if ( ! is_admin() || |
| 85 | ! current_user_can( 'manage_options' ) || |
| 86 | ! isset( $_GET['_wpnonce'] ) || |
| 87 | ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ), 'wccp_free_review-nonce' ) || |
| 88 | ! isset( $_GET['wccp_free_review_dismiss'] ) ) : |
| 89 | |
| 90 | return; |
| 91 | endif; |
| 92 | |
| 93 | add_site_option( 'wccp_free_review_dismiss', 'yes' ); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Set time to current so review notice will popup after 14 days |
| 98 | * |
| 99 | * @since 1.9 |
| 100 | */ |
| 101 | private function wccp_free_review_pending() { |
| 102 | |
| 103 | if ( ! is_admin() || |
| 104 | ! current_user_can( 'manage_options' ) || |
| 105 | ! isset( $_GET['_wpnonce'] ) || |
| 106 | ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ), 'wccp_free_review-nonce' ) || |
| 107 | ! isset( $_GET['wccp_free_review_later'] ) ) : |
| 108 | |
| 109 | return; |
| 110 | endif; |
| 111 | |
| 112 | // Reset Time to current time. |
| 113 | update_site_option( 'wccp_free_active_time', time() ); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Review notice message |
| 118 | * |
| 119 | * @since 1.0.11 |
| 120 | */ |
| 121 | public function wccp_free_review_notice_message() { |
| 122 | |
| 123 | $scheme = ( wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY ) ) ? '&' : '?'; |
| 124 | $url = $_SERVER['REQUEST_URI'] . $scheme . 'wccp_free_review_dismiss=yes'; |
| 125 | $dismiss_url = wp_nonce_url( $url, 'wccp_free_review-nonce' ); |
| 126 | |
| 127 | $_later_link = $_SERVER['REQUEST_URI'] . $scheme . 'wccp_free_review_later=yes'; |
| 128 | $later_url = wp_nonce_url( $_later_link, 'wccp_free_review-nonce' ); |
| 129 | |
| 130 | global $icon_path; |
| 131 | |
| 132 | global $rating_url; |
| 133 | ?> |
| 134 | |
| 135 | <div class="wccp_free_review-notice"> |
| 136 | <div class="wccp_free_review-thumbnail"> |
| 137 | <img src="<?php echo $icon_path; ?>" alt=""> |
| 138 | </div> |
| 139 | <div class="wccp_free_review-text"> |
| 140 | <h3><?php _e( 'Leave A Review?', 'wp-content-copy-protector' ) ?></h3> |
| 141 | <p><?php _e( 'We hope you\'ve enjoyed using WP copy Protection :) Would you mind taking a few minutes to write a review on WordPress.org?<br>Just writing simple "thank you" will make us happy!', 'wp-content-copy-protector' ) ?></p> |
| 142 | <ul class="wccp_free_review-ul"> |
| 143 | <li><a href="<?php echo $rating_url; ?>" target="_blank"><span class="dashicons dashicons-external"></span><?php _e( 'Sure! I\'d love to!', 'wp-content-copy-protector' ) ?></a></li> |
| 144 | <li><a href="<?php echo $dismiss_url ?>"><span class="dashicons dashicons-smiley"></span><?php _e( 'I\'ve already left a review', 'wp-content-copy-protector' ) ?></a></li> |
| 145 | <li><a href="<?php echo $later_url ?>"><span class="dashicons dashicons-calendar-alt"></span><?php _e( 'Will Rate Later', 'wp-content-copy-protector' ) ?></a></li> |
| 146 | <li><a href="<?php echo $dismiss_url ?>"><span class="dashicons dashicons-dismiss"></span><?php _e( 'Hide Forever', 'wp-content-copy-protector' ) ?></a></li></ul> |
| 147 | </div> |
| 148 | </div> |
| 149 | <?php |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | endif; |
| 154 | $admincore = ''; |
| 155 | if (isset($_GET['page'])) $admincore = sanitize_text_field($_GET['page']); |
| 156 | if($admincore != 'wccpoptionspro') { |
| 157 | new wccp_free_Notification(); |
| 158 | } |
| 159 | ?> |