cookie-law-info
Last commit date
admin
5 years ago
images
5 years ago
includes
5 years ago
languages
5 years ago
public
5 years ago
third-party
5 years ago
cookie-law-info.php
5 years ago
index.php
5 years ago
license.txt
5 years ago
readme.txt
5 years ago
uninstall.php
5 years ago
wpml-config.xml
5 years ago
cookie-law-info.php
190 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.webtoffee.com/product/gdpr-cookie-consent/ |
| 12 | * @since 1.6.6 |
| 13 | * @package Cookie_Law_Info |
| 14 | * |
| 15 | * @wordpress-plugin |
| 16 | * Plugin Name: GDPR Cookie Consent |
| 17 | * Plugin URI: https://www.webtoffee.com/product/gdpr-cookie-consent/ |
| 18 | * Description: A simple way to show your website complies with the EU Cookie Law / GDPR. |
| 19 | * Version: 2.0.2 |
| 20 | * Author: WebToffee |
| 21 | * Author URI: https://www.webtoffee.com/ |
| 22 | * License: GPLv3 |
| 23 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 24 | * Text Domain: cookie-law-info |
| 25 | * Domain Path: /languages |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | Copyright 2018 WebToffee |
| 30 | |
| 31 | This program is free software; you can redistribute it and/or modify |
| 32 | it under the terms of the GNU General Public License, version 2, as |
| 33 | published by the Free Software Foundation. |
| 34 | |
| 35 | This program is distributed in the hope that it will be useful, |
| 36 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 37 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 38 | GNU General Public License for more details. |
| 39 | |
| 40 | You should have received a copy of the GNU General Public License |
| 41 | along with this program; if not, write to the Free Software |
| 42 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 43 | */ |
| 44 | |
| 45 | // If this file is called directly, abort. |
| 46 | if ( ! defined( 'WPINC' ) ) { |
| 47 | die; |
| 48 | } |
| 49 | $wt_cli_wp_lanugage = get_option('WPLANG', 'en_US'); |
| 50 | if ( empty($wt_cli_wp_lanugage) || strlen($wt_cli_wp_lanugage) <= 1) { |
| 51 | $wt_cli_wp_lanugage = 'en'; |
| 52 | } |
| 53 | define ( 'CLI_PLUGIN_DEVELOPMENT_MODE', false ); |
| 54 | define ( 'CLI_PLUGIN_BASENAME', plugin_basename(__FILE__) ); |
| 55 | define ( 'CLI_PLUGIN_PATH', plugin_dir_path(__FILE__) ); |
| 56 | define ( 'CLI_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 57 | define ( 'CLI_DB_KEY_PREFIX', 'CookieLawInfo-' ); |
| 58 | define ( 'CLI_LATEST_VERSION_NUMBER', '0.9' ); |
| 59 | define ( 'CLI_SETTINGS_FIELD', CLI_DB_KEY_PREFIX . CLI_LATEST_VERSION_NUMBER ); |
| 60 | define ( 'CLI_MIGRATED_VERSION', CLI_DB_KEY_PREFIX . 'MigratedVersion' ); |
| 61 | // Previous version settings (depreciated from 0.9 onwards): |
| 62 | define ( 'CLI_ADMIN_OPTIONS_NAME', 'CookieLawInfo-0.8.3' ); |
| 63 | define ( 'CLI_PLUGIN_FILENAME',__FILE__); |
| 64 | define ( 'CLI_POST_TYPE','cookielawinfo'); |
| 65 | define ('CLI_DEFAULT_LANGUAGE', substr($wt_cli_wp_lanugage, 0, 2)); |
| 66 | define ( 'CLI_ACTIVATION_ID','wtgdprcookieconsent'); |
| 67 | |
| 68 | /** |
| 69 | * Currently plugin version. |
| 70 | * Rename this for your plugin and update it as you release new versions. |
| 71 | */ |
| 72 | define( 'CLI_VERSION', '2.0.2' ); |
| 73 | |
| 74 | function wt_cookie_law_info_update_message( $data, $response ) |
| 75 | { |
| 76 | |
| 77 | if(isset( $data['upgrade_notice'])) |
| 78 | { |
| 79 | add_action( 'admin_print_footer_scripts','wt_cookie_law_info_plugin_screen_update_js'); |
| 80 | $msg=str_replace(array('<p>','</p>'),array('<div>','</div>'),$data['upgrade_notice']); |
| 81 | echo '<style type="text/css"> |
| 82 | #cookie-law-info-update .update-message p:last-child{ display:none;} |
| 83 | #cookie-law-info-update ul{ list-style:disc; margin-left:30px;} |
| 84 | .wf-update-message{ padding-left:30px;} |
| 85 | </style> |
| 86 | <div class="update-message wf-update-message"><div style="color: #f56e28;">' . __( '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>'. wpautop($msg).'</div>'; |
| 87 | } |
| 88 | } |
| 89 | function wt_cookie_law_info_plugin_screen_update_js() |
| 90 | { |
| 91 | ?> |
| 92 | <script> |
| 93 | ( function( $ ){ |
| 94 | var update_dv=$( '#cookie-law-info-update '); |
| 95 | update_dv.find('.wf-update-message').next('p').remove(); |
| 96 | update_dv.find('a.update-link:eq(0)').click(function(){ |
| 97 | $('.wf-update-message').remove(); |
| 98 | }); |
| 99 | })( jQuery ); |
| 100 | </script> |
| 101 | <?php |
| 102 | } |
| 103 | add_action( 'in_plugin_update_message-cookie-law-info/cookie-law-info.php', 'wt_cookie_law_info_update_message', 10, 2 ); |
| 104 | /** |
| 105 | * The code that runs during plugin activation. |
| 106 | * This action is documented in includes/class-cookie-law-info-activator.php |
| 107 | */ |
| 108 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-cookie-law-info-activator.php'; |
| 109 | function activate_cookie_law_info() { |
| 110 | Cookie_Law_Info_Activator::activate(); |
| 111 | register_uninstall_hook( __FILE__, 'uninstall_cookie_law_info' ); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * The code that runs during plugin deactivation. |
| 116 | * This action is documented in includes/class-cookie-law-info-deactivator.php |
| 117 | */ |
| 118 | function deactivate_cookie_law_info() { |
| 119 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-cookie-law-info-deactivator.php'; |
| 120 | Cookie_Law_Info_Deactivator::deactivate(); |
| 121 | } |
| 122 | register_activation_hook( __FILE__, 'activate_cookie_law_info' ); |
| 123 | register_deactivation_hook( __FILE__, 'deactivate_cookie_law_info' ); |
| 124 | |
| 125 | |
| 126 | function uninstall_cookie_law_info() |
| 127 | { |
| 128 | // Bye bye settings: |
| 129 | delete_option( CLI_ADMIN_OPTIONS_NAME ); |
| 130 | delete_option( CLI_MIGRATED_VERSION ); |
| 131 | delete_option( CLI_SETTINGS_FIELD ); |
| 132 | |
| 133 | // Bye bye custom meta: |
| 134 | $args = array('post_type' => 'cookielawinfo'); |
| 135 | $posts = get_posts($args); |
| 136 | if (!$posts) |
| 137 | { |
| 138 | return; |
| 139 | } |
| 140 | if($posts) |
| 141 | { |
| 142 | foreach($posts as $post) |
| 143 | { |
| 144 | $custom = get_post_custom( $post->ID ); |
| 145 | // Look for old values. If they exist, move them to new values then delete old values: |
| 146 | if ( isset ( $custom["cookie_type"][0] ) ) |
| 147 | { |
| 148 | delete_post_meta( $post->ID, "cookie_type", $custom["cookie_type"][0] ); |
| 149 | } |
| 150 | if ( isset ( $custom["cookie_duration"][0] ) ) |
| 151 | { |
| 152 | delete_post_meta( $post->ID, "cookie_duration", $custom["cookie_duration"][0] ); |
| 153 | } |
| 154 | if ( isset ( $custom["_cli_cookie_type"][0] ) ) |
| 155 | { |
| 156 | delete_post_meta( $post->ID, "_cli_cookie_type", $custom["_cli_cookie_type"][0] ); |
| 157 | } |
| 158 | if(isset( $custom["_cli_cookie_duration"][0] ) ) |
| 159 | { |
| 160 | delete_post_meta( $post->ID, "_cli_cookie_duration", $custom["_cli_cookie_duration"][0] ); |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | * The core plugin class that is used to define internationalization, |
| 170 | * admin-specific hooks, and public-facing site hooks. |
| 171 | */ |
| 172 | require plugin_dir_path( __FILE__ ) . 'includes/class-cookie-law-info.php'; |
| 173 | |
| 174 | |
| 175 | /** |
| 176 | * Begins execution of the plugin. |
| 177 | * |
| 178 | * Since everything within the plugin is registered via hooks, |
| 179 | * then kicking off the plugin from this point in the file does |
| 180 | * not affect the page life cycle. |
| 181 | * |
| 182 | * @since 1.6.6 |
| 183 | */ |
| 184 | function run_cookie_law_info() { |
| 185 | |
| 186 | $plugin = new Cookie_Law_Info(); |
| 187 | $plugin->run(); |
| 188 | } |
| 189 | run_cookie_law_info(); |
| 190 |