cookie-law-info
Last commit date
languages
1 month ago
legacy
1 month ago
lite
1 month ago
public
1 month ago
class-autoloader.php
1 month ago
cookie-law-info.php
1 month ago
license.txt
1 month ago
readme.txt
1 month ago
uninstall.php
1 month ago
wpml-config.xml
1 month ago
cookie-law-info.php
153 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The plugin bootstrap file |
| 5 | * |
| 6 | * This file is read by WordPress to generate the plugin information in the plugin |
| 7 | * admin area. This file also includes all of the dependencies used by the plugin, |
| 8 | * registers the activation and deactivation functions, and defines a function |
| 9 | * that starts the plugin. |
| 10 | * |
| 11 | * @link https://www.cookieyes.com/ |
| 12 | * @since 1.6.6 |
| 13 | * @package Cookie_Law_Info |
| 14 | * |
| 15 | * @wordpress-plugin |
| 16 | * Plugin Name: CookieYes | GDPR Cookie Consent |
| 17 | * Plugin URI: https://www.cookieyes.com/ |
| 18 | * Description: A simple way to show your website complies with the EU Cookie Law / GDPR. |
| 19 | * Version: 3.4.1 |
| 20 | * Author: CookieYes |
| 21 | * Author URI: https://www.cookieyes.com/ |
| 22 | * License: GPLv3 |
| 23 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 24 | * Text Domain: cookie-law-info |
| 25 | */ |
| 26 | |
| 27 | /* |
| 28 | Copyright 2018 WebToffee |
| 29 | |
| 30 | This program is free software; you can redistribute it and/or modify |
| 31 | it under the terms of the GNU General Public License, version 2, as |
| 32 | published by the Free Software Foundation. |
| 33 | |
| 34 | This program is distributed in the hope that it will be useful, |
| 35 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 36 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 37 | GNU General Public License for more details. |
| 38 | |
| 39 | You should have received a copy of the GNU General Public License |
| 40 | along with this program; if not, write to the Free Software |
| 41 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 42 | */ |
| 43 | |
| 44 | // If this file is called directly, abort. |
| 45 | if ( ! defined( 'WPINC' ) ) { |
| 46 | die; |
| 47 | } |
| 48 | |
| 49 | define( 'CLI_VERSION', '3.4.1' ); |
| 50 | define( 'CLI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 51 | define( 'CLI_PLUGIN_BASEPATH', plugin_dir_path( __FILE__ ) ); |
| 52 | define( 'CLI_SETTINGS_FIELD', 'CookieLawInfo-0.9' ); |
| 53 | // Previous version settings (deprecated from 0.9 onwards). |
| 54 | define( 'CLI_ADMIN_OPTIONS_NAME', 'CookieLawInfo-0.8.3' ); |
| 55 | define( 'CLI_PLUGIN_FILENAME', __FILE__ ); |
| 56 | define( 'CLI_POST_TYPE', 'cookielawinfo' ); |
| 57 | define( 'CLI_DEFAULT_LANGUAGE', cky_set_default_language() ); |
| 58 | |
| 59 | /** CookieYes web app URL */ |
| 60 | if ( ! defined( 'CKY_APP_URL' ) ) { |
| 61 | define( 'CKY_APP_URL', 'https://app.cookieyes.com' ); |
| 62 | } |
| 63 | |
| 64 | /** CookieYes web app script cdn URL. */ |
| 65 | if ( ! defined( 'CKY_APP_CDN_URL' ) ) { |
| 66 | define( 'CKY_APP_CDN_URL', 'https://cdn-cookieyes.com' ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Load and set default language of the site. |
| 71 | * |
| 72 | * @return string |
| 73 | */ |
| 74 | function cky_set_default_language() { |
| 75 | $default = get_option( 'WPLANG', 'en_US' ); |
| 76 | if ( empty( $default ) || strlen( $default ) <= 1 ) { |
| 77 | $default = 'en'; |
| 78 | } |
| 79 | return substr( $default, 0, 2 ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Add an upgrade notice whenever an update is available. |
| 84 | * |
| 85 | * @param array $data Upgrade data. |
| 86 | * @param array $response Upgrade response data. |
| 87 | * @return void |
| 88 | */ |
| 89 | function cky_upgrade_notice( $data, $response ) { |
| 90 | if ( isset( $data['upgrade_notice'] ) ) { |
| 91 | add_action( 'admin_print_footer_scripts', 'cky_upgrade_notice_js' ); |
| 92 | $msg = str_replace( array( '<p>', '</p>' ), array( '<div>', '</div>' ), $data['upgrade_notice'] ); |
| 93 | echo '<style type="text/css"> |
| 94 | #cookie-law-info-update .update-message p:last-child{ display:none;} |
| 95 | #cookie-law-info-update ul{ list-style:disc; margin-left:30px;} |
| 96 | .cky-upgrade-notice{ padding-left:30px;} |
| 97 | </style> |
| 98 | <div class="update-message cky-upgrade-notice"><div style="color: #f56e28;">' . esc_html__( 'Please make sure the cache is cleared after each plugin update especially if you have minified JS and/or CSS files.', 'cookie-law-info' ) . '</div>' . wp_kses_post( wpautop( $msg ) ) . '</div>'; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Javascript for handling upgrade notice. |
| 104 | * |
| 105 | * @return void |
| 106 | */ |
| 107 | function cky_upgrade_notice_js() { ?> |
| 108 | <script> |
| 109 | ( function( $ ){ |
| 110 | var update_dv=$( '#cookie-law-info-update '); |
| 111 | update_dv.find('.cky-upgrade-notice').next('p').remove(); |
| 112 | update_dv.find('a.update-link:eq(0)').click(function(){ |
| 113 | $('.cky-upgrade-notice').remove(); |
| 114 | }); |
| 115 | })( jQuery ); |
| 116 | </script> |
| 117 | <?php |
| 118 | } |
| 119 | |
| 120 | add_action( 'in_plugin_update_message-cookie-law-info/cookie-law-info.php', 'cky_upgrade_notice', 10, 2 ); |
| 121 | |
| 122 | //declare compliance with WP Consent API |
| 123 | add_filter( "wp_consent_api_registered_".CLI_PLUGIN_BASENAME, '__return_true' ); |
| 124 | |
| 125 | /** |
| 126 | * Return internal DB version. |
| 127 | * |
| 128 | * @return string |
| 129 | */ |
| 130 | function cky_get_consent_db_version() { |
| 131 | return get_option( 'cky_cookie_consent_lite_db_version', '2.0' ); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Check if plugin is in legacy version. |
| 136 | * |
| 137 | * @return boolean |
| 138 | */ |
| 139 | function cky_is_legacy() { |
| 140 | $current_version = cky_get_consent_db_version(); |
| 141 | if ( empty( get_option( CLI_SETTINGS_FIELD, array() ) ) || ( ! is_null( $current_version ) && version_compare( $current_version, '2.0', '>' ) === true ) ) { |
| 142 | return false; |
| 143 | } else { |
| 144 | return true; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if ( cky_is_legacy() ) { |
| 149 | require_once CLI_PLUGIN_BASEPATH . 'legacy/loader.php'; |
| 150 | } else { |
| 151 | require_once CLI_PLUGIN_BASEPATH . 'lite/loader.php'; |
| 152 | } |
| 153 |