| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: The GDPR Framework |
| 5 |
* Plugin URI: https://www.data443.com/gdpr-framework/ |
| 6 |
* Description: Tools to help make your website GDPR-compliant. Fully documented, extendable and developer-friendly. |
| 7 |
* Author: Data443 |
| 8 |
* Requires at least: 4.7 |
| 9 |
* Requires PHP: 5.6 |
| 10 |
* Version: 2.1.0 |
| 11 |
* Author URI: https://www.data443.com/ |
| 12 |
* Text Domain: gdpr-framework |
| 13 |
* Domain Path: /languages |
| 14 |
* |
| 15 |
* @package WordPress |
| 16 |
*/ |
| 17 |
|
| 18 |
if (!defined('WPINC')) |
| 19 |
{ |
| 20 |
die; |
| 21 |
} |
| 22 |
|
| 23 |
if (defined('GDPR_FRAMEWORK_PRO_VERSION')) { |
| 24 |
function GDPR_admin_notices() { |
| 25 |
?> |
| 26 |
<div style="clear:both"></div> |
| 27 |
<div class="error iwp" style="padding:10px;"> |
| 28 |
The PREMIUM GDPR plugin is already installed. Please deactivate this plugin to continue using the FREE version. |
| 29 |
</div> |
| 30 |
<div style="clear:both"></div> |
| 31 |
<?php } |
| 32 |
add_action('admin_notices', 'GDPR_admin_notices'); |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
define('GDPR_FRAMEWORK_VERSION', '2.1.0'); |
| 37 |
|
| 38 |
define('GDPR_DEFAULT_UNKNOWN_USER_MESSAGE', 'Message received.'); |
| 39 |
|
| 40 |
add_shortcode( 'gdpr_privacy_safe', 'render_privacy_safe' ); // preserve backward compatibility |
| 41 |
add_shortcode( 'data443_privacy_safe', 'render_privacy_safe' ); |
| 42 |
|
| 43 |
/** |
| 44 |
* Render WHMCS Seal Generator Addon Javascript |
| 45 |
*/ |
| 46 |
function render_privacy_safe() { |
| 47 |
global $gdpr; |
| 48 |
wp_register_script( 'gdpr_whmcs_seal_generator', $gdpr->PluginUrl . 'assets/js/showseal.js', null, true, true ); |
| 49 |
wp_localize_script( |
| 50 |
'gdpr_whmcs_seal_generator', |
| 51 |
'gdpr_seal_var', |
| 52 |
array( |
| 53 |
'gdpr_imageparams' => esc_attr( get_option( 'gdpr_privacy_safe_params' ) ), |
| 54 |
'gdpr_imagecode' => esc_attr( get_option( 'gdpr_privacy_safe_imagecode' ) ), |
| 55 |
'gdpr_showimagefunc' => 'showimage_' . esc_attr( get_option( 'gdpr_privacy_safe_imagecode' ) ), |
| 56 |
) |
| 57 |
); |
| 58 |
wp_enqueue_script( 'gdpr_whmcs_seal_generator', basename( dirname( __FILE__ ) ) . 'assets/js/showseal.js', null, true, true ); |
| 59 |
|
| 60 |
$seal_code = '<div class="data443-privacy-safe" style="font-size:12px;text-align: left;">'; |
| 61 |
|
| 62 |
if( get_option( 'gdpr_privacy_safe_imagecode' ) !== '' && get_option( 'gdpr_privacy_safe_params' ) !== '' ){ |
| 63 |
$seal_code .= '<a href="javascript:;" onclick="openpopup_' . esc_attr( get_option( 'gdpr_privacy_safe_imagecode' ) ) . '();"> |
| 64 |
<img id="data443-privacy-safe-image" src="https://orders.data443.com/seal/seal.php?params=' . esc_attr( get_option( 'gdpr_privacy_safe_params' ) ) . '" alt="Data443 Privacy Safe" /> |
| 65 |
</a>'; |
| 66 |
} |
| 67 |
if( get_option( 'gdpr_privacy_safe_backlink' ) === '1' ){ |
| 68 |
$seal_code .= '<span style="display:block;">Privacy Management Service by <a href="https://data443.com/products/global-privacy-manager/" target="_blank">Data443</a></span>'; |
| 69 |
} |
| 70 |
$seal_code .= '</div>'; |
| 71 |
// scale the size of the link text based on the loaded scaled image |
| 72 |
$seal_code .= "<script>jQuery('#data443-privacy-safe-image').load(function(){var px='12px';var w=jQuery(this).width();if(w>0&&w<=150){px='6px'}else if(w<300){px='10px'};jQuery('.data443-privacy-safe').css({'font-size': px});})</script>"; |
| 73 |
return $seal_code; |
| 74 |
} |
| 75 |
|
| 76 |
function gdpr_framework_load_textdomain() |
| 77 |
{ |
| 78 |
load_plugin_textdomain('gdpr-framework', false, basename( dirname( __FILE__ ) ) . '/languages/'); |
| 79 |
} |
| 80 |
add_action('init', 'gdpr_framework_load_textdomain'); |
| 81 |
|
| 82 |
/** |
| 83 |
* Our custom post type function |
| 84 |
*/ |
| 85 |
function create_custom_post_type() |
| 86 |
{ |
| 87 |
$args = array( |
| 88 |
'label' => 'Do Not Sell Info', |
| 89 |
'public' => true, |
| 90 |
'has_archive' => false, |
| 91 |
'exclude_from_search' => true, |
| 92 |
'publicly_queryable' => false, |
| 93 |
'show_in_menu' => false, |
| 94 |
'menu_position' => 20, |
| 95 |
'show_ui' => true, |
| 96 |
'hierarchical' => false, |
| 97 |
'rewrite' => array( 'slug' => 'donotsellrequests' ), |
| 98 |
'query_var' => true, |
| 99 |
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'post-formats' ), |
| 100 |
); |
| 101 |
register_post_type( 'donotsellrequests', $args ); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Hooking up our function to theme setup |
| 106 |
*/ |
| 107 |
add_action( 'init', 'create_custom_post_type' ); |
| 108 |
|
| 109 |
// Add Columns to our custom posts |
| 110 |
|
| 111 |
add_filter('manage_donotsellrequests_posts_columns', function ($columns) { |
| 112 |
$columns = array_merge($columns, ['donotsell_first_name' => __('First Name', 'textdomain')]); |
| 113 |
$columns = array_merge($columns, ['donotsell_last_name' => __('Last Name', 'textdomain')]); |
| 114 |
$columns = array_merge($columns, ['title' => __('Email', 'textdomain')]); |
| 115 |
$taken_out = $columns['date']; |
| 116 |
unset($columns['date']); |
| 117 |
$columns['date'] = $taken_out; |
| 118 |
return $columns; |
| 119 |
}); |
| 120 |
|
| 121 |
add_action('manage_donotsellrequests_posts_custom_column', function ($column_key, $post_id) { |
| 122 |
if ($column_key == 'donotsell_first_name') { |
| 123 |
$data = get_post_meta($post_id, 'donotsell_first_name', true); |
| 124 |
_e($data, 'textdomain'); |
| 125 |
} elseif ($column_key == 'donotsell_last_name') { |
| 126 |
$data = get_post_meta($post_id, 'donotsell_last_name', true); |
| 127 |
_e($data, 'textdomain'); |
| 128 |
} |
| 129 |
|
| 130 |
}, 10, 2); |
| 131 |
|
| 132 |
/** |
| 133 |
* Helper function for prettying up errors |
| 134 |
* |
| 135 |
* @param string $message |
| 136 |
* @param string $subtitle |
| 137 |
* @param string $title |
| 138 |
*/ |
| 139 |
$gdpr_error = function($message, $subtitle = '', $title = '') |
| 140 |
{ |
| 141 |
$title = $title ?: _x('WordPress GDPR › Error', '(Admin)', 'gdpr-framework'); |
| 142 |
$message = "<h1>{$title}<br><small>{$subtitle}</small></h1><p>{$message}</p>"; |
| 143 |
wp_die($message, $title); |
| 144 |
}; |
| 145 |
|
| 146 |
/** |
| 147 |
* Ensure compatible version of PHP is used |
| 148 |
*/ |
| 149 |
if (version_compare(phpversion(), '5.6.0', '<')) |
| 150 |
{ |
| 151 |
$gdpr_error( |
| 152 |
_x('You must be using PHP 5.6.0 or greater.', '(Admin)', 'gdpr-framework'), |
| 153 |
_x('Invalid PHP version', '(Admin)', 'gdpr-framework') |
| 154 |
); |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* Ensure compatible version of WordPress is used |
| 159 |
*/ |
| 160 |
if (version_compare(get_bloginfo('version'), '4.3', '<')) |
| 161 |
{ |
| 162 |
$gdpr_error( |
| 163 |
_x('You must be using WordPress 4.3.0 or greater.', '(Admin)', 'gdpr-framework'), |
| 164 |
_x('Invalid WordPress version', '(Admin)', 'gdpr-framework') |
| 165 |
); |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* Fix issue with redeclate function issue on DIVI theme. |
| 170 |
*/ |
| 171 |
function TermAndConditionWithPrivacyContent() |
| 172 |
{ |
| 173 |
return 'I accept the %sTerms and Conditions%s and the %sPrivacy Policy%s'; |
| 174 |
} |
| 175 |
|
| 176 |
function gdprfPrivacyPolicy() |
| 177 |
{ |
| 178 |
return 'I accept the %sPrivacy Policy%s'; |
| 179 |
} |
| 180 |
|
| 181 |
function gdprfPrivacyPolicyurl($policypage) |
| 182 |
{ |
| 183 |
$policypageURL = get_option( 'gdpr_custom_policy_page' ); |
| 184 |
if($policypageURL=="") |
| 185 |
{ |
| 186 |
return $policypage; |
| 187 |
}else{ |
| 188 |
return $policypageURL; |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
function gdpr_privacy_accpetance($gdpr_error_massage) |
| 193 |
{ |
| 194 |
return $gdpr_error_massage; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Save user logs |
| 199 |
*/ |
| 200 |
add_action( 'profile_update', 'my_profile_update', 10, 2 ); |
| 201 |
|
| 202 |
function my_profile_update( $user_id, $old_user_data ) |
| 203 |
{ |
| 204 |
$data = (array) $old_user_data->data; |
| 205 |
|
| 206 |
$all_meta_for_user = get_user_meta( $user_id ); |
| 207 |
if($all_meta_for_user['nickname']['0']){ |
| 208 |
$data['nickname'] = $all_meta_for_user['nickname']['0']; |
| 209 |
} |
| 210 |
if($all_meta_for_user['first_name']['0']){ |
| 211 |
$data['first_name'] = $all_meta_for_user['first_name']['0']; |
| 212 |
} |
| 213 |
if($all_meta_for_user['last_name']['0']){ |
| 214 |
$data['last_name'] = $all_meta_for_user['last_name']['0']; |
| 215 |
} |
| 216 |
if($all_meta_for_user['description']['0']){ |
| 217 |
$data['description'] = $all_meta_for_user['description']['0']; |
| 218 |
} |
| 219 |
$userdata = serialize($data); |
| 220 |
$model = new \Codelight\GDPR\Components\Consent\UserConsentModel(); |
| 221 |
$model->savelog($user_id,$userdata); |
| 222 |
} |
| 223 |
|
| 224 |
include_once(dirname(__FILE__).'/autoload.php'); |
| 225 |
|
| 226 |
register_activation_hook(__FILE__, function () { |
| 227 |
if (in_array('gdpr-framework-pro/gdpr-framework.php', apply_filters('active_plugins', get_option('active_plugins')))) { |
| 228 |
die('This plugin could not be activated because the PRO version of this plugin is active.'); |
| 229 |
} |
| 230 |
$model = new \Codelight\GDPR\Components\Consent\UserConsentModel(); |
| 231 |
$model->createTable(); |
| 232 |
$model->createUserTable(); |
| 233 |
if (apply_filters('gdpr/data-subject/anonymize/change_role', true) && ! get_role('anonymous')) { |
| 234 |
|
| 235 |
add_role( |
| 236 |
'anonymous', |
| 237 |
_x('Anonymous', '(Admin)', 'gdpr-framework'), |
| 238 |
array() |
| 239 |
); |
| 240 |
} |
| 241 |
|
| 242 |
update_option('gdpr_enable_stylesheet', true); |
| 243 |
update_option('gdpr_enable', true); |
| 244 |
}); |
| 245 |
|
| 246 |
require_once('gdpr-helper-functions.php'); |
| 247 |
require_once('bootstrap.php'); |
| 248 |
|