Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/cookiead.../includes
File: functions.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* CookieAdmin
[2] Fix | Delete
* https://cookieadmin.net
[3] Fix | Delete
* (c) Softaculous Team
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
// Are we being accessed directly ?
[7] Fix | Delete
if(!defined('COOKIEADMIN_PRO_VERSION')) {
[8] Fix | Delete
exit('Hacking Attempt !');
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
function cookieadmin_pro_activation(){
[12] Fix | Delete
update_option('cookieadmin_pro_version', COOKIEADMIN_PRO_VERSION);
[13] Fix | Delete
[14] Fix | Delete
include_once(COOKIEADMIN_PRO_DIR . 'includes/database.php');
[15] Fix | Delete
[16] Fix | Delete
\CookieAdminPro\Database::activate();
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
function cookieadmin_pro_is_network_active($plugin_name){
[20] Fix | Delete
$is_network_wide = false;
[21] Fix | Delete
[22] Fix | Delete
// Handling network site
[23] Fix | Delete
if(!is_multisite()){
[24] Fix | Delete
return $is_network_wide;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
$_tmp_plugins = get_site_option('active_sitewide_plugins');
[28] Fix | Delete
[29] Fix | Delete
if(!empty($_tmp_plugins) && preg_grep('/.*\/'.$plugin_name.'\.php$/', array_keys($_tmp_plugins))){
[30] Fix | Delete
$is_network_wide = true;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
return $is_network_wide;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
function cookieadmin_pro_update_checker(){
[37] Fix | Delete
[38] Fix | Delete
$current_version = get_option('cookieadmin_pro_version', '0.0');
[39] Fix | Delete
$version = (int) str_replace('.', '', $current_version);
[40] Fix | Delete
[41] Fix | Delete
// No update required
[42] Fix | Delete
if($current_version == COOKIEADMIN_PRO_VERSION){
[43] Fix | Delete
return true;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
$is_network_wide = cookieadmin_pro_is_network_active('cookieadmin');
[47] Fix | Delete
[48] Fix | Delete
if($is_network_wide){
[49] Fix | Delete
$free_ins = get_site_option('cookieadmin_free_installed');
[50] Fix | Delete
}else{
[51] Fix | Delete
$free_ins = get_option('cookieadmin_free_installed');
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
// If plugin runing reached here it means CookieAdmin free installed
[55] Fix | Delete
if(empty($free_ins)){
[56] Fix | Delete
if($is_network_wide){
[57] Fix | Delete
update_site_option('cookieadmin_free_installed', time());
[58] Fix | Delete
}else{
[59] Fix | Delete
update_option('cookieadmin_free_installed', time());
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
update_option('cookieadmin_version_pro_nag', time());
[64] Fix | Delete
update_option('cookieadmin_version_free_nag', time());
[65] Fix | Delete
update_option('cookieadmin_pro_version', COOKIEADMIN_PRO_VERSION);
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
[69] Fix | Delete
// Load license data
[70] Fix | Delete
function cookieadmin_pro_load_license($parent = 0){
[71] Fix | Delete
[72] Fix | Delete
global $cookieadmin, $lic_resp, $sitepad;
[73] Fix | Delete
[74] Fix | Delete
$license_field = 'cookieadmin_license';
[75] Fix | Delete
$license_api_url = COOKIEADMIN_API;
[76] Fix | Delete
[77] Fix | Delete
// Save license
[78] Fix | Delete
if(!empty($parent) && is_string($parent) && strlen($parent) > 5){
[79] Fix | Delete
$lic['license'] = $parent;
[80] Fix | Delete
[81] Fix | Delete
// Load license of Soft Pro
[82] Fix | Delete
}elseif(!empty($parent)){
[83] Fix | Delete
$license_field = 'softaculous_pro_license';
[84] Fix | Delete
$lic = get_option('softaculous_pro_license', []);
[85] Fix | Delete
[86] Fix | Delete
// My license
[87] Fix | Delete
}else{
[88] Fix | Delete
$lic = get_option($license_field, []);
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
// Loaded license is a Soft Pro
[92] Fix | Delete
if(!empty($lic['license']) && preg_match('/^softwp/is', $lic['license'])){
[93] Fix | Delete
$license_field = 'softaculous_pro_license';
[94] Fix | Delete
$license_api_url = 'https://a.softaculous.com/softwp/';
[95] Fix | Delete
$prods = apply_filters('softaculous_pro_products', []);
[96] Fix | Delete
}else{
[97] Fix | Delete
$prods = [];
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
if(empty($lic['last_update'])){
[101] Fix | Delete
$lic['last_update'] = time() - 86600;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
// Update license details as well
[105] Fix | Delete
if(!empty($lic) && !empty($lic['license']) && (time() - @$lic['last_update']) >= 86400){
[106] Fix | Delete
[107] Fix | Delete
$url = $license_api_url.'/license.php?license='.$lic['license'].'&prods='.implode(',', $prods).'&url='.rawurlencode(site_url());
[108] Fix | Delete
$resp = wp_remote_get($url);
[109] Fix | Delete
$lic_resp = $resp;
[110] Fix | Delete
[111] Fix | Delete
//Did we get a response ?
[112] Fix | Delete
if(is_array($resp)){
[113] Fix | Delete
[114] Fix | Delete
$tosave = json_decode($resp['body'], true);
[115] Fix | Delete
[116] Fix | Delete
//Is it the license ?
[117] Fix | Delete
if(!empty($tosave['license'])){
[118] Fix | Delete
$tosave['last_update'] = time();
[119] Fix | Delete
update_option($license_field, $tosave);
[120] Fix | Delete
$lic = $tosave;
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
// If the license is Free or Expired check for Softaculous Pro license
[126] Fix | Delete
if(empty($lic) || empty($lic['active'])){
[127] Fix | Delete
[128] Fix | Delete
if(function_exists('softaculous_pro_load_license')){
[129] Fix | Delete
$softaculous_license = softaculous_pro_load_license();
[130] Fix | Delete
if(!empty($softaculous_license['license']) &&
[131] Fix | Delete
(!empty($softaculous_license['active']) || empty($lic['license']))
[132] Fix | Delete
){
[133] Fix | Delete
$lic = $softaculous_license;
[134] Fix | Delete
}
[135] Fix | Delete
}elseif(empty($parent)){
[136] Fix | Delete
$soft_lic = get_option('softaculous_pro_license', []);
[137] Fix | Delete
[138] Fix | Delete
if(!empty($soft_lic)){
[139] Fix | Delete
return cookieadmin_pro_load_license(1);
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
if(!empty($lic['license'])){
[145] Fix | Delete
$cookieadmin['license'] = $lic;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
// For sitepad users
[149] Fix | Delete
if(defined('SITEPAD') && empty($cookieadmin['license'])){
[150] Fix | Delete
$license = !empty($sitepad['license']) ? $sitepad['license']: (isset($sitepad['server_license']) ? $sitepad['server_license'] : []);
[151] Fix | Delete
$license['active'] = isset($license['active']) ? $license['active'] : (isset($license['status']) ? $license['status'] : '');
[152] Fix | Delete
$cookieadmin['license'] = $license;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
add_filter('softaculous_pro_products', 'cookieadmin_pro_softaculous_pro_products', 10, 1);
[158] Fix | Delete
function cookieadmin_pro_softaculous_pro_products($r = []){
[159] Fix | Delete
$r['cookieadmin'] = 'cookieadmin';
[160] Fix | Delete
return $r;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// Add our license key if ANY
[164] Fix | Delete
function cookieadmin_pro_updater_filter_args($queryArgs){
[165] Fix | Delete
[166] Fix | Delete
global $cookieadmin;
[167] Fix | Delete
[168] Fix | Delete
if (!empty($cookieadmin['license']['license'])){
[169] Fix | Delete
$queryArgs['license'] = $cookieadmin['license']['license'];
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
$queryArgs['url'] = rawurlencode(site_url());
[173] Fix | Delete
[174] Fix | Delete
return $queryArgs;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
function cookieadmin_pro_ajax_handler(){
[178] Fix | Delete
[179] Fix | Delete
$cookieadmin_fn = (!empty($_REQUEST['cookieadmin_act']) ? sanitize_text_field(wp_unslash($_REQUEST['cookieadmin_act'])) : '');
[180] Fix | Delete
[181] Fix | Delete
if(empty($cookieadmin_fn)){
[182] Fix | Delete
wp_send_json_error(array('message' => 'Action not posted'));
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
// Define a whitelist of allowed functions
[186] Fix | Delete
$user_allowed_actions = array(
[187] Fix | Delete
'save_consent' => 'save_consent'
[188] Fix | Delete
);
[189] Fix | Delete
[190] Fix | Delete
$admin_allowed_actions = array(
[191] Fix | Delete
'export_logs' => 'export_logs',
[192] Fix | Delete
'get_consent_logs' => 'get_consent_logs',
[193] Fix | Delete
'dismiss_expired_licenses' => 'dismiss_expired_licenses',
[194] Fix | Delete
'version_notice' => 'version_notice'
[195] Fix | Delete
);
[196] Fix | Delete
[197] Fix | Delete
if(array_key_exists($cookieadmin_fn, $user_allowed_actions)){
[198] Fix | Delete
[199] Fix | Delete
check_ajax_referer('cookieadmin_pro_js_nonce', 'cookieadmin_pro_security');
[200] Fix | Delete
header_remove('Set-Cookie');
[201] Fix | Delete
call_user_func('\CookieAdminPro\Enduser::'.$user_allowed_actions[$cookieadmin_fn]);
[202] Fix | Delete
[203] Fix | Delete
}elseif(array_key_exists($cookieadmin_fn, $admin_allowed_actions)){
[204] Fix | Delete
[205] Fix | Delete
check_ajax_referer('cookieadmin_pro_admin_js_nonce', 'cookieadmin_pro_security');
[206] Fix | Delete
[207] Fix | Delete
if(!current_user_can('administrator')){
[208] Fix | Delete
wp_send_json_error(array('message' => 'Sorry, but you do not have permissions to perform this action'));
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
call_user_func('\CookieAdminPro\Admin::'.$admin_allowed_actions[$cookieadmin_fn]);
[212] Fix | Delete
[213] Fix | Delete
}else{
[214] Fix | Delete
wp_send_json_error(array('message' => 'Unauthorized action'));
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
// Handle the Check for update link and ask to install license key
[220] Fix | Delete
function cookieadmin_pro_updater_check_link($final_link){
[221] Fix | Delete
[222] Fix | Delete
global $cookieadmin;
[223] Fix | Delete
[224] Fix | Delete
if(empty($cookieadmin['license']['license'])){
[225] Fix | Delete
return '<a href="'.admin_url('admin.php?page=cookieadmin-license').'">'.esc_html__('Install CookieAdmin Pro License Key', 'cookieadmin').'</a>';
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
return $final_link;
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
// Prevent update of cookieadmin free
[232] Fix | Delete
function cookieadmin_pro_get_free_version_num(){
[233] Fix | Delete
[234] Fix | Delete
if(defined('COOKIEADMIN_VERSION')){
[235] Fix | Delete
return COOKIEADMIN_VERSION;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
// In case of cookieadmin deactive
[239] Fix | Delete
return cookieadmin_pro_file_get_version_num('cookieadmin/cookieadmin.php');
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
// Prevent update of cookieadmin free
[243] Fix | Delete
function cookieadmin_pro_file_get_version_num($plugin){
[244] Fix | Delete
[245] Fix | Delete
// In case of cookieadmin deactive
[246] Fix | Delete
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
[247] Fix | Delete
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/'.$plugin);
[248] Fix | Delete
[249] Fix | Delete
if(empty($plugin_data)){
[250] Fix | Delete
return false;
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
return $plugin_data['Version'];
[254] Fix | Delete
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
// Prevent update of cookieadmin free
[258] Fix | Delete
function cookieadmin_pro_disable_manual_update_for_plugin($transient){
[259] Fix | Delete
$plugin = 'cookieadmin/cookieadmin.php';
[260] Fix | Delete
[261] Fix | Delete
// Is update available?
[262] Fix | Delete
if(!isset($transient->response) || !isset($transient->response[$plugin])){
[263] Fix | Delete
return $transient;
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
$free_version = cookieadmin_pro_get_free_version_num();
[267] Fix | Delete
$pro_version = COOKIEADMIN_PRO_VERSION;
[268] Fix | Delete
[269] Fix | Delete
if(!empty($GLOBALS['cookieadmin_pro_is_upgraded'])){
[270] Fix | Delete
$pro_version = cookieadmin_pro_file_get_version_num('cookieadmin-pro/cookieadmin-pro.php');
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// Update the cookieadmin version to the equivalent of Pro version
[274] Fix | Delete
if(!empty($pro_version) && version_compare($free_version, $pro_version, '<')){
[275] Fix | Delete
$transient->response[$plugin]->new_version = $pro_version;
[276] Fix | Delete
$transient->response[$plugin]->package = 'https://downloads.wordpress.org/plugin/cookieadmin.'.$pro_version.'.zip';
[277] Fix | Delete
}else{
[278] Fix | Delete
unset($transient->response[$plugin]);
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
return $transient;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
// Auto update free version after update pro version
[285] Fix | Delete
function cookieadmin_pro_update_free_after_pro($upgrader_object, $options){
[286] Fix | Delete
[287] Fix | Delete
// Check if the action is an update for the plugins
[288] Fix | Delete
if($options['action'] != 'update' || $options['type'] != 'plugin'){
[289] Fix | Delete
return;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
// Define the slugs for the free and pro plugins
[293] Fix | Delete
$free_slug = 'cookieadmin/cookieadmin.php';
[294] Fix | Delete
$pro_slug = 'cookieadmin-pro/cookieadmin-pro.php';
[295] Fix | Delete
[296] Fix | Delete
// Check if the pro plugin is in the list of updated plugins
[297] Fix | Delete
if(
[298] Fix | Delete
(isset($options['plugins']) && in_array($pro_slug, $options['plugins']) && !in_array($free_slug, $options['plugins'])) ||
[299] Fix | Delete
(isset($options['plugin']) && $pro_slug == $options['plugin'])
[300] Fix | Delete
){
[301] Fix | Delete
[302] Fix | Delete
// Trigger the update for the free plugin
[303] Fix | Delete
$current_version = cookieadmin_pro_get_free_version_num();
[304] Fix | Delete
[305] Fix | Delete
if(empty($current_version)){
[306] Fix | Delete
return;
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
$GLOBALS['cookieadmin_pro_is_upgraded'] = true;
[310] Fix | Delete
[311] Fix | Delete
// This will set the 'update_plugins' transient again
[312] Fix | Delete
wp_update_plugins();
[313] Fix | Delete
[314] Fix | Delete
// Check for updates for the free plugin
[315] Fix | Delete
$update_plugins = get_site_transient('update_plugins');
[316] Fix | Delete
[317] Fix | Delete
if(empty($update_plugins) || !isset($update_plugins->response[$free_slug]) || version_compare($update_plugins->response[$free_slug]->new_version, $current_version, '<=')){
[318] Fix | Delete
return;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
[322] Fix | Delete
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
[323] Fix | Delete
[324] Fix | Delete
$skin = wp_doing_ajax()? new WP_Ajax_Upgrader_Skin() : null;
[325] Fix | Delete
[326] Fix | Delete
$upgrader = new Plugin_Upgrader($skin);
[327] Fix | Delete
$upgraded = $upgrader->upgrade($free_slug);
[328] Fix | Delete
[329] Fix | Delete
if(!is_wp_error($upgraded) && $upgraded){
[330] Fix | Delete
// Re-active free plugins
[331] Fix | Delete
if( file_exists( WP_PLUGIN_DIR . '/'. $free_slug ) && is_plugin_inactive($free_slug) ){
[332] Fix | Delete
activate_plugin($free_slug); // TODO for network
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
// Re-active pro plugins
[336] Fix | Delete
if( file_exists( WP_PLUGIN_DIR . '/'. $pro_slug ) && is_plugin_inactive($pro_slug) ){
[337] Fix | Delete
activate_plugin($pro_slug); // TODO for network
[338] Fix | Delete
}
[339] Fix | Delete
}
[340] Fix | Delete
}
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
function cookieadmin_pro_api_url($main_server = 0, $suffix = 'cookieadmin'){
[344] Fix | Delete
[345] Fix | Delete
global $cookieadmin;
[346] Fix | Delete
[347] Fix | Delete
$r = array(
[348] Fix | Delete
'https://s0.softaculous.com/a/softwp/',
[349] Fix | Delete
'https://s1.softaculous.com/a/softwp/',
[350] Fix | Delete
'https://s2.softaculous.com/a/softwp/',
[351] Fix | Delete
'https://s3.softaculous.com/a/softwp/',
[352] Fix | Delete
'https://s4.softaculous.com/a/softwp/',
[353] Fix | Delete
'https://s5.softaculous.com/a/softwp/',
[354] Fix | Delete
'https://s6.softaculous.com/a/softwp/',
[355] Fix | Delete
'https://s7.softaculous.com/a/softwp/',
[356] Fix | Delete
'https://s8.softaculous.com/a/softwp/'
[357] Fix | Delete
);
[358] Fix | Delete
[359] Fix | Delete
$mirror = $r[array_rand($r)];
[360] Fix | Delete
[361] Fix | Delete
if(!empty($suffix)){
[362] Fix | Delete
$mirror = str_replace('/softwp', '/'.$suffix, $mirror);
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
if(!empty($main_server) && $main_server < 0){
[366] Fix | Delete
return $mirror;
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
// If the license is newly issued, we need to fetch from API only
[370] Fix | Delete
if(!empty($main_server) || empty($cookieadmin['license']['last_edit']) ||
[371] Fix | Delete
(!empty($cookieadmin['license']['last_edit']) && (time() - 3600) < $cookieadmin['license']['last_edit'])
[372] Fix | Delete
){
[373] Fix | Delete
$mirror = COOKIEADMIN_API;
[374] Fix | Delete
}
[375] Fix | Delete
[376] Fix | Delete
return $mirror;
[377] Fix | Delete
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
function cookieadmin_pro_plugins_expired($plugins){
[381] Fix | Delete
$plugins[] = 'CookieAdmin';
[382] Fix | Delete
return $plugins;
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
function cookieadmin_pro_expiry_notice(){
[386] Fix | Delete
global $cookieadmin;
[387] Fix | Delete
[388] Fix | Delete
// The combined notice for all Softaculous plugin to show that the license has expired
[389] Fix | Delete
$dismissed_at = get_option('softaculous_expired_licenses', 0);
[390] Fix | Delete
$expired_plugins = apply_filters('softaculous_expired_licenses', []);
[391] Fix | Delete
if(
[392] Fix | Delete
!empty($expired_plugins) &&
[393] Fix | Delete
is_array($expired_plugins) &&
[394] Fix | Delete
!defined('SOFTACULOUS_EXPIRY_LICENSES') &&
[395] Fix | Delete
(empty($dismissed_at) || ($dismissed_at + WEEK_IN_SECONDS) < time())
[396] Fix | Delete
){
[397] Fix | Delete
[398] Fix | Delete
define('SOFTACULOUS_EXPIRY_LICENSES', true); // To make sure other plugins don't return a Notice
[399] Fix | Delete
[400] Fix | Delete
echo '<div class="notice notice-error is-dismissible" id="cookieadmin-pro-expiry-notice">
[401] Fix | Delete
<p>'.
[402] Fix | Delete
/* translators: 1: Styling for red color and bold, 2: Styling for red color and bold ends, 3: List of Softaculous plugins that have expired */
[403] Fix | Delete
sprintf(esc_html__('Your SoftWP license has %1$sexpired%2$s. Please renew it to continue receiving uninterrupted updates and support for %3$s.', 'cookieadmin'),
[404] Fix | Delete
'<font style="color:red;"><b>',
[405] Fix | Delete
'</b></font>',
[406] Fix | Delete
esc_html(implode(', ', $expired_plugins))
[407] Fix | Delete
). '</p>
[408] Fix | Delete
</div>';
[409] Fix | Delete
[410] Fix | Delete
wp_register_script('cookieadmin-pro-expiry-notice', '', ['jquery'], COOKIEADMIN_PRO_VERSION, true);
[411] Fix | Delete
wp_enqueue_script('cookieadmin-pro-expiry-notice');
[412] Fix | Delete
wp_add_inline_script('cookieadmin-pro-expiry-notice', '
[413] Fix | Delete
jQuery(document).ready(function(){
[414] Fix | Delete
jQuery("#cookieadmin-pro-expiry-notice").on("click", ".notice-dismiss", function(e){
[415] Fix | Delete
e.preventDefault();
[416] Fix | Delete
let target = jQuery(e.target);
[417] Fix | Delete
[418] Fix | Delete
let jEle = target.closest("#cookieadmin-pro-expiry-notice");
[419] Fix | Delete
jEle.slideUp();
[420] Fix | Delete
[421] Fix | Delete
jQuery.post("'.admin_url('admin-ajax.php').'", {
[422] Fix | Delete
cookieadmin_pro_security : "'.wp_create_nonce('cookieadmin_pro_admin_js_nonce').'",
[423] Fix | Delete
action: "cookieadmin_pro_ajax_handler",
[424] Fix | Delete
cookieadmin_act: "dismiss_expired_licenses",
[425] Fix | Delete
}, function(res){
[426] Fix | Delete
if(!res["success"]){
[427] Fix | Delete
alert(res["data"]);
[428] Fix | Delete
}
[429] Fix | Delete
}).fail(function(data){
[430] Fix | Delete
alert("There seems to be some issue dismissing this alert");
[431] Fix | Delete
});
[432] Fix | Delete
});
[433] Fix | Delete
})');
[434] Fix | Delete
}
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
function cookieadmin_pro_human_readable_time($timestamp){
[438] Fix | Delete
[439] Fix | Delete
$now = time();
[440] Fix | Delete
$today_start = strtotime('today');
[441] Fix | Delete
$yesterday_start = strtotime('yesterday');
[442] Fix | Delete
[443] Fix | Delete
if ($timestamp >= $today_start) {
[444] Fix | Delete
return 'Today ' . wp_date('g:i A T', $timestamp);
[445] Fix | Delete
} elseif ($timestamp >= $yesterday_start) {
[446] Fix | Delete
return 'Yesterday ' . wp_date('g:i A T', $timestamp);
[447] Fix | Delete
} else {
[448] Fix | Delete
return wp_date('M j Y g:i A T', $timestamp); // e.g., Dec 6 2024 6:00 AM UTC
[449] Fix | Delete
}
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
function cookieadmin_pro_scan_cookies($urls){
[453] Fix | Delete
[454] Fix | Delete
$scanner_info = get_option('cookieadmin_pro_scanner', []);
[455] Fix | Delete
[456] Fix | Delete
if(empty($scanner_info['last_scan']) || (time() > $scanner_info['last_scan'] + 3600)){
[457] Fix | Delete
return call_user_func('\CookieAdminPro\Scanner::start_scan', $urls);
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
wp_send_json_error(array('message' => __('Cookie Scan can be triggered once an hour', 'cookieadmin')));
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
function cookieadmin_pro_render_cookie_data($attributes = ""){
[464] Fix | Delete
global $wpdb;
[465] Fix | Delete
[466] Fix | Delete
if(!empty($attributes)){
[467] Fix | Delete
$show_category = explode(',', $attributes['categories']);
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
$table_name = esc_sql($wpdb->prefix.'cookieadmin_cookies');
[471] Fix | Delete
$scanned_cookies = $wpdb->get_results("SELECT * FROM {$table_name}");
[472] Fix | Delete
[473] Fix | Delete
// group cookies by category
[474] Fix | Delete
$grouped_cookies = array();
[475] Fix | Delete
[476] Fix | Delete
foreach($scanned_cookies as $cookie){
[477] Fix | Delete
$category = !empty($cookie->category) ? $cookie->category : 'Unknown';
[478] Fix | Delete
if(!empty($show_category) && !in_array(strtolower($category), $show_category)){
[479] Fix | Delete
continue;
[480] Fix | Delete
}
[481] Fix | Delete
$grouped_cookies[$category][] = $cookie;
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
$cookiedata = '<div style="overflow-x:auto;">';
[485] Fix | Delete
$cookiedata .= '<table style="width:100%; border-collapse:collapse;">';
[486] Fix | Delete
[487] Fix | Delete
$cookiedata .= '
[488] Fix | Delete
<thead>
[489] Fix | Delete
<tr>
[490] Fix | Delete
<th style="border:1px solid #ddd; padding:10px; background:#2c3e50; color:#fff; text-align:left; width:35%;">'.esc_html__('Name', 'cookieadmin').'</th>
[491] Fix | Delete
<th style="border:1px solid #ddd; padding:10px; background:#2c3e50; color:#fff; text-align:left; width:50%">'.esc_html__('Description', 'cookieadmin').'</th>
[492] Fix | Delete
<th style="border:1px solid #ddd; padding:10px; background:#2c3e50; color:#fff; text-align:left; width:15%">'.esc_html__('Expiry', 'cookieadmin').'</th>
[493] Fix | Delete
</tr>
[494] Fix | Delete
</thead>
[495] Fix | Delete
<tbody>';
[496] Fix | Delete
[497] Fix | Delete
foreach($grouped_cookies as $category => $cookies){
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function