| 1 |
<?php |
| 2 |
|
| 3 |
namespace CookieAdmin; |
| 4 |
|
| 5 |
if(!defined('COOKIEADMIN_VERSION') || !defined('ABSPATH')){ |
| 6 |
die('Hacking Attempt'); |
| 7 |
} |
| 8 |
|
| 9 |
class Admin{ |
| 10 |
|
| 11 |
static function enqueue_scripts(){ |
| 12 |
|
| 13 |
if(!is_admin()){ |
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; |
| 18 |
$admin_page = basename(parse_url($request_uri, PHP_URL_PATH)); |
| 19 |
|
| 20 |
if($admin_page != 'admin.php'){ |
| 21 |
return true; |
| 22 |
} |
| 23 |
|
| 24 |
$current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 25 |
|
| 26 |
// List all page slugs where styles should be loaded |
| 27 |
$plugin_pages = [ |
| 28 |
'cookieadmin', |
| 29 |
'cookieadmin-settings', |
| 30 |
'cookieadmin-scan-cookies', |
| 31 |
'cookieadmin-consent', |
| 32 |
'cookieadmin-consent-logs', |
| 33 |
'cookieadmin-license', |
| 34 |
'cookieadmin-do-not-sell' |
| 35 |
]; |
| 36 |
|
| 37 |
if(empty($current_page) || !in_array($current_page, $plugin_pages)){ |
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
//Consent Page CSS |
| 42 |
wp_enqueue_style('cookieadmin-style', COOKIEADMIN_PLUGIN_URL . 'assets/css/cookie.css', [], COOKIEADMIN_VERSION); |
| 43 |
wp_enqueue_style('cookieadmin-user-style', COOKIEADMIN_PLUGIN_URL . 'assets/css/consent.css', [], COOKIEADMIN_VERSION); |
| 44 |
|
| 45 |
//WP Color picker |
| 46 |
wp_enqueue_style('wp-color-picker'); |
| 47 |
|
| 48 |
$view = get_option('cookieadmin_law', 'cookieadmin_gdpr'); |
| 49 |
$policy = cookieadmin_load_policy(); |
| 50 |
|
| 51 |
if(!empty($policy) && !empty($view)){ |
| 52 |
|
| 53 |
wp_enqueue_script('cookieadmin_js', COOKIEADMIN_PLUGIN_URL . 'assets/js/cookie.js', [], COOKIEADMIN_VERSION); |
| 54 |
// wp_enqueue_script('cookieadmin_js', COOKIEADMIN_PLUGIN_URL . 'assets/js/consent.js', [], COOKIEADMIN_VERSION); |
| 55 |
|
| 56 |
$policy['set'] = $view; |
| 57 |
$policy['admin_url'] = admin_url('admin-ajax.php'); |
| 58 |
$policy['cookieadmin_nonce'] = wp_create_nonce('cookieadmin_admin_js_nonce'); |
| 59 |
//cookieadmin_r_print($policy);die(); |
| 60 |
|
| 61 |
$policy['lang']['show_more'] = __('Show more', 'cookieadmin'); |
| 62 |
$policy['lang']['show_less'] = __('Show less', 'cookieadmin'); |
| 63 |
$policy['lang']['days'] = __('Day(s)', 'cookieadmin'); |
| 64 |
$policy['lang']['session'] = __('Session', 'cookieadmin'); |
| 65 |
$policy['lang']['scan_completed'] = __('Scan completed', 'cookieadmin'); |
| 66 |
$policy['lang']['processing'] = __('Processing...', 'cookieadmin'); |
| 67 |
$policy['lang']['active'] = __('Active', 'cookieadmin'); |
| 68 |
$policy['lang']['install_failed'] = __('Installation failed. Please try again.', 'cookieadmin'); |
| 69 |
$policy['lang']['error_occurred'] = __('An error occurred. Please try again.', 'cookieadmin'); |
| 70 |
|
| 71 |
wp_localize_script('cookieadmin_js', 'cookieadmin_policy', $policy); |
| 72 |
} |
| 73 |
|
| 74 |
wp_enqueue_script('cookieadmin_js_footer', COOKIEADMIN_PLUGIN_URL . 'assets/js/footer.js', [], COOKIEADMIN_VERSION); |
| 75 |
wp_localize_script('cookieadmin_js_footer', 'cookieadmin_data', array('is_pro' => cookieadmin_is_pro())); |
| 76 |
|
| 77 |
// We only need to upload icon on consent form page |
| 78 |
if(!empty($_GET['page']) && $_GET['page'] == 'cookieadmin-consent'){ |
| 79 |
//to upload icons |
| 80 |
wp_enqueue_media(); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
//Add Main Menu |
| 85 |
static function cookieadmin_plugin_menu(){ |
| 86 |
|
| 87 |
if(!empty($_REQUEST['cookieadmin_save_settings'])){ |
| 88 |
|
| 89 |
if(!empty($_REQUEST['cookieadmin_consent_type'])){ |
| 90 |
\CookieAdmin\Admin\Consent::save_consent_form(); |
| 91 |
}else{ |
| 92 |
\CookieAdmin\Admin\Settings::save_settings(); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
$capability = 'activate_plugins'; |
| 97 |
$logo = defined('SITEPAD') ? 'cookieadmin_icon_20-black.svg' : 'cookieadmin_icon_20.svg'; |
| 98 |
|
| 99 |
add_menu_page(__('CookieAdmin', 'cookieadmin'), __('CookieAdmin', 'cookieadmin'), $capability, 'cookieadmin', '\CookieAdmin\Admin\Dashboard::dashboard', COOKIEADMIN_PLUGIN_URL .'assets/images/'.$logo); |
| 100 |
|
| 101 |
add_submenu_page('cookieadmin', __('Dashboard', 'cookieadmin'), __('Dashboard', 'cookieadmin'), $capability, 'cookieadmin', '\CookieAdmin\Admin\Dashboard::dashboard'); |
| 102 |
|
| 103 |
add_submenu_page('cookieadmin', __('Consent Form', 'cookieadmin'), __('Consent Form', 'cookieadmin'), $capability, 'cookieadmin-consent', '\CookieAdmin\Admin\Consent::consent_form'); |
| 104 |
|
| 105 |
add_submenu_page('cookieadmin', __('Settings', 'cookieadmin'), __('Settings', 'cookieadmin'), $capability, 'cookieadmin-settings', '\CookieAdmin\Admin\Settings::settings'); |
| 106 |
|
| 107 |
add_submenu_page('cookieadmin', __('Scan Cookies', 'cookieadmin'), __('Scan Cookies', 'cookieadmin'), $capability, 'cookieadmin-scan-cookies', '\CookieAdmin\Admin\Scan::show_cookies'); |
| 108 |
|
| 109 |
if(defined('COOKIEADMIN_PREMIUM')){ |
| 110 |
add_submenu_page('cookieadmin', __('Consent Logs', 'cookieadmin'), __('Consent Logs', 'cookieadmin'), $capability, 'cookieadmin-consent-logs', '\CookieAdminPro\Admin::show_consent_logs'); |
| 111 |
|
| 112 |
// GEO Targeting |
| 113 |
add_submenu_page('cookieadmin', __('Geo Targeting', 'cookieadmin'), __('Geo Targeting', 'cookieadmin'), $capability, 'cookieadmin-geo-targeting', '\CookieAdminPro\Admin\Geo::geo_admin_page'); |
| 114 |
|
| 115 |
// Do Not Sell menu |
| 116 |
add_submenu_page('cookieadmin', __('Do Not Sell Requests', 'cookieadmin'), __('Do Not Sell', 'cookieadmin'), $capability, 'cookieadmin-do-not-sell', '\CookieAdminPro\Admin\DoNotSell::do_not_sell_requests'); |
| 117 |
|
| 118 |
if(!defined('SITEPAD')){ |
| 119 |
add_submenu_page('cookieadmin', __('License', 'cookieadmin'), __('License', 'cookieadmin'), $capability, 'cookieadmin-license', '\CookieAdminPro\License::cookieadmin_show_license'); |
| 120 |
} |
| 121 |
}else if(!defined('SITEPAD')){ |
| 122 |
// Go Pro link |
| 123 |
add_submenu_page('cookieadmin', __('CookieAdmin Go Pro', 'cookieadmin'), __('Go Pro', 'cookieadmin'), $capability, COOKIEADMIN_PRO_URL); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
// cookieadmin header |
| 128 |
static function header_theme($title = 'Dashboard'){ |
| 129 |
|
| 130 |
global $cookieadmin_lang, $cookieadmin_error, $cookieadmin_msg; |
| 131 |
|
| 132 |
self::conflict_notice(); |
| 133 |
|
| 134 |
echo ' |
| 135 |
<div class="cookieadmin-metabox-holder"> |
| 136 |
<div class="cookieadmin-header"> |
| 137 |
<div class="cookieadmin-header-left"> |
| 138 |
<div class="cookieadmin-icon"> |
| 139 |
<img class="cookieadmin-logo" src="'.esc_attr(COOKIEADMIN_PLUGIN_URL).'assets/images/cookieadmin-logo.png" alt="CookieAdmin Logo"> |
| 140 |
</div> |
| 141 |
<span class="cookieadmin-header-version">v'.esc_html(COOKIEADMIN_VERSION).'</span> |
| 142 |
</div> |
| 143 |
<div class="cookieadmin-header-right"> |
| 144 |
<a href="https://cookieadmin.net/docs" class="cookieadmin-header-link" target="_blank"><span class="dashicons dashicons-book-alt"></span> ' . esc_html__('Documentation', 'cookieadmin') . '</a> |
| 145 |
<span class="cookieadmin-header-separator"></span> |
| 146 |
<a href="https://softaculous.deskuss.com/open.php?topicId=26" class="cookieadmin-header-link" target="_blank"><span class="dashicons dashicons-sos"></span> ' . esc_html__('Support', 'cookieadmin') . '</a> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
<h1 class="cookieadmin-page-title">'.esc_html($title).'</h1>'; |
| 150 |
|
| 151 |
if(!empty($cookieadmin_error)){ |
| 152 |
echo '<div class="cookieadmin-notice"><div id="cookieadmin_message" class="error"><p>'.esc_html($cookieadmin_error).'</p></div></div>'; |
| 153 |
} |
| 154 |
|
| 155 |
if(!empty($cookieadmin_msg)){ |
| 156 |
echo '<div class="cookieadmin-notice"><div id="cookieadmin_message" class="updated"><p>'.esc_html($cookieadmin_msg).'</p></div></div>'; |
| 157 |
} |
| 158 |
|
| 159 |
echo '<div class="cookieadmin-postbox-container">'; |
| 160 |
} |
| 161 |
|
| 162 |
// cookieadmin footer |
| 163 |
static function footer_theme($no_twitter = 0){ |
| 164 |
global $cookieadmin_lang, $cookieadmin_error, $cookieadmin_msg; |
| 165 |
|
| 166 |
echo '</div>'; |
| 167 |
|
| 168 |
if(!defined('SITEPAD')){ |
| 169 |
echo '<div class="cookieadmin-footer"> |
| 170 |
<a href="'.esc_url(COOKIEADMIN_WWW_URL).'" target="_blank">CookieAdmin</a> v'.esc_html(COOKIEADMIN_VERSION).' · ' . esc_html__('Report bugs', 'cookieadmin') . ' <a href="https://softaculous.deskuss.com/open.php?topicId=26" target="_blank">'.esc_html__('here', 'cookieadmin').'</a>'; |
| 171 |
|
| 172 |
if(defined('COOKIEADMIN_PREMIUM')){ |
| 173 |
echo ' · <a href="mailto:support@cookieadmin.net">'.esc_html__('Email support', 'cookieadmin').'</a>'; |
| 174 |
} |
| 175 |
|
| 176 |
echo '</div>'; |
| 177 |
} |
| 178 |
|
| 179 |
echo '</div>'; |
| 180 |
} |
| 181 |
|
| 182 |
static function cookieadmin_table_exists($table_name) { |
| 183 |
global $wpdb; |
| 184 |
|
| 185 |
$query = $wpdb->prepare("SHOW TABLES LIKE %s", $table_name); |
| 186 |
|
| 187 |
return $wpdb->get_var($query) === $table_name; |
| 188 |
} |
| 189 |
|
| 190 |
static function scan_notice(){ |
| 191 |
|
| 192 |
$cookieadmin_auto_scan = get_option('cookieadmin_scan'); |
| 193 |
$current_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; |
| 194 |
|
| 195 |
if(empty($cookieadmin_auto_scan['status']) || (strpos($current_page, 'cookieadmin') !== 0)){ |
| 196 |
return false; |
| 197 |
} |
| 198 |
|
| 199 |
$msg = ''; |
| 200 |
|
| 201 |
if($cookieadmin_auto_scan['status'] === 2){ |
| 202 |
|
| 203 |
$count = !empty($cookieadmin_auto_scan['count']) ? $cookieadmin_auto_scan['count'] : 0; |
| 204 |
/* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */ |
| 205 |
$msg = sprintf(__('<br><strong>Cookie Scan is running:</strong> %1$d Cookies found. Please wait for cookies to appear on <a href="%2$s">Scan Cookies Page</a>', 'cookieadmin'), $count, esc_url(admin_url('admin.php?page=cookieadmin-scan-cookies'))); |
| 206 |
} |
| 207 |
|
| 208 |
if($cookieadmin_auto_scan['status'] === 3 && isset($cookieadmin_auto_scan['success'])){ |
| 209 |
|
| 210 |
if($cookieadmin_auto_scan['success'] === true){ |
| 211 |
/* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */ |
| 212 |
$msg = sprintf(__('<br><strong>Cookie Scan completed successfully:</strong> Please visit <a href="%1$s">Scan Cookies</a> to review scan results.', 'cookieadmin'), esc_url(admin_url('admin.php?page=cookieadmin-scan-cookies'))); |
| 213 |
} |
| 214 |
|
| 215 |
if($cookieadmin_auto_scan['success'] === false){ |
| 216 |
/* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */ |
| 217 |
$msg = sprintf(__('<br><strong>Cookie Scan failed:</strong> Please <a href="%1$s">Scan Cookies</a> again for compliance. %2$s', 'cookieadmin'), esc_url(admin_url('admin.php?page=cookieadmin-scan-cookies')), esc_html(!empty($cookieadmin_auto_scan['message']) ? $cookieadmin_auto_scan['message'] : '')); |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
if(empty($msg)){ |
| 222 |
return; |
| 223 |
} |
| 224 |
|
| 225 |
// cookieadmin_logo_svg fn is Internal static SVG. if allowing user input or filters, escape it. |
| 226 |
echo ' |
| 227 |
<div class="notice notice-info is-dismissible" id="cookieadmin-auto-scan-notice"> |
| 228 |
<p>'.cookieadmin_logo_svg().wp_kses_post($msg). '</p> |
| 229 |
</div>'; |
| 230 |
|
| 231 |
wp_register_script('cookieadmin-scan-notice', '', ['jquery'], '', true); |
| 232 |
wp_enqueue_script('cookieadmin-scan-notice'); |
| 233 |
wp_add_inline_script('cookieadmin-scan-notice', 'jQuery("#cookieadmin-auto-scan-notice").on("click", |
| 234 |
function(e){ |
| 235 |
|
| 236 |
let target = jQuery(e.target); |
| 237 |
if(!target.hasClass("notice-dismiss")){ |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
var data; |
| 242 |
|
| 243 |
// Hide it |
| 244 |
jQuery("#cookieadmin-auto-scan-notice").remove(); |
| 245 |
|
| 246 |
// Save this preference |
| 247 |
jQuery.post("'.admin_url('admin-ajax.php?action=cookieadmin_ajax_handler&cookieadmin_act=close-notice¬ice=cookieadmin-scan-notice').'&cookieadmin_security='.wp_create_nonce('cookieadmin_admin_js_nonce').'", data, function(response) { |
| 248 |
}); |
| 249 |
|
| 250 |
});'); |
| 251 |
|
| 252 |
} |
| 253 |
static function consent_log_purge_notice(){ |
| 254 |
|
| 255 |
$cookieadmin_consent_purge = get_option('cookieadmin_consent_purge', ['status' => 0, 'count' => 0]); |
| 256 |
|
| 257 |
if(empty($cookieadmin_consent_purge['status'])){ |
| 258 |
return false; |
| 259 |
} |
| 260 |
|
| 261 |
$msg = ''; |
| 262 |
$count = empty($cookieadmin_consent_purge['count']) ? 0 : $cookieadmin_consent_purge['count']; |
| 263 |
|
| 264 |
if($cookieadmin_consent_purge['status'] === 2){ |
| 265 |
/* translators: %1$d: number of consent logs deleted */ |
| 266 |
$msg = sprintf(__('<br><strong>Consent logs are being deleted :</strong> %1$d logs deleted. Please wait for deletion process to complete.', 'cookieadmin'), $count); |
| 267 |
} |
| 268 |
|
| 269 |
if($cookieadmin_consent_purge['status'] === 3){ |
| 270 |
if(isset($cookieadmin_consent_purge['success'])){ |
| 271 |
if($cookieadmin_consent_purge['success'] === true){ |
| 272 |
/* translators: %1$d: number of consent logs deleted */ |
| 273 |
$msg = sprintf(__('<br><strong>Consent logs deleted successfully:</strong> %1$d logs deleted.', 'cookieadmin'), $count); |
| 274 |
} |
| 275 |
|
| 276 |
if($cookieadmin_consent_purge['success'] === false){ |
| 277 |
/* translators: %1$d: number of consent logs deleted, %2$s: error message*/ |
| 278 |
$msg = sprintf(__('<br><strong>Consent logs deletion failed:</strong> %1$d logs deleted. Error : %2$s', 'cookieadmin'), $count, esc_html($cookieadmin_consent_purge['message'])); |
| 279 |
} |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
if(empty($msg)){ |
| 284 |
return; |
| 285 |
} |
| 286 |
|
| 287 |
// cookieadmin_logo_svg fn is Internal static SVG. if allowing user input or filters, escape it. |
| 288 |
echo ' |
| 289 |
<div class="notice notice-info is-dismissible" id="cookieadmin-consent-purge-notice"> |
| 290 |
<p>'.cookieadmin_logo_svg().wp_kses_post($msg). '</p> |
| 291 |
</div>'; |
| 292 |
|
| 293 |
wp_register_script('cookieadmin-consent-purge-notice', '', ['jquery'], '', true); |
| 294 |
wp_enqueue_script('cookieadmin-consent-purge-notice'); |
| 295 |
wp_add_inline_script('cookieadmin-consent-purge-notice', 'jQuery("#cookieadmin-consent-purge-notice").on("click", |
| 296 |
function(e){ |
| 297 |
|
| 298 |
let target = jQuery(e.target); |
| 299 |
if(!target.hasClass("notice-dismiss")){ |
| 300 |
return; |
| 301 |
} |
| 302 |
|
| 303 |
var data; |
| 304 |
|
| 305 |
// Hide it |
| 306 |
jQuery("#cookieadmin-consent-purge-notice").remove(); |
| 307 |
|
| 308 |
// Save this preference |
| 309 |
jQuery.post("'.admin_url('admin-ajax.php?action=cookieadmin_ajax_handler&cookieadmin_act=close-notice¬ice=cookieadmin-consent-purge-notice').'&cookieadmin_security='.wp_create_nonce('cookieadmin_admin_js_nonce').'", data, function(response) { |
| 310 |
}); |
| 311 |
|
| 312 |
});'); |
| 313 |
|
| 314 |
} |
| 315 |
|
| 316 |
static function conflict_notice(){ |
| 317 |
|
| 318 |
$conflicting = [ |
| 319 |
'complianz-gdpr/complianz-gdpr.php' => 'Complianz', |
| 320 |
'cookie-law-info/cookie-law-info.php' => 'CookieYes', |
| 321 |
'cookiebot/cookiebot.php' => 'Cookiebot', |
| 322 |
'cookie-notice/cookie-notice.php' => 'Cookie Notice', |
| 323 |
'gdpr-cookie-compliance/gdpr-cookie-compliance.php' => 'GDPR Cookie Compliance', |
| 324 |
'borlabs-cookie/borlabs-cookie.php' => 'Borlabs Cookie', |
| 325 |
'wp-gdpr-compliance/wp-gdpr-compliance.php' => 'Cookie Information', |
| 326 |
]; |
| 327 |
|
| 328 |
if(!function_exists('is_plugin_active')){ |
| 329 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 330 |
} |
| 331 |
|
| 332 |
$active = []; |
| 333 |
foreach($conflicting as $slug => $name){ |
| 334 |
if(is_plugin_active($slug)){ |
| 335 |
$active[] = $name; |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
if(empty($active)){ |
| 340 |
return; |
| 341 |
} |
| 342 |
|
| 343 |
$names = implode(', ', $active); |
| 344 |
|
| 345 |
echo '<div class="cookieadmin-conflict-notice"> |
| 346 |
<span class="dashicons dashicons-warning"></span> |
| 347 |
<span>'.sprintf(__('Conflicting plugin(s) detected: <b>%s</b>. Please deactivate them to avoid issues with CookieAdmin.', 'cookieadmin'), esc_html($names)).'</span> |
| 348 |
</div>'; |
| 349 |
} |
| 350 |
|
| 351 |
static function close_notices(){ |
| 352 |
|
| 353 |
if(empty($_REQUEST['notice'])){ |
| 354 |
return; |
| 355 |
} |
| 356 |
|
| 357 |
$notice = sanitize_text_field(wp_unslash($_REQUEST['notice'])); |
| 358 |
$notice = str_replace('-notice', '', $notice); |
| 359 |
$notice = str_replace('-', '_', $notice); |
| 360 |
|
| 361 |
update_option($notice, array()); |
| 362 |
} |
| 363 |
|
| 364 |
static function plugin_update_notice(){ |
| 365 |
if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){ |
| 366 |
return; |
| 367 |
} |
| 368 |
|
| 369 |
$to_update_plugins = apply_filters('softaculous_plugin_update_notice', []); |
| 370 |
|
| 371 |
if(empty($to_update_plugins)){ |
| 372 |
return; |
| 373 |
} |
| 374 |
|
| 375 |
/* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */ |
| 376 |
$msg = sprintf(__('New versions of %1$s %2$s available. Updating ensures better performance, security, and access to the latest features.', 'cookieadmin'), '<b>'.esc_html(implode(', ', $to_update_plugins)).'</b>', (count($to_update_plugins) > 1 ? 'are' : 'is')) . ' <a class="button button-primary" href='.esc_url(admin_url('plugins.php?plugin_status=upgrade')).'>Update Now</a>'; |
| 377 |
|
| 378 |
define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice |
| 379 |
echo '<div class="notice notice-info is-dismissible" id="cookieadmin-plugin-update-notice"> |
| 380 |
<p>'.wp_kses_post($msg). '</p> |
| 381 |
</div>'; |
| 382 |
|
| 383 |
wp_register_script('cookieadmin-update-notice', '', ['jquery'], '', true); |
| 384 |
wp_enqueue_script('cookieadmin-update-notice'); |
| 385 |
wp_add_inline_script('cookieadmin-update-notice', 'jQuery("#cookieadmin-plugin-update-notice").on("click", function(e){ |
| 386 |
let target = jQuery(e.target); |
| 387 |
|
| 388 |
if(!target.hasClass("notice-dismiss")){ |
| 389 |
return; |
| 390 |
} |
| 391 |
|
| 392 |
var data; |
| 393 |
|
| 394 |
// Hide it |
| 395 |
jQuery("#cookieadmin-plugin-update-notice").hide(); |
| 396 |
|
| 397 |
// Save this preference |
| 398 |
jQuery.post("'.admin_url('admin-ajax.php?action=cookieadmin_ajax_handler&cookieadmin_act=close-update-notice').'&cookieadmin_security='.wp_create_nonce('cookieadmin_admin_js_nonce').'", data, function(response) { |
| 399 |
//alert(response); |
| 400 |
}); |
| 401 |
});'); |
| 402 |
} |
| 403 |
|
| 404 |
static function plugin_update_notice_filter($plugins = []){ |
| 405 |
$plugins['cookieadmin/cookieadmin.php'] = 'CookieAdmin'; |
| 406 |
return $plugins; |
| 407 |
} |
| 408 |
|
| 409 |
static function close_plugin_update_notice(){ |
| 410 |
$plugin_update_notice = get_option('softaculous_plugin_update_notice', []); |
| 411 |
$available_update_list = get_site_transient('update_plugins'); |
| 412 |
$to_update_plugins = apply_filters('softaculous_plugin_update_notice', []); |
| 413 |
|
| 414 |
if(empty($available_update_list) || empty($available_update_list->response)){ |
| 415 |
return; |
| 416 |
} |
| 417 |
|
| 418 |
foreach($to_update_plugins as $plugin_path => $plugin_name){ |
| 419 |
if(isset($available_update_list->response[$plugin_path])){ |
| 420 |
$plugin_update_notice[$plugin_path] = $available_update_list->response[$plugin_path]->new_version; |
| 421 |
} |
| 422 |
} |
| 423 |
|
| 424 |
update_option('softaculous_plugin_update_notice', $plugin_update_notice); |
| 425 |
} |
| 426 |
|
| 427 |
static function is_feature_available($return = 0){ |
| 428 |
|
| 429 |
if(cookieadmin_is_pro()){ |
| 430 |
return ''; |
| 431 |
} |
| 432 |
|
| 433 |
$msg = ' <a href="'.esc_url(COOKIEADMIN_PRO_URL).'" target="_blank" class="cookieadmin-pro-badge">'.esc_html__('Pro', 'cookieadmin').'</a>'; |
| 434 |
|
| 435 |
if(!empty($return)){ |
| 436 |
return $msg; |
| 437 |
}else{ |
| 438 |
echo wp_kses_post($msg); |
| 439 |
} |
| 440 |
|
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
|