first commit

This commit is contained in:
Roman Pyrih
2023-07-24 08:30:51 +02:00
commit c2e100a763
7128 changed files with 1622619 additions and 0 deletions

View File

@@ -0,0 +1,969 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Cookie_Notice_Bot_Detect class.
*
* Based on CrawlerDetect php class adjusted to PHP 5.2
* https://github.com/JayBizzle/Crawler-Detect/blob/master/src/CrawlerDetect.php
*
* @since 2.0.0
* @class Cookie_Notice_Bot_Detect
*/
class Cookie_Notice_Bot_Detect {
/**
* The user agent.
*
* @var null
*/
protected $user_agent = null;
/**
* Headers that contain a user agent.
*
* @var array
*/
protected $http_headers = array();
/**
* Store regex matches.
*
* @var array
*/
protected $matches = array();
/**
* Crawlers object.
*
* @var object
*/
protected $crawlers = array();
/**
* Exclusions object.
*
* @var object
*/
protected $exclusions = array();
/**
* Headers object.
*
* @var object
*/
protected $ua_http_headers;
/**
* Class constructor.
*/
public function __construct() {
$this->crawlers = $this->get_crawlers_list();
$this->exclusions = $this->get_exclusions_list();
add_action( 'after_setup_theme', array( $this, 'init' ) );
}
/**
* Initialize class.
*/
public function init() {
// break on admin side
if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
return;
$this->ua_http_headers = $this->get_headers_list();
$this->set_http_headers();
$this->set_user_agent();
}
/**
* Set HTTP headers.
*
* @param array $http_headers
*/
public function set_http_headers( $http_headers = null ) {
// use global _SERVER if $http_headers aren't defined
if ( ! is_array( $http_headers ) || ! count( $http_headers ) ) {
$http_headers = $_SERVER;
}
// clear existing headers
$this->http_headers = array();
// only save HTTP headers - in PHP land, that means only _SERVER vars that start with HTTP_.
foreach ( $http_headers as $key => $value ) {
if ( substr( $key, 0, 5 ) === 'HTTP_' ) {
$this->http_headers[$key] = $value;
}
}
}
/**
* Return user agent headers.
*
* @return array
*/
public function get_ua_http_headers() {
return $this->ua_http_headers;
}
/**
* Return the user agent.
*
* @return string
*/
public function get_user_agent() {
return $this->user_agent;
}
/**
* Set the user agent.
*
* @param string $user_agent
*/
public function set_user_agent( $user_agent = null ) {
if ( false === empty( $user_agent ) ) {
return $this->user_agent = $user_agent;
} else {
$this->user_agent = null;
foreach ( $this->get_ua_http_headers() as $alt_header ) {
if ( false === empty( $this->http_headers[$alt_header] ) ) { // @todo: should use get_http_header(), but it would be slow.
$this->user_agent .= $this->http_headers[$alt_header] . ' ';
}
}
return $this->user_agent = ( ! empty( $this->user_agent ) ? trim( $this->user_agent ) : null);
}
}
/**
* Build the user agent regex.
*
* @return string
*/
public function get_regex() {
return '(' . implode( '|', $this->crawlers ) . ')';
}
/**
* Build the replacement regex.
*
* @return string
*/
public function get_exclusions() {
return '(' . implode( '|', $this->exclusions ) . ')';
}
/**
* Check user agent string against the regex.
*
* @param string $user_agent
*
* @return bool
*/
public function is_crawler( $user_agent = null ) {
$agent = is_null( $user_agent ) ? $this->user_agent : $user_agent;
$agent = preg_replace( '/' . $this->get_exclusions() . '/i', '', $agent );
if ( strlen( trim( $agent ) ) == 0 ) {
return false;
} else {
$result = preg_match( '/' . $this->get_regex() . '/i', trim( $agent ), $matches );
}
if ( $matches ) {
$this->matches = $matches;
}
return (bool) $result;
}
/**
* Return the matches.
*
* @return string
*/
public function get_matches() {
return isset( $this->matches[0] ) ? $this->matches[0] : null;
}
/**
* Return the regular expressions to match against the user agent.
*
* @return array
*/
protected function get_crawlers_list() {
$data = array(
'.*Java.*outbrain',
'008\/',
'192.comAgent',
'2ip\.ru',
'404checker',
'^bluefish ',
'^FDM ',
'^Goose\/',
'^Java\/',
'^Mget',
'^NG\/[0-9\.]',
'^NING\/',
'^PHP\/[0-9]',
'^RMA\/',
'^Ruby|Ruby\/[0-9]',
'^scrutiny\/',
'^VSE\/[0-9]',
'^WordPress\.com',
'^XRL\/[0-9]',
'a3logics\.in',
'A6-Indexer',
'a\.pr-cy\.ru',
'Aboundex',
'aboutthedomain',
'Accoona-AI-Agent',
'acoon',
'acrylicapps\.com\/pulp',
'adbeat',
'AddThis',
'ADmantX',
'adressendeutschland',
'Advanced Email Extractor v',
'agentslug',
'AHC',
'aihit',
'aiohttp\/',
'Airmail',
'akula\/',
'alertra',
'alexa site audit',
'alyze\.info',
'amagit',
'AndroidDownloadManager',
'Anemone',
'Ant\.com',
'Anturis Agent',
'AnyEvent-HTTP\/',
'Apache-HttpClient\/',
'AportWorm\/[0-9]',
'AppEngine-Google',
'Arachmo',
'arachnode',
'Arachnophilia',
'archive-com',
'aria2',
'asafaweb.com',
'AskQuickly',
'Astute',
'autocite',
'Autonomy',
'B-l-i-t-z-B-O-T',
'Backlink-Ceck\.de',
'Bad-Neighborhood',
'baidu\.com',
'baypup\/[0-9]',
'baypup\/colbert',
'BazQux',
'BCKLINKS',
'BDFetch',
'BegunAdvertising\/',
'bibnum\.bnf',
'BigBozz',
'biglotron',
'BingLocalSearch',
'BingPreview',
'binlar',
'biz_Directory',
'Blackboard Safeassign',
'Bloglovin',
'BlogPulseLive',
'BlogSearch',
'Blogtrottr',
'boitho\.com-dc',
'BPImageWalker',
'Braintree-Webhooks',
'Branch Metrics API',
'Branch-Passthrough',
'Browsershots',
'BUbiNG',
'Butterfly\/',
'BuzzSumo',
'CakePHP',
'CapsuleChecker',
'CaretNail',
'cb crawl',
'CC Metadata Scaper',
'Cerberian Drtrs',
'CERT\.at-Statistics-Survey',
'cg-eye',
'changedetection',
'Charlotte',
'CheckHost',
'chkme\.com',
'CirrusExplorer\/',
'CISPA Vulnerability Notification',
'CJNetworkQuality',
'clips\.ua\.ac\.be',
'Cloud mapping experiment',
'CloudFlare-AlwaysOnline',
'Cloudinary\/[0-9]',
'cmcm\.com',
'coccoc',
'CommaFeed',
'Commons-HttpClient',
'Comodo SSL Checker',
'contactbigdatafr',
'convera',
'copyright sheriff',
'cosmos\/[0-9]',
'Covario-IDS',
'CrawlForMe\/[0-9]',
'cron-job\.org',
'Crowsnest',
'curb',
'Curious George',
'curl',
'cuwhois\/[0-9]',
'CyberPatrol',
'cybo\.com',
'DareBoost',
'DataparkSearch',
'dataprovider',
'Daum(oa)?[ \/][0-9]',
'DeuSu',
'developers\.google\.com\/\+\/web\/snippet\/',
'Digg',
'Dispatch\/',
'dlvr',
'DNS-Tools Header-Analyzer',
'DNSPod-reporting',
'docoloc',
'DomainAppender',
'dotSemantic',
'downforeveryoneorjustme',
'downnotifier\.com',
'DowntimeDetector',
'Dragonfly File Reader',
'drupact',
'Drupal (\+http:\/\/drupal\.org\/)',
'dubaiindex',
'EARTHCOM',
'Easy-Thumb',
'ec2linkfinder',
'eCairn-Grabber',
'ECCP',
'ElectricMonk',
'elefent',
'EMail Exractor',
'EmailWolf',
'Embed PHP Library',
'Embedly',
'europarchive\.org',
'evc-batch\/[0-9]',
'EventMachine HttpClient',
'Evidon',
'Evrinid',
'ExactSearch',
'ExaleadCloudview',
'Excel\/',
'Exploratodo',
'ezooms',
'facebookexternalhit',
'facebookplatform',
'fairshare',
'Faraday v',
'Faveeo',
'Favicon downloader',
'FavOrg',
'Feed Wrangler',
'Feedbin',
'FeedBooster',
'FeedBucket',
'FeedBurner',
'FeedChecker',
'Feedly',
'Feedspot',
'feeltiptop',
'Fetch API',
'Fetch\/[0-9]',
'Fever\/[0-9]',
'findlink',
'findthatfile',
'Flamingo_SearchEngine',
'FlipboardBrowserProxy',
'FlipboardProxy',
'FlipboardRSS',
'fluffy',
'flynxapp',
'forensiq',
'FoundSeoTool\/[0-9]',
'free thumbnails',
'FreeWebMonitoring SiteChecker',
'Funnelback',
'g00g1e\.net',
'GAChecker',
'geek-tools',
'Genderanalyzer',
'Genieo',
'GentleSource',
'GetLinkInfo',
'getprismatic\.com',
'GetURLInfo\/[0-9]',
'GigablastOpenSource',
'Go [\d\.]* package http',
'Go-http-client',
'GomezAgent',
'gooblog',
'Goodzer\/[0-9]',
'Google favicon',
'Google Keyword Suggestion',
'Google Keyword Tool',
'Google Page Speed Insights',
'Google PP Default',
'Google Search Console',
'Google Web Preview',
'Google-Adwords',
'Google-Apps-Script',
'Google-Calendar-Importer',
'Google-HTTP-Java-Client',
'Google-Publisher-Plugin',
'Google-SearchByImage',
'Google-Site-Verification',
'Google-Structured-Data-Testing-Tool',
'google_partner_monitoring',
'GoogleDocs',
'GoogleHC\/',
'GoogleProducer',
'GoScraper',
'GoSpotCheck',
'GoSquared-Status-Checker',
'gosquared-thumbnailer',
'GotSiteMonitor',
'Grammarly',
'grouphigh',
'grub-client',
'GTmetrix',
'Hatena',
'hawkReader',
'HEADMasterSEO',
'HeartRails_Capture',
'heritrix',
'hledejLevne\.cz\/[0-9]',
'Holmes',
'HootSuite Image proxy',
'Hootsuite-WebFeed\/[0-9]',
'HostTracker',
'ht:\/\/check',
'htdig',
'HTMLParser\/',
'HTTP-Header-Abfrage',
'http-kit',
'HTTP-Tiny',
'HTTP_Compression_Test',
'http_request2',
'http_requester',
'HttpComponents',
'httphr',
'HTTPMon',
'httpscheck',
'httpssites_power',
'httpunit',
'HttpUrlConnection',
'httrack',
'hosterstats',
'huaweisymantec',
'HubPages.*crawlingpolicy',
'HubSpot Connect',
'HubSpot Marketing Grader',
'HyperZbozi.cz Feeder',
'ichiro',
'IdeelaborPlagiaat',
'IDG Twitter Links Resolver',
'IDwhois\/[0-9]',
'Iframely',
'igdeSpyder',
'IlTrovatore',
'ImageEngine\/',
'Imagga',
'InAGist',
'inbound\.li parser',
'InDesign%20CC',
'infegy',
'infohelfer',
'InfoWizards Reciprocal Link System PRO',
'inpwrd\.com',
'Integrity',
'integromedb',
'internet_archive',
'InternetSeer',
'internetVista monitor',
'IODC',
'IOI',
'ips-agent',
'iqdb\/',
'Irokez',
'isitup\.org',
'iskanie',
'iZSearch',
'janforman',
'Jigsaw',
'Jobboerse',
'jobo',
'Jobrapido',
'KeepRight OpenStreetMap Checker',
'KimonoLabs\/',
'knows\.is',
'kouio',
'KrOWLer',
'kulturarw3',
'KumKie',
'L\.webis',
'Larbin',
'LayeredExtractor',
'LibVLC',
'libwww',
'link checker',
'Link Valet',
'link_thumbnailer',
'linkCheck',
'linkdex',
'LinkExaminer',
'linkfluence',
'linkpeek',
'LinkTiger',
'LinkWalker',
'Lipperhey',
'livedoor ScreenShot',
'LoadImpactPageAnalyzer',
'LoadImpactRload',
'LongURL API',
'looksystems\.net',
'ltx71',
'lwp-trivial',
'lycos',
'LYT\.SR',
'mabontland',
'MagpieRSS',
'Mail.Ru',
'MailChimp\.com',
'Mandrill',
'marketinggrader',
'Mediapartners-Google',
'MegaIndex\.ru',
'Melvil Rawi\/',
'MergeFlow-PageReader',
'MetaInspector',
'Metaspinner',
'MetaURI',
'Microsearch',
'Microsoft Office ',
'Microsoft Windows Network Diagnostics',
'Mindjet',
'Miniflux',
'Mnogosearch',
'mogimogi',
'Mojolicious (Perl)',
'monitis',
'Monitority\/[0-9]',
'montastic',
'MonTools',
'Moreover',
'Morning Paper',
'mowser',
'Mrcgiguy',
'mShots',
'MVAClient',
'nagios',
'Najdi\.si\/',
'NETCRAFT',
'NetLyzer FastProbe',
'netresearch',
'NetShelter ContentScan',
'NetTrack',
'Netvibes',
'Neustar WPM',
'NeutrinoAPI',
'NewsBlur .*Finder',
'NewsGator',
'newsme',
'newspaper\/',
'NG-Search',
'nineconnections\.com',
'NLNZ_IAHarvester',
'Nmap Scripting Engine',
'node-superagent',
'node\.io',
'nominet\.org\.uk',
'Norton-Safeweb',
'Notifixious',
'notifyninja',
'nuhk',
'nutch',
'Nuzzel',
'nWormFeedFinder',
'Nymesis',
'Ocelli\/[0-9]',
'oegp',
'okhttp',
'Omea Reader',
'omgili',
'Online Domain Tools',
'OpenCalaisSemanticProxy',
'Openstat\/',
'OpenVAS',
'Optimizer',
'Orbiter',
'OrgProbe\/[0-9]',
'ow\.ly',
'ownCloud News',
'Page Analyzer',
'Page Valet',
'page2rss',
'page_verifier',
'PagePeeker',
'Pagespeed\/[0-9]',
'Panopta',
'panscient',
'parsijoo',
'PayPal IPN',
'Pcore-HTTP',
'Pearltrees',
'peerindex',
'Peew',
'PhantomJS\/',
'Photon\/',
'phpcrawl',
'phpservermon',
'Pi-Monster',
'Pingdom\.com',
'Pingoscope',
'PingSpot',
'Pinterest',
'Pizilla',
'Ploetz \+ Zeller',
'Plukkie',
'PocketParser',
'Pompos',
'Porkbun',
'Port Monitor',
'postano',
'PostPost',
'postrank',
'PowerPoint\/',
'Priceonomics Analysis Engine',
'Prlog',
'probethenet',
'Project 25499',
'Promotion_Tools_www.searchenginepromotionhelp.com',
'prospectb2b',
'Protopage',
'proximic',
'PTST ',
'PTST\/[0-9]+',
'Pulsepoint XT3 web scraper',
'Python-httplib2',
'python-requests',
'Python-urllib',
'Qirina Hurdler',
'Qseero',
'Qualidator.com SiteAnalyzer',
'Quora Link Preview',
'Qwantify',
'Radian6',
'RankSonicSiteAuditor',
'Readability',
'RealPlayer%20Downloader',
'RebelMouse',
'redback\/',
'Redirect Checker Tool',
'ReederForMac',
'ResponseCodeTest\/[0-9]',
'RestSharp',
'RetrevoPageAnalyzer',
'Riddler',
'Rival IQ',
'Robosourcer',
'Robozilla\/[0-9]',
'ROI Hunter',
'SalesIntelligent',
'SauceNAO',
'SBIder',
'Scoop',
'scooter',
'ScoutJet',
'ScoutURLMonitor',
'Scrapy',
'Scrubby',
'SearchSight',
'semanticdiscovery',
'semanticjuice',
'SEO Browser',
'Seo Servis',
'seo-nastroj.cz',
'Seobility',
'SEOCentro',
'SeoCheck',
'SeopultContentAnalyzer',
'SEOstats',
'Server Density Service Monitoring',
'servernfo\.com',
'Seznam screenshot-generator',
'Shelob',
'Shoppimon Analyzer',
'ShoppimonAgent\/[0-9]',
'ShopWiki',
'ShortLinkTranslate',
'shrinktheweb',
'SilverReader',
'SimplePie',
'SimplyFast',
'Site-Shot\/',
'Site24x7',
'SiteBar',
'SiteCondor',
'siteexplorer\.info',
'SiteGuardian',
'Siteimprove\.com',
'Sitemap(s)? Generator',
'Siteshooter B0t',
'SiteTruth',
'sitexy\.com',
'SkypeUriPreview',
'slider\.com',
'slurp',
'SMRF URL Expander',
'Snappy',
'SniffRSS',
'sniptracker',
'Snoopy',
'sogou web',
'SortSite',
'spaziodati',
'Specificfeeds',
'speedy',
'SPEng',
'Spinn3r',
'spray-can',
'Sprinklr ',
'spyonweb',
'Sqworm',
'SSL Labs',
'StackRambler',
'Statastico\/',
'StatusCake',
'Stratagems Kumo',
'Stroke.cz',
'StudioFACA',
'suchen',
'summify',
'Super Monitoring',
'Surphace Scout',
'SwiteScraper',
'Symfony2 BrowserKit',
'Sysomos',
'T0PHackTeam',
'Tarantula\/',
'teoma',
'terrainformatica\.com',
'The Expert HTML Source Viewer',
'theinternetrules',
'theoldreader\.com',
'Thumbshots',
'ThumbSniper',
'TinEye',
'Tiny Tiny RSS',
'topster',
'touche.com',
'Traackr.com',
'truwoGPS',
'tweetedtimes\.com',
'Tweetminster',
'Twikle',
'Twingly',
'Typhoeus',
'ubermetrics-technologies',
'uclassify',
'UdmSearch',
'UnwindFetchor',
'updated',
'Upflow',
'URLChecker',
'URLitor.com',
'urlresolver',
'Urlstat',
'UrlTrends Ranking Updater',
'Vagabondo',
'via ggpht\.com GoogleImageProxy',
'visionutils',
'vkShare',
'voltron',
'Vortex\/[0-9]',
'voyager\/',
'VSAgent\/[0-9]',
'VSB-TUO\/[0-9]',
'VYU2',
'w3af\.org',
'W3C-checklink',
'W3C-mobileOK',
'W3C_I18n-Checker',
'W3C_Unicorn',
'wangling',
'Wappalyzer',
'WatchMouse',
'WbSrch\/',
'web-capture\.net',
'Web-Monitoring',
'Web-sniffer',
'Webauskunft',
'WebCapture',
'webcollage',
'WebCookies',
'WebCorp',
'WebDoc',
'WebFetch',
'WebImages',
'WebIndex',
'webkit2png',
'webmastercoffee',
'webmon ',
'webscreenie',
'Webshot',
'Website Analyzer\/',
'websitepulse[+ ]checker',
'Websnapr\/',
'Websquash\.com',
'Webthumb\/[0-9]',
'WebThumbnail',
'WeCrawlForThePeace',
'WeLikeLinks',
'WEPA',
'WeSEE',
'wf84',
'wget',
'WhatsApp',
'WhatsMyIP',
'WhatWeb',
'Whibse',
'Whynder Magnet',
'Windows-RSS-Platform',
'WinHttpRequest',
'wkhtmlto',
'wmtips',
'Woko',
'WomlpeFactory',
'Word\/',
'WordPress\/',
'wotbox',
'WP Engine Install Performance API',
'WPScan',
'wscheck',
'WWW-Mechanize',
'www\.monitor\.us',
'XaxisSemanticsClassifier',
'Xenu Link Sleuth',
'XING-contenttabreceiver\/[0-9]',
'XmlSitemapGenerator',
'xpymep([0-9]?)\.exe',
'Y!J-(ASR|BSC)',
'Yaanb',
'yacy',
'Yahoo Ad monitoring',
'Yahoo Link Preview',
'YahooCacheSystem',
'YahooSeeker',
'YahooYSMcm',
'YandeG',
'yandex',
'yanga',
'yeti',
'Yo-yo',
'Yoleo Consumer',
'yoogliFetchAgent',
'YottaaMonitor',
'yourls\.org',
'Zao',
'Zemanta Aggregator',
'Zend\\\\Http\\\\Client',
'Zend_Http_Client',
'zgrab',
'ZnajdzFoto',
'ZyBorg',
'[a-z0-9\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider|uptime|validator|fetcher)',
);
return $data;
}
/**
* Return the list of strings to remove from the user agent before running the crawler regex.
*
* @return array
*/
public function get_exclusions_list() {
$data = array(
'Safari.[\d\.]*',
'Firefox.[\d\.]*',
'Chrome.[\d\.]*',
'Chromium.[\d\.]*',
'MSIE.[\d\.]',
'Opera\/[\d\.]*',
'Mozilla.[\d\.]*',
'AppleWebKit.[\d\.]*',
'Trident.[\d\.]*',
'Windows NT.[\d\.]*',
'Android [\d\.]*',
'Macintosh.',
'Ubuntu',
'Linux',
'[ ]Intel',
'Mac OS X [\d_]*',
'(like )?Gecko(.[\d\.]*)?',
'KHTML,',
'CriOS.[\d\.]*',
'CPU iPhone OS ([0-9_])* like Mac OS X',
'CPU OS ([0-9_])* like Mac OS X',
'iPod',
'compatible',
'x86_..',
'i686',
'x64',
'X11',
'rv:[\d\.]*',
'Version.[\d\.]*',
'WOW64',
'Win64',
'Dalvik.[\d\.]*',
' \.NET CLR [\d\.]*',
'Presto.[\d\.]*',
'Media Center PC',
'BlackBerry',
'Build',
'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
'Opera',
' \.NET[\d\.]*',
'\(|\)|;|,', // remove the following characters ( ) : ,
);
return $data;
}
/**
* Return all possible HTTP headers that represent the User-Agent string.
*
* @return array
*/
public function get_headers_list() {
$data = array(
// the default User-Agent string.
'HTTP_USER_AGENT',
// header can occur on devices using Opera Mini.
'HTTP_X_OPERAMINI_PHONE_UA',
// vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
'HTTP_X_DEVICE_USER_AGENT',
'HTTP_X_ORIGINAL_USER_AGENT',
'HTTP_X_SKYFIRE_PHONE',
'HTTP_X_BOLT_PHONE_UA',
'HTTP_DEVICE_STOCK_UA',
'HTTP_X_UCBROWSER_DEVICE_UA',
// sometimes, bots (especially Google) use a genuine user agent, but fill this header in with their email address
'HTTP_FROM',
);
return $data;
}
}

View File

@@ -0,0 +1,294 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Cookie_Notice_Frontend class.
*
* @class Cookie_Notice_Frontend
*/
class Cookie_Notice_Frontend {
private $widget_url = '';
private $is_bot = false;
private $hide_banner = false;
public function __construct() {
// actions
add_action( 'init', array( $this, 'init' ) );
$this->widget_url = '//cdn.hu-manity.co/hu-banner.min.js';
$this->app_url = 'https://app.hu-manity.co';
}
/**
* Init frontend.
*/
public function init() {
// purge cache
if ( isset( $_GET['hu_purge_cache'] ) )
$this->purge_cache();
// is it preview mode?
$this->preview_mode = isset( $_GET['cn_preview_mode'] );
// is it a bot?
$this->is_bot = Cookie_Notice()->bot_detect->is_crawler();
// is user logged in and hiding the banner is enabled
$this->hide_banner = is_user_logged_in() && Cookie_Notice()->options['general']['hide_banner'] === true;
global $pagenow;
// bail if in preview mode or it's a bot request
if ( ! $this->preview_mode && ! $this->is_bot && ! $this->hide_banner && ! ( is_admin() && $pagenow === 'widgets.php' && isset( $_GET['legacy-widget-preview'] ) ) ) {
// init cookie compliance
if ( Cookie_Notice()->get_status() === 'active' ) {
add_action( 'send_headers', array( $this, 'add_compliance_http_header' ) );
add_action( 'wp_head', array( $this, 'add_cookie_compliance' ), 0 );
// init cookie notice
} else {
// actions
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_notice_scripts' ) );
add_filter( 'script_loader_tag', array( $this, 'wp_enqueue_script_async' ), 10, 3 );
add_action( 'wp_head', array( $this, 'wp_print_header_scripts' ) );
add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
add_action( 'wp_footer', array( $this, 'add_cookie_notice' ), 1000 );
// filters
add_filter( 'body_class', array( $this, 'change_body_class' ) );
}
}
}
/**
* Add CORS header for API requests and purge cache.
*/
public function add_compliance_http_header() {
header( "Access-Control-Allow-Origin: $this->app_url" );
header( 'Access-Control-Allow-Methods: GET' );
}
/**
* Run Cookie Compliance.
*
* @return void
*/
public function add_cookie_compliance() {
// get site language
$locale = get_locale();
$locale_code = explode( '_', $locale );
// exceptions, norwegian
if ( in_array( $locale_code, array( 'nb', 'nn' ) ) )
$locale_code = 'no';
$options = apply_filters( 'cn_cookie_compliance_args', array(
'appID' => Cookie_Notice()->options['general']['app_id'],
'currentLanguage' => $locale_code[0],
'blocking' => (bool) ( ! is_user_logged_in() ? Cookie_Notice()->options['general']['app_blocking'] : false )
) );
// message output
$output = '
<!-- Hu Banner -->
<script type="text/javascript">
var huOptions = ' . json_encode( $options ) . ';
</script>
<script type="text/javascript" src="' . $this->widget_url . '"></script>';
echo apply_filters( 'cn_cookie_compliance_output', $output, $options );
}
/**
* Cookie notice output.
*
* @return mixed
*/
public function add_cookie_notice() {
// WPML >= 3.2
if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
Cookie_Notice()->options['general']['message_text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['message_text'], 'Cookie Notice', 'Message in the notice' );
Cookie_Notice()->options['general']['accept_text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['accept_text'], 'Cookie Notice', 'Button text' );
Cookie_Notice()->options['general']['refuse_text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['refuse_text'], 'Cookie Notice', 'Refuse button text' );
Cookie_Notice()->options['general']['revoke_message_text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['revoke_message_text'], 'Cookie Notice', 'Revoke message text' );
Cookie_Notice()->options['general']['revoke_text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['revoke_text'], 'Cookie Notice', 'Revoke button text' );
Cookie_Notice()->options['general']['see_more_opt']['text'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['see_more_opt']['text'], 'Cookie Notice', 'Privacy policy text' );
Cookie_Notice()->options['general']['see_more_opt']['link'] = apply_filters( 'wpml_translate_single_string', Cookie_Notice()->options['general']['see_more_opt']['link'], 'Cookie Notice', 'Custom link' );
// WPML and Polylang compatibility
} elseif ( function_exists( 'icl_t' ) ) {
Cookie_Notice()->options['general']['message_text'] = icl_t( 'Cookie Notice', 'Message in the notice', Cookie_Notice()->options['general']['message_text'] );
Cookie_Notice()->options['general']['accept_text'] = icl_t( 'Cookie Notice', 'Button text', Cookie_Notice()->options['general']['accept_text'] );
Cookie_Notice()->options['general']['refuse_text'] = icl_t( 'Cookie Notice', 'Refuse button text', Cookie_Notice()->options['general']['refuse_text'] );
Cookie_Notice()->options['general']['revoke_message_text'] = icl_t( 'Cookie Notice', 'Revoke message text', Cookie_Notice()->options['general']['revoke_message_text'] );
Cookie_Notice()->options['general']['revoke_text'] = icl_t( 'Cookie Notice', 'Revoke button text', Cookie_Notice()->options['general']['revoke_text'] );
Cookie_Notice()->options['general']['see_more_opt']['text'] = icl_t( 'Cookie Notice', 'Privacy policy text', Cookie_Notice()->options['general']['see_more_opt']['text'] );
Cookie_Notice()->options['general']['see_more_opt']['link'] = icl_t( 'Cookie Notice', 'Custom link', Cookie_Notice()->options['general']['see_more_opt']['link'] );
}
if ( function_exists( 'icl_object_id' ) )
Cookie_Notice()->options['general']['see_more_opt']['id'] = icl_object_id( Cookie_Notice()->options['general']['see_more_opt']['id'], 'page', true );
// get cookie container args
$options = apply_filters( 'cn_cookie_notice_args', array(
'position' => Cookie_Notice()->options['general']['position'],
'css_class' => Cookie_Notice()->options['general']['css_class'],
'button_class' => 'cn-button',
'colors' => Cookie_Notice()->options['general']['colors'],
'message_text' => Cookie_Notice()->options['general']['message_text'],
'accept_text' => Cookie_Notice()->options['general']['accept_text'],
'refuse_text' => Cookie_Notice()->options['general']['refuse_text'],
'revoke_message_text' => Cookie_Notice()->options['general']['revoke_message_text'],
'revoke_text' => Cookie_Notice()->options['general']['revoke_text'],
'refuse_opt' => Cookie_Notice()->options['general']['refuse_opt'],
'revoke_cookies' => Cookie_Notice()->options['general']['revoke_cookies'],
'see_more' => Cookie_Notice()->options['general']['see_more'],
'see_more_opt' => Cookie_Notice()->options['general']['see_more_opt'],
'link_target' => Cookie_Notice()->options['general']['link_target'],
'link_position' => Cookie_Notice()->options['general']['link_position'],
'aria_label' => 'Cookie Notice'
) );
// check legacy parameters
$options = Cookie_Notice()->check_legacy_params( $options, array( 'refuse_opt', 'see_more' ) );
if ( $options['see_more'] === true )
$options['message_text'] = do_shortcode( wp_kses_post( $options['message_text'] ) );
else
$options['message_text'] = wp_kses_post( $options['message_text'] );
$options['revoke_message_text'] = wp_kses_post( $options['revoke_message_text'] );
// escape css classes
$options['css_class'] = esc_attr( $options['css_class'] );
$options['button_class'] = esc_attr( $options['button_class'] );
// message output
$output = '
<!-- Cookie Notice plugin v' . Cookie_Notice()->defaults['version'] . ' by Hu-manity.co https://hu-manity.co/ -->
<div id="cookie-notice" role="dialog" class="cookie-notice-hidden cookie-revoke-hidden cn-position-' . esc_attr( $options['position'] ) . '" aria-label="' . esc_attr( $options['aria_label'] ) . '" style="background-color: rgba(' . implode( ',', Cookie_Notice()->hex2rgb( $options['colors']['bar'] ) ) . ',' . ( (int) $options['colors']['bar_opacity'] ) * 0.01 . ');">'
. '<div class="cookie-notice-container" style="color: ' . esc_attr( $options['colors']['text'] ) . ';">'
. '<span id="cn-notice-text" class="cn-text-container">'. $options['message_text'] . '</span>'
. '<span id="cn-notice-buttons" class="cn-buttons-container"><a href="#" id="cn-accept-cookie" data-cookie-set="accept" class="cn-set-cookie ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['accept_text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['accept_text'] ) . '</a>'
. ( $options['refuse_opt'] === true ? '<a href="#" id="cn-refuse-cookie" data-cookie-set="refuse" class="cn-set-cookie ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['refuse_text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['refuse_text'] ) . '</a>' : '' )
. ( $options['see_more'] === true && $options['link_position'] === 'banner' ? '<a href="' . ( $options['see_more_opt']['link_type'] === 'custom' ? esc_url( $options['see_more_opt']['link'] ) : get_permalink( $options['see_more_opt']['id'] ) ) . '" target="' . esc_attr( $options['link_target'] ) . '" id="cn-more-info" class="cn-more-info ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['see_more_opt']['text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['see_more_opt']['text'] ) . '</a>' : '' )
. '</span><a href="javascript:void(0);" id="cn-close-notice" data-cookie-set="accept" class="cn-close-icon" aria-label="' . esc_attr( $options['accept_text'] ) . '"></a>'
. '</div>
' . ( $options['refuse_opt'] === true && $options['revoke_cookies'] == true ?
'<div class="cookie-revoke-container" style="color: ' . esc_attr( $options['colors']['text'] ) . ';">'
. ( ! empty( $options['revoke_message_text'] ) ? '<span id="cn-revoke-text" class="cn-text-container">' . $options['revoke_message_text'] . '</span>' : '' )
. '<span id="cn-revoke-buttons" class="cn-buttons-container"><a href="#" class="cn-revoke-cookie ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['revoke_text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['revoke_text'] ) . '</a></span>
</div>' : '' ) . '
</div>
<!-- / Cookie Notice plugin -->';
echo apply_filters( 'cn_cookie_notice_output', $output, $options );
}
/**
* Load notice scripts and styles - frontend.
*/
public function wp_enqueue_notice_scripts() {
wp_enqueue_script( 'cookie-notice-front', plugins_url( '../js/front' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', __FILE__ ), array(), Cookie_Notice()->defaults['version'], isset( Cookie_Notice()->options['general']['script_placement'] ) && Cookie_Notice()->options['general']['script_placement'] === 'footer' );
wp_localize_script(
'cookie-notice-front',
'cnArgs',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'cn_save_cases' ),
'hideEffect' => Cookie_Notice()->options['general']['hide_effect'],
'position' => Cookie_Notice()->options['general']['position'],
'onScroll' => (int) Cookie_Notice()->options['general']['on_scroll'],
'onScrollOffset' => (int) Cookie_Notice()->options['general']['on_scroll_offset'],
'onClick' => (int) Cookie_Notice()->options['general']['on_click'],
'cookieName' => 'cookie_notice_accepted',
'cookieTime' => Cookie_Notice()->settings->times[Cookie_Notice()->options['general']['time']][1],
'cookieTimeRejected' => Cookie_Notice()->settings->times[Cookie_Notice()->options['general']['time_rejected']][1],
'cookiePath' => ( defined( 'COOKIEPATH' ) ? (string) COOKIEPATH : '' ),
'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? (string) COOKIE_DOMAIN : '' ),
'redirection' => (int) Cookie_Notice()->options['general']['redirection'],
'cache' => (int) ( defined( 'WP_CACHE' ) && WP_CACHE ),
'refuse' => (int) Cookie_Notice()->options['general']['refuse_opt'],
'revokeCookies' => (int) Cookie_Notice()->options['general']['revoke_cookies'],
'revokeCookiesOpt' => Cookie_Notice()->options['general']['revoke_cookies_opt'],
'secure' => (int) is_ssl()
)
);
wp_enqueue_style( 'cookie-notice-front', plugins_url( '../css/front' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.css', __FILE__ ) );
}
/**
* Make a JavaScript Asynchronous
*
* @param string $tag The original enqueued script tag
* @param string $handle The registered unique name of the script
* @param string $src
* @return string $tag The modified script tag
*/
public function wp_enqueue_script_async( $tag, $handle, $src ) {
if ( 'cookie-notice-front' === $handle ) {
$tag = str_replace( '<script', '<script async', $tag );
}
return $tag;
}
/**
* Print non functional JavaScript in body.
*
* @return mixed
*/
public function wp_print_footer_scripts() {
if ( Cookie_Notice()->cookies_accepted() ) {
$scripts = apply_filters( 'cn_refuse_code_scripts_html', html_entity_decode( trim( wp_kses( Cookie_Notice()->options['general']['refuse_code'], Cookie_Notice()->get_allowed_html() ) ) ) );
if ( ! empty( $scripts ) )
echo $scripts;
}
}
/**
* Print non functional JavaScript in header.
*
* @return mixed
*/
public function wp_print_header_scripts() {
if ( Cookie_Notice()->cookies_accepted() ) {
$scripts = apply_filters( 'cn_refuse_code_scripts_html', html_entity_decode( trim( wp_kses( Cookie_Notice()->options['general']['refuse_code_head'], Cookie_Notice()->get_allowed_html() ) ) ) );
if ( ! empty( $scripts ) )
echo $scripts;
}
}
/**
* Add new body classes.
*
* @param array $classes Body classes
* @return array
*/
public function change_body_class( $classes ) {
if ( is_admin() )
return $classes;
if ( Cookie_Notice()->cookies_set() ) {
$classes[] = 'cookies-set';
if ( Cookie_Notice()->cookies_accepted() )
$classes[] = 'cookies-accepted';
else
$classes[] = 'cookies-refused';
} else
$classes[] = 'cookies-not-set';
return $classes;
}
/**
* Purge config cache.
*/
public function purge_cache() {
delete_transient( 'cookie_notice_compliance_cache' );
}
}

View File

@@ -0,0 +1,26 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Check if cookies are accepted.
*
* @return boolean Whether cookies are accepted
*/
if ( ! function_exists( 'cn_cookies_accepted' ) ) {
function cn_cookies_accepted() {
return (bool) Cookie_Notice::cookies_accepted();
}
}
/**
* Check if cookies are set.
*
* @return boolean Whether cookies are set
*/
if ( ! function_exists( 'cn_cookies_set' ) ) {
function cn_cookies_set() {
return (bool) Cookie_Notice::cookies_set();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,915 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Cookie_Notice_Welcome_API class.
*
* @class Cookie_Notice_Welcome_API
*/
class Cookie_Notice_Welcome_API {
// api urls
private $account_api_url = '';
private $designer_api_url = '';
private $x_api_key = '';
/**
* Constructor.
*
* @return void
*/
public function __construct() {
add_action( 'wp_ajax_cn_api_request', array( $this, 'api_request' ) );
$this->account_api_url = 'https://account-api.hu-manity.co';
$this->designer_api_url = 'https://designer-api.hu-manity.co';
$this->x_api_key = 'hudft60djisdusdjwek';
}
/**
* Ajax API request
*/
public function api_request() {
if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
if ( ! check_ajax_referer( 'cookie-notice-welcome', 'nonce' ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
if ( empty( $_POST['request'] ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
if ( ( $_POST['request'] === 'payment' && ! empty( $_POST['cn_payment_nonce'] ) && ! wp_verify_nonce( $_POST['cn_payment_nonce'], 'cn_api_payment' ) ) || ( ! empty( $_POST['cn_nonce'] ) && ! wp_verify_nonce( $_POST['cn_nonce'], 'cn_api_' . $_POST['request'] ) ) )
wp_die( __( 'You do not have permission to access this page.', 'cookie-notice' ) );
$request = in_array( $_POST['request'], array( 'register', 'login', 'configure', 'select_plan', 'payment', 'get_bt_init_token' ), true ) ? $_POST['request'] : '';
$errors = array();
$response = false;
if ( ! $request )
return false;
// get site language
$locale = get_locale();
$locale_code = explode( '_', $locale );
// get app token data
$data_token = get_transient( 'cookie_notice_app_token' );
$api_token = ! empty( $data_token->token ) ? $data_token->token : '';
$admin_id = ! empty( $data_token->email ) ? $data_token->email : '';
$app_id = Cookie_Notice()->options['general']['app_id'];
$params = array();
switch ( $request ) {
case 'get_bt_init_token':
$result = $this->request( 'get_token' );
// is token available?
if ( ! empty( $result->token ) )
$response = array( 'token' => $result->token );
break;
case 'payment':
$error = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
// empty data?
if ( empty( $_POST['payment_nonce'] ) || empty( $_POST['plan'] ) || empty( $_POST['method'] ) ) {
$response = $error;
break;
}
// validate plan and payment method
$plan = in_array( $_POST['plan'], array( 'monthly', 'yearly' ), true ) ? $_POST['plan'] : false;
$plan = ! empty( $plan ) ? 'compliance_' . $plan . '_notrial' : false;
$method = in_array( $_POST['method'], array( 'credit_card', 'paypal' ), true ) ? $_POST['method'] : false;
// valid plan and payment method?
if ( empty( $plan ) || empty( $method ) ) {
$response = array( 'error' => __( 'Empty plan or payment method data.', 'cookie-notice' ) );
break;
}
$result = $this->request( 'get_customer', array( 'AppID' => $app_id ) );
// user found?
if ( ! empty( $result->id ) ) {
$customer = $result;
// create user
} else {
$result = $this->request(
'create_customer',
array(
'AppID' => $app_id,
'AdminID' => $admin_id, // remove later - AdminID from API response
'paymentMethodNonce' => sanitize_text_field( $_POST['payment_nonce'] )
)
);
if ( ! empty( $result->success ) ) {
$customer = $result->customer;
} else {
$customer = $result;
}
}
// user created/received?
if ( empty( $customer->id ) ) {
$response = array( 'error' => __( 'Unable to create customer data.', 'cookie-notice' ) );
break;
}
// @todo: check if subscribtion exists
$subscription = $this->request(
'create_subscription',
array(
'AppID' => $app_id,
'PlanId' => $plan,
'paymentMethodToken' => $customer->paymentMethods[0]->token
)
);
// subscription assigned?
if ( ! empty( $subscription->error ) ) {
$response = $subscription->error;
break;
}
break;
case 'register':
$email = is_email( $_POST['email'] );
$pass = ! empty( $_POST['pass'] ) ? $_POST['pass'] : '';
$pass2 = ! empty( $_POST['pass2'] ) ? $_POST['pass2'] : '';
$terms = isset( $_POST['terms'] );
$language = ! empty( $_POST['language'] ) ? sanitize_text_field( $_POST['language'] ) : 'en';
if ( ! $terms ) {
$response = array( 'error' => __( "Please accept the Terms of Service to proceed.", 'cookie-notice' ) );
break;
}
if ( ! $email ) {
$response = array( 'error' => __( 'Email is not allowed to be empty.', 'cookie-notice' ) );
break;
}
if ( ! $pass || ! is_string( $pass ) ) {
$response = array( 'error' => __( 'Password is not allowed to be empty.', 'cookie-notice' ) );
break;
}
if ( $pass !== $pass2 ) {
$response = array( 'error' => __( "Passwords do not match.", 'cookie-notice' ) );
break;
}
$params = array(
'AdminID' => $email,
'Password' => $pass,
'Language' => $language
);
$response = $this->request( $request, $params );
// errors?
if ( ! empty( $response->error ) ) {
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
// ok, so log in now
$params = array(
'AdminID' => $email,
'Password' => $pass
);
$response = $this->request( 'login', $params );
// errors?
if ( ! empty( $response->error ) ) {
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
// token in response?
if ( empty( $response->data->token ) ) {
$response = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
break;
}
// set token
set_transient( 'cookie_notice_app_token', $response->data, 24 * HOUR_IN_SECONDS );
// multisite?
if ( is_multisite() ) {
switch_to_blog( 1 );
$site_title = get_bloginfo( 'name' );
$site_url = network_site_url();
$site_description = get_bloginfo( 'description' );
restore_current_blog();
} else {
$site_title = get_bloginfo( 'name' );
$site_url = get_home_url();
$site_description = get_bloginfo( 'description' );
}
// create new app, no need to check existing
$params = array(
'DomainName' => $site_title,
'DomainUrl' => $site_url,
);
if ( ! empty( $site_description ) )
$params['DomainDescription'] = $site_description;
$response = $this->request( 'app_create', $params );
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
// data in response?
if ( empty( $response->data->AppID ) || empty( $response->data->SecretKey ) ) {
$response = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
break;
} else {
$app_id = $response->data->AppID;
$secret_key = $response->data->SecretKey;
}
// update options: app ID and secret key
Cookie_Notice()->options['general'] = wp_parse_args( array( 'app_id' => $app_id, 'app_key' => $secret_key ), Cookie_Notice()->options['general'] );
update_option( 'cookie_notice_options', Cookie_Notice()->options['general'] );
// purge cache
delete_transient( 'cookie_notice_compliance_cache' );
// get options
$app_config = get_transient( 'cookie_notice_app_config' );
// create quick config
$params = ! empty( $app_config ) && is_array( $app_config ) ? $app_config : array();
// cast to objects
if ( $params ) {
foreach ( $params as $key => $array ) {
$object = new stdClass();
foreach ( $array as $subkey => $value ) {
$new_params[$key] = $object;
$new_params[$key]->{$subkey} = $value;
}
}
$params = $new_params;
}
$params['AppID'] = $app_id;
// @todo When mutliple default languages are supported
$params['DefaultLanguage'] = 'en';
// $params['CurrentLanguage'] = $locale_code[0];
$response = $this->request( 'quick_config', $params );
if ( $response->status === 200 ) {
// notify publish app
$params = array(
'AppID' => $app_id
);
$response = $this->request( 'notify_app', $params );
if ( $response->status === 200 ) {
$response = true;
// update app status
update_option( 'cookie_notice_status', 'active' );
} else {
// update app status
update_option( 'cookie_notice_status', 'pending' );
// errors?
if ( ! empty( $response->error ) ) {
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
}
} else {
// update app status
update_option( 'cookie_notice_status', 'pending' );
// errors?
if ( ! empty( $response->error ) ) {
$response->error = $response->error;
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
}
break;
case 'login':
$email = is_email( $_POST['email'] );
$pass = ! empty( $_POST['pass'] ) ? $_POST['pass'] : '';
if ( ! $email ) {
$response = array( 'error' => __( 'Email is not allowed to be empty.', 'cookie-notice' ) );
break;
}
if ( ! $pass ) {
$response = array( 'error' => __( 'Password is not allowed to be empty.', 'cookie-notice' ) );
break;
}
$params = array(
'AdminID' => $email,
'Password' => $pass
);
$response = $this->request( $request, $params );
// errors?
if ( ! empty( $response->error ) ) {
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
// token in response?
if ( empty( $response->data->token ) ) {
$response = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
break;
}
// set token
set_transient( 'cookie_notice_app_token', $response->data, 24 * HOUR_IN_SECONDS );
// get apps and check if one for the current domain already exists
$response = $this->request( 'list_apps', array() );
// echo '<pre>'; print_r( $response ); echo '</pre>'; exit;
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
$apps_list = array();
$app_exists = false;
// multisite?
if ( is_multisite() ) {
switch_to_blog( 1 );
$site_title = get_bloginfo( 'name' );
$site_url = network_site_url();
$site_description = get_bloginfo( 'description' );
restore_current_blog();
} else {
$site_title = get_bloginfo( 'name' );
$site_url = get_home_url();
$site_description = get_bloginfo( 'description' );
}
// apps added, check if current one exists
if ( ! empty( $response->data ) ) {
$apps_list = (array) $response->data;
foreach ( $apps_list as $index => $app ) {
$site_without_http = trim( str_replace( array( 'http://', 'https://' ), '', $site_url ), '/' );
if ( $app->DomainUrl === $site_without_http ) {
$app_exists = $app;
continue;
}
}
}
// if no app, create one
if ( ! $app_exists ) {
// create new app
$params = array(
'DomainName' => $site_title,
'DomainUrl' => $site_url,
);
if ( ! empty( $site_description ) )
$params['DomainDescription'] = $site_description;
$response = $this->request( 'app_create', $params );
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
$app_exists = $response->data;
}
// check if we have the valid app data
if ( empty( $app_exists->AppID ) || empty( $app_exists->SecretKey ) ) {
$response = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
break;
}
// update options: app ID and secret key
Cookie_Notice()->options['general'] = wp_parse_args( array( 'app_id' => $app_exists->AppID, 'app_key' => $app_exists->SecretKey ), Cookie_Notice()->options['general'] );
update_option( 'cookie_notice_options', Cookie_Notice()->options['general'] );
// purge cache
delete_transient( 'cookie_notice_compliance_cache' );
// create quick config
$params = array(
'AppID' => $app_exists->AppID,
'DefaultLanguage' => 'en',
// 'CurrentLanguage' => $locale_code[0]
);
$response = $this->request( 'quick_config', $params );
if ( $response->status === 200 ) {
// @todo notify publish app
$params = array(
'AppID' => $app_exists->AppID
);
$response = $this->request( 'notify_app', $params );
if ( $response->status === 200 ) {
$response = true;
// update app status
update_option( 'cookie_notice_status', 'active' );
} else {
// update app status
update_option( 'cookie_notice_status', 'pending' );
// errors?
if ( ! empty( $response->error ) ) {
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
}
} else {
// update app status
update_option( 'cookie_notice_status', 'pending' );
// errors?
if ( ! empty( $response->error ) ) {
$response->error = $response->error;
break;
}
// errors?
if ( ! empty( $response->message ) ) {
$response->error = $response->message;
break;
}
}
break;
case 'configure':
$fields = array(
'cn_position',
'cn_color_primary',
'cn_color_background',
'cn_color_border',
'cn_color_text',
'cn_color_heading',
'cn_color_button_text',
'cn_laws',
'cn_naming',
'cn_privacy_paper',
'cn_privacy_contact',
);
$options = array();
// loop through potential config form fields
foreach ( $fields as $field ) {
switch ( $field ) {
case 'cn_position':
// sanitize position
$position = isset( $_POST[$field] ) ? sanitize_key( $_POST[$field] ) : '';
// valid position?
if ( in_array( $position, array( 'bottom', 'top', 'left', 'right', 'center' ), true ) )
$options['design']['position'] = $position;
break;
case 'cn_color_primary':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['primaryColor'] = '#20c19e';
break;
case 'cn_color_background':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['bannerColor'] = '#ffffff';
break;
case 'cn_color_border':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['borderColor'] = '#5e6a74';
break;
case 'cn_color_text':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['textColor'] = '#434f58';
break;
case 'cn_color_heading':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['headingColor'] = '#434f58';
break;
case 'cn_color_button_text':
// sanitize color
$color = isset( $_POST[$field] ) ? sanitize_hex_color( $_POST[$field] ) : '';
// valid color?
if ( empty( $color ) )
$options['design']['btnTextColor'] = '#ffffff';
break;
case 'cn_laws':
$new_options = array();
// any data?
if ( is_array( $_POST[$field] ) && ! empty( $_POST[$field] ) ) {
$options['laws'] = array_map( 'sanitize_text_field', $_POST[$field] );
foreach ( $options['laws'] as $law ) {
if ( in_array( $law, array( 'gdpr', 'ccpa' ), true ) )
$new_options[$law] = true;
}
}
$options['laws'] = $new_options;
// GDPR
if ( array_key_exists( 'gdpr', $options['laws'] ) )
$options['config']['privacyPolicyLink'] = true;
else
$options['config']['privacyPolicyLink'] = false;
// CCPA
if ( array_key_exists( 'ccpa', $options['laws'] ) )
$options['config']['dontSellLink'] = true;
else
$options['config']['dontSellLink'] = false;
break;
case 'cn_naming':
$naming = isset( $_POST[$field] ) ? (int) $_POST[$field] : 1;
$naming = in_array( $naming, array( 1, 2, 3 ) ) ? $naming : 1;
// English only for now
$level_names = array(
1 => array(
1 => 'Silver',
2 => 'Gold',
3 => 'Platinum'
),
2 => array(
1 => 'Private',
2 => 'Balanced',
3 => 'Personalized'
),
3 => array(
1 => 'Reject All',
2 => 'Accept Some',
3 => 'Accept All'
)
);
$options['text'] = array(
'levelNameText_1' => $level_names[$naming][1],
'levelNameText_2' => $level_names[$naming][2],
'levelNameText_3' => $level_names[$naming][3]
);
break;
case 'cn_privacy_paper':
$options['config']['privacyPaper'] = false; // isset( $_POST[$field] );
break;
case 'cn_privacy_contact':
$options['config']['privacyContact'] = false;// isset( $_POST[$field] );
break;
}
}
// set options
set_transient( 'cookie_notice_app_config', $options, 24 * HOUR_IN_SECONDS );
break;
case 'select_plan':
break;
}
echo json_encode( $response );
exit;
}
/**
* API request.
*
* @param string $action The requested action.
* @param array $_data Parameters for the API action.
* @return false|object
*/
private function request( $request = '', $params = '' ) {
$api_args = array(
'timeout' => 60,
'sslverify' => false,
'headers' => array( 'x-api-key' => $this->x_api_key )
);
$api_params = array();
$json = false;
// get app token data
$data_token = get_transient( 'cookie_notice_app_token' );
$api_token = ! empty( $data_token->token ) ? $data_token->token : '';
$admin_id = ! empty( $data_token->email ) ? $data_token->email : '';
switch ( $request ) {
case 'register':
$api_url = $this->account_api_url . '/api/account/account/registration';
$api_args['method'] = 'POST';
break;
case 'login':
$api_url = $this->account_api_url . '/api/account/account/login';
$api_args['method'] = 'POST';
break;
case 'list_apps':
$api_url = $this->account_api_url . '/api/account/app/list';
$api_args['method'] = 'GET';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token
)
);
break;
case 'app_create':
$api_url = $this->account_api_url . '/api/account/app/add';
$api_args['method'] = 'POST';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token
)
);
break;
case 'get_config':
$api_url = $this->designer_api_url . '/api/designer/user-design-live';
$api_args['method'] = 'GET';
break;
case 'quick_config':
$json = true;
$api_url = $this->designer_api_url . '/api/designer/user-design/quick';
$api_args['method'] = 'POST';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token,
'Content-Type' => 'application/json; charset=utf-8'
)
);
break;
case 'notify_app':
$json = true;
$api_url = $this->account_api_url . '/api/account/app/notifyAppPublished';
$api_args['method'] = 'POST';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token,
'Content-Type' => 'application/json; charset=utf-8'
)
);
break;
// braintree init token
case 'get_token':
$api_url = $this->account_api_url . '/api/account/braintree';
$api_args['method'] = 'GET';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token
)
);
break;
// braintree get customer
case 'get_customer':
$json = true;
$api_url = $this->account_api_url . '/api/account/braintree/findcustomer';
$api_args['method'] = 'POST';
$api_args['data_format'] = 'body';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token,
'Content-Type' => 'application/json; charset=utf-8'
)
);
break;
// braintree create customer in vault
case 'create_customer':
$json = true;
$api_url = $this->account_api_url . '/api/account/braintree/createcustomer';
$api_args['method'] = 'POST';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token,
'Content-Type' => 'application/json; charset=utf-8'
)
);
break;
// braintree assign subscription to the customer
case 'create_subscription':
$json = true;
$api_url = $this->account_api_url . '/api/account/braintree/createsubscription';
$api_args['method'] = 'POST';
$api_args['headers'] = array_merge(
$api_args['headers'],
array(
'Authorization' => 'Bearer ' . $api_token,
'Content-Type' => 'application/json; charset=utf-8'
)
);
break;
}
if ( ! empty( $params ) && is_array( $params ) ) {
foreach ( $params as $key => $param ) {
if ( is_object( $param ) )
$api_params[$key] = $param;
else
$api_params[$key] = sanitize_text_field( $param );
}
if ( $json )
$api_args['body'] = json_encode( $api_params );
else
$api_args['body'] = $api_params;
}
$response = wp_remote_request( $api_url, $api_args );
if ( is_wp_error( $response ) )
$result = array( 'error' => $response->get_error_message() );
else {
$content_type = wp_remote_retrieve_header( $response, 'Content-Type' );
// HTML response, means error
if ( $content_type == 'text/html' ) {
$result = array( 'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ) );
} else {
$result = wp_remote_retrieve_body( $response );
// detect json or array
$result = is_array( $result ) ? $result : json_decode( $result );
}
}
return $result;
}
/**
* Ajax API request
*/
public function get_app_status( $app_id ) {
$result = '';
if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) )
return false;
$params = array(
'AppID' => $app_id
);
$response = $this->request( 'get_config', $params );
if ( ! empty( $response->data ) ) {
$result = 'active';
} else {
if ( ! empty( $response->error ) ) {
if ( $response->error == 'App is not puplised yet' )
$result = 'pending';
else
$result = '';
}
}
return $result;
}
/**
* Defines the function used to initial the cURL library.
*
* @param string $url To URL to which the request is being made
* @param string $params The URL query parameters
* @return string $response The response, if available; otherwise, null
*/
private function curl( $url, $args ) {
$curl = curl_init( $url );
$headers = array();
foreach ( $args['headers'] as $header => $value ) {
$headers[] = $header . ': ' . $value;
}
curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_HEADER, false );
curl_setopt( $curl, CURLOPT_USERAGENT, '' );
curl_setopt( $curl, CURLOPT_HTTPGET, true );
curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $args['body'] );
curl_setopt( $curl, CURLOPT_TIMEOUT, 10 );
$response = curl_exec( $curl );
if ( 0 !== curl_errno( $curl ) || 200 !== curl_getinfo( $curl, CURLINFO_HTTP_CODE ) )
$response = null;
curl_close( $curl );
return $response;
}
}

View File

@@ -0,0 +1,132 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Cookie_Notice_Welcome_Frontend class.
*
* @class Cookie_Notice_Welcome_Frontend
*/
class Cookie_Notice_Welcome_Frontend {
private $widget_url = '';
private $preview_mode = false;
/**
* Constructor.
*
* @return void
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'preview_init' ), 1 );
$this->widget_url = '//cdn.hu-manity.co/hu-banner.min.js';
}
/**
* Initialize preview mode.
*/
public function preview_init() {
// check preview mode
$this->preview_mode = isset( $_GET['cn_preview_mode'] ) ? absint( $_GET['cn_preview_mode'] ) : false;
if ( $this->preview_mode !== false ) {
// filters
add_filter( 'show_admin_bar', '__return_false' );
add_filter( 'cn_cookie_notice_output', '__return_false', 1000 );
// actions
add_action( 'wp_enqueue_scripts', array( $this, 'wp_dequeue_scripts' ) );
// only in live preview
if ( $this->preview_mode === 1 ) {
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
add_action( 'wp_head', array( $this, 'wp_head_scripts' ), 0 );
}
}
}
/**
* Load scripts and styles.
*
* @return void
*/
public function wp_enqueue_scripts( $page ) {
// show only in live preview
if ( $this->preview_mode === 1 ) {
wp_enqueue_script( 'cookie-notice-welcome-frontend', plugins_url( '../js/front-welcome.js', __FILE__ ), array( 'jquery', 'underscore' ), Cookie_Notice()->defaults['version'] );
wp_localize_script(
'cookie-notice-welcome-frontend',
'cnFrontWelcome',
array(
'previewMode' => $this->preview_mode,
'allowedURLs' => $this->get_allowed_urls(),
'levelNames' => Cookie_Notice()->settings->level_names,
'textStrings' => Cookie_Notice()->settings->text_strings
)
);
}
}
/**
* Unload scripts and styles.
*
* @return void
*/
public function wp_dequeue_scripts( $page ) {
// deregister native CN
wp_dequeue_script( 'cookie-notice-front' );
}
/**
* .
*
* @return void
*/
public function wp_head_scripts() {
$options = array(
'currentLanguage' => 'en',
'previewMode' => true,
'debugMode' => true,
'config' => array(
'privacyPaper' => true,
'privacyContact' => true
)
);
echo '
<!-- Hu Banner -->
<script type="text/javascript">
var huOptions = ' . json_encode( $options ) . ';
</script>
<script type="text/javascript" src="' . $this->widget_url . '"></script>
<style>.hu-preview-mode #hu::after {content: "";position: fixed;width: 100%;height: 100%;display: block;top: 0;left: 0;}</style>';
}
/**
* Get URLs allowed to be previewed.
*
* @return array
*/
public function get_allowed_urls() {
$allowed_urls = array( home_url( '/' ) );
if ( is_ssl() && ! $this->is_cross_domain() )
$allowed_urls[] = home_url( '/', 'https' );
return $allowed_urls;
}
/**
* Determines whether the admin and the frontend are on different domains.
*
* @return bool
*/
public function is_cross_domain() {
$admin_origin = wp_parse_url( admin_url() );
$home_origin = wp_parse_url( home_url() );
return ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
}
}

View File

@@ -0,0 +1,743 @@
<?php
// exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Cookie_Notice_Welcome class.
*
* @class Cookie_Notice_Welcome
*/
class Cookie_Notice_Welcome {
private $app_login_url = '';
public function __construct() {
// actions
add_action( 'admin_init', array( $this, 'welcome' ) );
add_action( 'wp_ajax_cn_welcome_screen', array( $this, 'welcome_screen' ) );
$this->app_login_url = 'https://app.hu-manity.co/#/en/cc2/login';
}
/**
* Load scripts and styles - admin.
*/
public function admin_enqueue_scripts( $page ) {
if ( in_array( Cookie_Notice()->get_status(), array( 'active', 'pending' ) ) )
return;
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'cookie-notice-modaal', plugins_url( '../assets/modaal/css/modaal.min.css', __FILE__ ), array(), Cookie_Notice()->defaults['version'] );
wp_enqueue_script( 'cookie-notice-modaal', plugins_url( '../assets/modaal/js/modaal.min.js', __FILE__ ), array(), Cookie_Notice()->defaults['version'] );
wp_enqueue_style( 'cookie-notice-spectrum', plugins_url( '../assets/spectrum/spectrum.min.css', __FILE__ ), array(), Cookie_Notice()->defaults['version'] );
wp_enqueue_style( 'cookie-notice-microtip', plugins_url( '../assets/microtip/microtip.min.css', __FILE__ ), array(), Cookie_Notice()->defaults['version'] );
wp_enqueue_script( 'cookie-notice-spectrum', plugins_url( '../assets/spectrum/spectrum.min.js', __FILE__ ), array(), Cookie_Notice()->defaults['version'] );
wp_enqueue_script( 'cookie-notice-welcome', plugins_url( '../js/admin-welcome.js', __FILE__ ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-progressbar' ), Cookie_Notice()->defaults['version'] );
wp_enqueue_script( 'cookie-notice-braintree-client', 'https://js.braintreegateway.com/web/3.71.0/js/client.min.js', array(), null, false );
wp_enqueue_script( 'cookie-notice-braintree-hostedfields', 'https://js.braintreegateway.com/web/3.71.0/js/hosted-fields.min.js', array(), null, false );
wp_enqueue_script( 'cookie-notice-braintree-paypal', 'https://js.braintreegateway.com/web/3.71.0/js/paypal-checkout.min.js', array(), null, false );
$js_args = array(
'ajaxURL' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'cookie-notice-welcome' ),
'initModal' => get_transient( 'cn_show_welcome' ), // welcome modal
'error' => __( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ),
'statusPassed' => __( 'Passed', 'cookie-notice' ),
'statusFailed' => __( 'Failed', 'cookie-notice' ),
'complianceStatus' => Cookie_Notice()->get_status(),
'complianceFailed' => __( '<em>Compliance Failed!</em>Your website does not achieve minimum viable compliance. <b><a href="#" class="cn-sign-up">Sign up to Cookie Compliance</a></b> to bring your site into compliance with the latest data privacy rules and regulations.', 'cookie-notice' ),
'compliancePassed' => __( '<em>Compliance Passed!</em>Congratulations. Your website meets minimum viable compliance.', 'cookie-notice' ),
'invalidFields' => __( 'Please fill all the required fields.', 'cookie-notice' )
);
// delete the show modal transient
delete_transient( 'cn_show_welcome' );
wp_localize_script(
'cookie-notice-welcome',
'cnWelcomeArgs',
$js_args
);
wp_enqueue_style( 'cookie-notice-welcome', plugins_url( '../css/admin-welcome.css', __FILE__ ) );
}
/**
* Add one or more classes to the body tag in the dashboard.
*
* @param string $classes
* @return string
*/
public function admin_body_class( $classes ) {
if ( isset( $_GET['page'] ) && $_GET['page'] === 'cookie-notice-welcome' )
$classes .= ' folded';
return $classes;
}
/**
* Send user to the welcome page on first activation.
*
* @return void
*/
public function welcome() {
global $pagenow;
if ( $pagenow != 'admin.php' )
return;
if ( isset( $_GET['page'] ) && $_GET['page'] !== 'cookie-notice' )
return;
// bail if activating from network, or bulk, or within an iFrame
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
return;
if ( (isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action']) && (isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'cookie-notice.php' )) )
return;
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
}
/**
* Welcome modal container.
*/
public function admin_footer() {
echo '<button id="cn-modal-trigger" style="display:none;"></button>';
}
/**
* Output the welcome screen.
*
* @return void
*/
public function welcome_page() {
// get plugin version
$plugin_version = substr( Cookie_Notice()->defaults['version'], 0, 3 );
$screen = ( isset( $_GET['screen'] ) ? (int) $_GET['screen'] : 1 );
$this->welcome_screen( $screen );
}
/**
* Render welcome screen sidebar step.
*
* @param int $step
* @return mixed
*/
public function welcome_screen( $screen, $echo = true ) {
global $current_user;
if ( ! current_user_can( 'install_plugins' ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
$sidebars = array( 'about', 'login', 'register', 'configure', 'select_plan', 'success' );
$steps = array( 1, 2, 3, 4 );
$screens = array_merge( $sidebars, $steps );
$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
$screen = ! empty( $screen ) && in_array( $screen, $screens ) ? $screen : ( isset( $_REQUEST['screen'] ) && in_array( $_REQUEST['screen'], $screens ) ? $_REQUEST['screen'] : '' );
if ( empty( $screen ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
if ( $is_ajax && ! check_ajax_referer( 'cookie-notice-welcome', 'nonce' ) )
wp_die( _( 'You do not have permission to access this page.', 'cookie-notice' ) );
// get token data
$token_data = get_transient( 'cookie_notice_app_token' );
// step screens
if ( in_array( $screen, $steps ) ) {
$html = '
<div class="wrap full-width-layout cn-welcome-wrap cn-welcome-step-' . esc_attr( $screen ) . ' has-loader">';
if ( $screen == 1 ) {
$html .= $this->welcome_screen( 'about', false );
$html .= '
<div class="cn-content cn-sidebar-visible">
<div class="cn-inner">
<div class="cn-content-full">
<h1><b>Cookie Compliance&trade;</b></h1>
<h2>' . __( 'The next generation of Cookie Notice', 'cookie-notice' ) . '</h2>
<div class="cn-lead">
<p><b>' . __( 'Cookie Compliance is a free web application that enables websites to take a proactive approach to data protection and consent laws.', 'cookie-notice' ) . '</b></p>
<div class="cn-hero-image">
<div class="cn-flex-item">
<img src="' . plugins_url( '../img/screen-compliance.png', __FILE__ ) . '" alt="Cookie Notice dashboard" />
</div>
</div>
<p>' . __( 'It is the first solution to offer <b>intentional consent</b>, a new consent framework that incorporates the latest guidelines from over 100+ countries, and emerging standards from leading international organizations like the IEEE.', 'cookie-notice' ) . '</p>
<p>' . __( 'Cookie Notice includes <b>seamless integration</b> with Cookie Compliance to help your site comply with the latest updates to existing consent laws and provide a beautiful, multi-level experience to engage visitors in data privacy decisions.', 'cookie-notice' ) . '</p>
</div>';
$html .= '
<div class="cn-buttons">
<button type="button" class="cn-btn cn-btn-lg cn-screen-button" data-screen="2"><span class="cn-spinner"></span>' . __( 'Sign up to Cookie Compliance', 'cookie-notice' ) . '</button><br />
<button type="button" class="cn-btn cn-btn-lg cn-btn-transparent cn-skip-button">' . __( 'Skip for now', 'cookie-notice' ) . '</button>
</div>
';
$html .= '
</div>
</div>
</div>';
} elseif ( $screen == 2 ) {
$html .= $this->welcome_screen( 'configure', false );
$html .= '
<div id="cn_upgrade_iframe" class="cn-content cn-sidebar-visible has-loader cn-loading"><span class="cn-spinner"></span>
<iframe id="cn_iframe_id" src="' . home_url( '/?cn_preview_mode=1' ) . '"></iframe>
</div>';
} elseif ( $screen == 3 ) {
// get options
$app_config = get_transient( 'cookie_notice_app_config' );
$html .= $this->welcome_screen( 'register', false );
$html .= '
<div class="cn-content cn-sidebar-visible">
<div class="cn-inner">
<div class="cn-content-full">
<h1><b>Cookie Compliance&trade;</b></h1>
<h2>' . __( 'The next generation of Cookie Notice', 'cookie-notice' ) . '</h2>
<div class="cn-lead">
<p>' . __( 'Take a proactive approach to data protection and consent laws by signing up for Cookie Compliance account. Then select a limited Basic Plan for free or get one of the Professional Plans for unlimited visits, consent storage, languages and customizations.', 'cookie-notice' ) . '</p>
</div>';
/*
<div class="cn-billing-wrapper cn-radio-wrapper">
<label for="cn_billing_monthly"><input id="cn_billing_monthly" type="radio" name="cn_billing" value="monthly" checked><span><span>' . __( 'Billing Monthly', 'cookie-notice' ) . '</span><span class="cn-plan-overlay"></span></span></label><label for="cn_billing_yearly"><input id="cn_billing_yearly" type="radio" name="cn_billing" value="yearly"><span><span>' . __( 'Billing Yearly', 'cookie-notice' ) . '</span> <span class="cn-price-off">(' . __( '15% off', 'cookie-notice' ) . ')</span><span class="cn-plan-overlay"></span></span></label>
</div>
$html .= '
<div class="cn-hero-image">
<div class="cn-flex-item">
<div class="cn-logo-container">
<img src="' . plugins_url( '../img/cookie-notice-logo-dark.png', __FILE__ ) . '">
<span class="cn-badge">' . __( 'WP Plugin', 'cookie-notice' ) . '</span>
</div>
<img src="' . plugins_url( '../img/screen-notice.png', __FILE__ ) . '" alt="Cookie Notice dashboard" />
<ul class="cn-features-list">
<li><span>' . __( '<b>Free</b>', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Customizable notice message', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Consent on click, scroll or close', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Link to Privacy Policy page', 'cookie-notice' ) . '</span></li>
</ul>
</div>
<div class="cn-flex-item">
<img src="//cno0-53eb.kxcdn.com/screen-plus.png" alt="Cookie Notice + Compliance" />
</div>
<div class="cn-flex-item">
<div class="cn-logo-container">
<img src="' . plugins_url( '../img/cookie-compliance-logo-dark.png', __FILE__ ) . '">
<span class="cn-badge">' . __( 'Web App', 'cookie-notice' ) . '</span>
</div>
<img src="' . plugins_url( '../img/screen-compliance.png', __FILE__ ) . '"alt="Cookie Compliance dashboard" />
<ul class="cn-features-list">
<li><span>' . __( '<b>Free plan</b>', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Consent Analytics Dashboard', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Cookie Autoblocking', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Cookie Categories', 'cookie-notice' ) . '</span></li>
<li><span>' . __( 'Proof-of-Consent Storage', 'cookie-notice' ) . '</span></li>
<li><span>' . __( "Link to 'Do Not Sell' page", 'cookie-notice' ) . '</span></li>
</ul>
</div>
</div>';
*/
$html .= '
<h3 class="cn-pricing-select">' . __( 'Compliance Plans', 'cookie-notice' ) . ':</h3>
<div class="cn-pricing-table">
<label class="cn-pricing-item" for="cn_pricing_plan_free">
<input id="cn_pricing_plan_free" type="radio" name="cn_pricing_plan" value="free">
<div class="cn-pricing-info">
<div class="cn-pricing-head">
<h4>' . __( 'Basic', 'cookie-notice' ) . '</h4>
<span class="cn-plan-pricing"><span class="cn-plan-price">' . __( 'Free', 'cookie-notice' ) . '</span></span>
</div>
<div class="cn-pricing-body">
<p class="cn-included"><span class="cn-icon"></span>' . __( 'GDPR, CCPA, ePrivacy, PECR compliance', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( 'Consent Analytics Dashboard', 'cookie-notice' ) . '</p>
<p class="cn-excluded"><span class="cn-icon"></span>' . __( '<b>1,000</b> visits / month', 'cookie-notice' ) . '</p>
<p class="cn-excluded"><span class="cn-icon"></span>' . __( '<b>30 days</b> consent storage', 'cookie-notice' ) . '</p>
<p class="cn-excluded"><span class="cn-icon"></span>' . __( '<b>1 additional</b> language', 'cookie-notice' ) . '</p>
<p class="cn-excluded"><span class="cn-icon"></span>' . __( '<b>Basic</b> Support', 'cookie-notice' ) . '</p>
</div>
<div class="cn-pricing-footer">
<button type="button" class="cn-btn cn-btn-outline">' . __( 'Select Plan', 'cookie-notice' ) . '</button>
</div>
</div>
</label>
<label class="cn-pricing-item" for="cn_pricing_plan_monthly">
<input id="cn_pricing_plan_monthly" type="radio" name="cn_pricing_plan" value="monthly">
<div class="cn-pricing-info">
<div class="cn-pricing-head">
<h4>' . __( 'Professional Monthly', 'cookie-notice' ) . '</h4>
<span class="cn-plan-pricing"><span class="cn-plan-price"><sup>$</sup>14.95</span> / ' . __( 'month', 'cookie-notice' ) . '</span>
</div>
<div class="cn-pricing-body">
<p class="cn-included"><span class="cn-icon"></span>' . __( 'GDPR, CCPA, ePrivacy, PECR compliance', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( 'Consent Analytics Dashboard', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Unlimited</b> visits', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Lifetime</b> consent storage', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Unlimited</b> languages', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Regular</b> Support', 'cookie-notice' ) . '</p>
</div>
<div class="cn-pricing-footer">
<button type="button" class="cn-btn cn-btn-outline">' . __( 'Select Plan', 'cookie-notice' ) . '</button>
</div>
</div>
</label>
<label class="cn-pricing-item" for="cn_pricing_plan_yearly">
<input id="cn_pricing_plan_yearly" type="radio" name="cn_pricing_plan" value="yearly">
<div class="cn-pricing-info">
<div class="cn-pricing-head">
<h4>' . __( 'Professional Yearly', 'cookie-notice' ) . '</h4>
<span class="cn-plan-pricing"><span class="cn-plan-price"><sup>$</sup>149.50</span> / ' . __( 'year', 'cookie-notice' ) . '</span>
<span class="cn-plan-promo">' . __( 'Best Value', 'cookie-notice' ) . '</span>
</div>
<div class="cn-pricing-body">
<p class="cn-included"><span class="cn-icon"></span>' . __( 'GDPR, CCPA, ePrivacy, PECR compliance', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( 'Consent Analytics Dashboard', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Unlimited</b> visits', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Lifetime</b> consent storage', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Unlimited</b> languages', 'cookie-notice' ) . '</p>
<p class="cn-included"><span class="cn-icon"></span>' . __( '<b>Premium</b> Support', 'cookie-notice' ) . '</p>
</div>
<div class="cn-pricing-footer">
<button type="button" class="cn-btn cn-btn-outline">' . __( 'Select Plan', 'cookie-notice' ) . '</button>
</div>
</div>
</label>
</div>
<div class="cn-buttons">
<button type="button" class="cn-btn cn-btn-lg cn-btn-transparent cn-skip-button">' . __( "I dont want to create an account now", 'cookie-notice' ) . '</button>
</div>';
$html .= '
</div>
</div>
</div>';
} elseif ( $screen == 4 ) {
$html .= $this->welcome_screen( 'success', false );
$html .= '
<div class="cn-content cn-sidebar-visible">
<div class="cn-inner">
<div class="cn-content-full">
<h1><b>' . __( 'Congratulations', 'cookie-notice' ) . '</b></h1>
<h2>' . __( 'You are now promoting privacy with Hu-manity.co', 'cookie-notice' ) . '</h2>
<div class="cn-lead">
<p>' . __( 'Log in to your Cookie Compliance&trade; account and continue configuring your Privacy Experience.', 'cookie-notice' ) . '</p>
</div>
<div class="cn-buttons">
<a href="' . $this->app_login_url . '" class="cn-btn cn-btn-lg" target="_blank">' . __( 'Go to Application', 'cookie-notice' ) . '</a>
</div>
</div>
</div>
</div>';
}
$html .= '
</div>';
// sidebar screens
} elseif ( in_array( $screen, $sidebars ) ) {
$html = '';
if ( $screen === 'about' ) {
$theme = wp_get_theme();
$html .= '
<div class="cn-sidebar cn-sidebar-left has-loader">
<div class="cn-inner">
<div class="cn-header">
<div class="cn-top-bar">
<div class="cn-logo"><img src="' . plugins_url( '../img/cookie-notice-logo.png', __FILE__ ) . '" alt="Cookie Notice logo" /></div>
</div>
</div>
<div class="cn-body">
<h2>' . __( 'Compliance check', 'cookie-notice' ) . '</h2>
<div class="cn-lead"><p>' . __( 'This is a Compliance Check to determine your sites compliance with updated data processing and consent rules under GDPR, CCPA and other international data privacy laws.', 'cookie-notice' ) . '</p></div>
<div id="cn_preview_about">
<p>' . __( 'Site URL', 'cookie-notice' ) . ': <b>' . home_url() . '</b></p>
<p>' . __( 'Site Name', 'cookie-notice' ) . ': <b>' . get_bloginfo( 'name' ) . '</b></p>
</div>
<div class="cn-compliance-check">
<div class="cn-progressbar"><div class="cn-progress-label">' . __( 'Checking...', 'cookie-notice' ) . '</div></div>
<div class="cn-compliance-feedback cn-hidden"></div>
<div class="cn-compliance-results">
<div class="cn-compliance-item"><p><span class="cn-compliance-label">' . __( 'Cookie Notice', 'cookie-notice' ) . ' </span><span class="cn-compliance-status"></span></p><p><span class="cn-compliance-desc">' . __( 'Notifies visitors that site uses cookies.', 'cookie-notice' ) . '</span></p></div>
<div class="cn-compliance-item" style="display: none;"><p><span class="cn-compliance-label">' . __( 'Autoblocking', 'cookie-notice' ) . ' </span><span class="cn-compliance-status"></span></p><p><span class="cn-compliance-desc">' . __( 'Non-essential cookies blocked until consent is registered.', 'cookie-notice' ) . '</span></p></div>
<div class="cn-compliance-item" style="display: none;"><p><span class="cn-compliance-label">' . __( 'Cookie Categories', 'cookie-notice' ) . ' </span><span class="cn-compliance-status"></span></p><p><span class="cn-compliance-desc">' . __( 'Separate consent requested per purpose of use.', 'cookie-notice' ) . '</span></p></div>
<div class="cn-compliance-item" style="display: none;"><p><span class="cn-compliance-label">' . __( 'Proof-of-Consent', 'cookie-notice' ) . ' </span><span class="cn-compliance-status"></span></p><p><span class="cn-compliance-desc">' . __( 'Proof-of-consent stored in secure audit format.', 'cookie-notice' ) . '</span></p></div>
</div>
</div>
' /* <div id="cn_preview_frame"><img src=" ' . esc_url( $theme->get_screenshot() ) . '" /></div>
. '<div id="cn_preview_frame"><div id="cn_preview_frame_wrapper"><iframe id="cn_iframe_id" src="' . home_url( '/?cn_preview_mode=0' ) . '" scrolling="no" frameborder="0"></iframe></div></div> */ . '
</div>';
} elseif ( $screen === 'configure' ) {
$html .= '
<div class="cn-sidebar cn-sidebar-left has-loader cn-theme-light">
<div class="cn-inner">
<div class="cn-header">
<div class="cn-top-bar">
<div class="cn-logo"><img src="' . plugins_url( '../img/cookie-notice-logo.png', __FILE__ ) . '" alt="Cookie Notice logo" /></div>
</div>
</div>
<div class="cn-body">
<h2>' . __( 'Live Setup', 'cookie-notice' ) . '</h2>
<div class="cn-lead"><p>' . __( 'Configure your Cookie Notice & Compliance design and compliance features through the options below. Click Apply Setup to save the configuration and go to selecting your preferred cookie solution.', 'cookie-notice' ) . '</p></div>
<form id="cn-form-configure" class="cn-form" action="" data-action="configure">
<div class="cn-accordion">
<div class="cn-accordion-item cn-form-container" tabindex="-1">
<div class="cn-accordion-header cn-form-header"><button class="cn-accordion-button" type="button">' . __( 'Banner Compliance', 'cookie-notice' ) . '</button></div>
<div class="cn-accordion-collapse cn-form">
<div class="cn-form-feedback cn-hidden"></div>' .
/*
<div class="cn-field cn-field-select">
<label for="cn_location">' . __( 'What is the location of your business/organization?', 'cookie-notice' ) . '</label>
<div class="cn-select-wrapper">
<select id="cn_location" name="cn_location">
<option value="0">' . __( 'Select location', 'cookie-notice' ) . '</option>';
foreach ( Cookie_Notice()->settings->countries as $country_code => $country_name ) {
$html .= '<option value="' . $country_code . '">' . $country_name . '</option>';
}
$html .= '
</select>
</div>
</div>
*/
'
<div id="cn_laws" class="cn-field cn-field-checkbox">
<label>' . __( 'Select the laws that apply to your business', 'cookie-notice' ) . ':</label>
<div class="cn-checkbox-image-wrapper">
<label for="cn_laws_gdpr"><input id="cn_laws_gdpr" type="checkbox" name="cn_laws" value="gdpr" title="' . __( 'GDPR', 'cookie-notice' ) . '" checked><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAC/ElEQVRoge2ZzZGjMBCFmcMet4rjHjlsANQmsGRgZ7BkMGRgZ7DOYMhgnME4A08GdgZ2AujbA41HiD8JEOawXUWVXUjd73WLVqsVBB4F+OlTv3cBciB7Ng4nAV6ADHjnSz6A7bOxPQQIh94Dd43AaSFodgKkFmNOGoHEYvwySw1IgJtFFHJgC6RD4GTJnedF2jQSAUfNqzfgMFFnAnxqOi9CvNc5UwzG1CWaQede03f1Bl6MhZqxz5l0Jot97BKBRH5nc3hLCETyO52qr1LqL4wjxWm5Akd/UMaJfOzdjpUs8xvYyXp8k//RcjA7Mf01MMVdE3IjyxyfvZyMLIVEIuoarGcZJhqOgY14bJITqO8VSd/AqobZy6T2UPUbi5RSH0op9EeW5igiguVAWZ50YxKvhRoZJ4MC/maCr56iKN5GEgi139EYHVailDpqYHMgKYpir5S6a5FIvQGYIuL9B3jjXapFYnUpOgiCIAC2mpcT872+lJ4Ab1hkqfQRuHslIB9wNHa+BYHrHAToOprKJuacJSgPLH+M1HmRtLkDdkqp95aU+tqb09tthcC5No/moeLcybKpMO5KmZbPydLON3HwzagSflQD9BIid/BI4gD2OpaA2DIbBan+8qC9sD5cOxD4FADZWAJir72kkAjE8sxN4FEGF0WRT4xAVtl1/X6sCQCZlpH6wDtHYHbpIFDVUskA+HUSUEqd9eKrB/xqCVQkNmb+X4SAy8fhmEYnEbDGJanKavDCBPoPWJSnsIvk2BvlAbr3RAaEssZPYx6blN2BK2obGFGX/bBf/EsLrm7SlL3J5k73ZMGmVS9MT5Qt8T0rulGhLHViyso3sZ20uvbif1kiKl5tuFSqI/WH+Gq78HUR4dytc7CRS86fLwo078YQQ5HFXKtLEOq3NMP53lVaNpPIcs4Fy0YB9S70LNdXpgGqjW5g3AvNlvgd+DUwb6vZmHT72aY8rtY+WgN4YI5+fh3cFPUNynqz8inUt//V7OpWAnwHNuZvH/IPPeDD9c6V9FUAAAAASUVORK5CYII=" width="24" height="24"><span>' . __( 'GDPR', 'cookie-notice' ) . '</span></label>
<label for="cn_laws_ccpa"><input id="cn_laws_ccpa" type="checkbox" name="cn_laws" value="ccpa" title="' . __( 'CCPA', 'cookie-notice' ) . '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAwCAYAAACScGMWAAACPElEQVRYheXYvXHbMBTAcY7AEbSA79Smskp30QiqkyLaQPQE8Qb2BtEG4QZil3Ry5ZZaAO/vAqANIwSJD1LmXXD3ToVE8sf3hEcQRVEUBXADfE+Mu2LOAVSkj/q/xj0sGVcvEgeUGTAvDlgBP4CD+Vyl4HaZuNa9WRH5JSK4oZT6CZQxuN+ZOBzYqQ9mxSkYmAuzcUqpyoE0InIUkWcng1UoLresWFlrOwCwczLa2EAispczWzvcxs5YzzXWDm4bistpwk1RfCypr2yppc3BVUvDXYAtsO7OsSRcbY5bAbfArYicrYu36Ob7Fj297wx8Ncf7JwewScGJSD3S00LjOJa9p0/E1SHlDQWm4rqmHI+LAKbgGsx/y23IMbiQVUos7g2G04yjcOYEObga2InIxQNrc3FjK2MvDtP7DOQYAIvGlcBzYub+WRKNwOJw5oRDvW8Ih4icImDxOHNiX3nHcF0GDwGwZJyvvCG4aZuwB9i31lsMbu/DAXsD9IZS6kEpVQ0FoQvPHlxfaU/jR15peGbuGf3mlhqHKYF95c0dj1MCY5ZV1wUy/uT4dOB2BtykwDmyNw0QOM6EyweS9547L/AKOID7VNwcLcUdf1Jxa3T27MjaDOoZL0m4AXRJ3uZ3Pg69p9fy/pxssVYW6GdxbrvJwjXoUnZh40oTFXrT53q4EXiNtYltkCkTaDoc71v734B9z/ex7WdSXHfxzcBvYsbfKXHlECwAd0H/JZ7MjX6ZDBcy0DPYBmyHbugVe8KbbhsHbZ0AAAAASUVORK5CYII=" width="24" height="24"><span>' . __( 'CCPA', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div id="cn_naming" class="cn-field cn-field-radio">
<label class="cn-asterix">' . __( 'Select a naming style for the consent choices', 'cookie-notice' ) . ':</label>
<div class="cn-radio-wrapper">
<label for="cn_naming_1"><input id="cn_naming_1" type="radio" name="cn_naming" value="1" checked><span>' . __( 'Silver, Gold, Platinum (Default)', 'cookie-notice' ) . '</span></label>
<label for="cn_naming_2"><input id="cn_naming_2" type="radio" name="cn_naming" value="2"><span>' . __( 'Private, Balanced, Personalized', 'cookie-notice' ) . '</span></label>
<label for="cn_naming_3"><input id="cn_naming_3" type="radio" name="cn_naming" value="3"><span>' . __( 'Reject All, Accept Some, Accept All', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div class="cn-field cn-field-checkbox">
<label>' . __( 'Select additional information to include in the banner:', 'cookie-notice' ) . '</label>
<div class="cn-checkbox-wrapper">
<label for="cn_privacy_paper"><input id="cn_privacy_paper" type="checkbox" name="cn_privacy_paper" value="1"><span>' . __( 'Display <b>Privacy Paper</b> to provide helpful data privacy and consent information to visitors.', 'cookie-notice' ) . '</span></label>
<label for="cn_privacy_contact"><input id="cn_privacy_contact" type="checkbox" name="cn_privacy_contact" value="1"><span>' . __( 'Display <b>Privacy Contact</b> to provide Data Controller contact information and links to external data privacy resources.', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div class="cn-small">* ' . __( 'available for Cookie Compliance&trade; Pro plans only', 'cookie-notice' ) . '</div>
</div>
</div>
<div class="cn-accordion-item cn-form-container cn-collapsed" tabindex="-1">
<div class="cn-accordion-header cn-form-header"><button class="cn-accordion-button" type="button">' . __( 'Banner Design', 'cookie-notice' ) . '</button></div>
<div class="cn-accordion-collapse cn-form">
<div class="cn-form-feedback cn-hidden"></div>
<div class="cn-field cn-field-radio-image">
<label>' . __( 'Select your preferred display position', 'cookie-notice' ) . ':</label>
<div class="cn-radio-image-wrapper">
<label for="cn_position_bottom"><input id="cn_position_bottom" type="radio" name="cn_position" value="bottom" title="' . __( 'Bottom', 'cookie-notice' ) . '" checked><img src="' . plugins_url( '../img/layout-bottom.png', __FILE__ ) . '" width="24" height="24"></label>
<label for="cn_position_top"><input id="cn_position_top" type="radio" name="cn_position" value="top" title="' . __( 'Top', 'cookie-notice' ) . '"><img src="' . plugins_url( '../img/layout-top.png', __FILE__ ) . '" width="24" height="24"></label>
<label for="cn_position_left"><input id="cn_position_left" type="radio" name="cn_position" value="left" title="' . __( 'Left', 'cookie-notice' ) . '"><img src="' . plugins_url( '../img/layout-left.png', __FILE__ ) . '" width="24" height="24"></label>
<label for="cn_position_right"><input id="cn_position_right" type="radio" name="cn_position" value="right" title="' . __( 'Right', 'cookie-notice' ) . '"><img src="' . plugins_url( '../img/layout-right.png', __FILE__ ) . '" width="24" height="24"></label>
<label for="cn_position_center"><input id="cn_position_center" type="radio" name="cn_position" value="center" title="' . __( 'Center', 'cookie-notice' ) . '"><img src="' . plugins_url( '../img/layout-center.png', __FILE__ ) . '" width="24" height="24"></label>
</div>
</div>
<div class="cn-field cn-fieldset">
<label>' . __( 'Adjust the banner color scheme', 'cookie-notice' ) . ':</label>
<div class="cn-checkbox-wrapper cn-color-picker-wrapper">
<label for="cn_color_primary"><input id="cn_color_primary" class="cn-color-picker" type="checkbox" name="cn_color_primary" value="#20c19e"><span>' . __( 'Color of the buttons and interactive elements.', 'cookie-notice' ) . '</span></label>
<label for="cn_color_background"><input id="cn_color_background" class="cn-color-picker" type="checkbox" name="cn_color_background" value="#ffffff"><span>' . __( 'Color of the banner background.', 'cookie-notice' ) . '</span></label>
<label for="cn_color_text"><input id="cn_color_text" class="cn-color-picker" type="checkbox" name="cn_color_text" value="#434f58"><span>' . __( 'Color of the body text.', 'cookie-notice' ) . '</span></label>
<label for="cn_color_border"><input id="cn_color_border" class="cn-color-picker" type="checkbox" name="cn_color_border" value="#5e6a74"><span class="cn-asterix">' . __( 'Color of the borders and inactive elements.', 'cookie-notice' ) . '</span></label>
<label for="cn_color_heading"><input id="cn_color_heading" class="cn-color-picker" type="checkbox" name="cn_color_heading" value="#434f58"><span class="cn-asterix">' . __( 'Color of the heading text.', 'cookie-notice' ) . '</span></label>
<label for="cn_color_button_text"><input id="cn_color_button_text" class="cn-color-picker" type="checkbox" name="cn_color_button_text" value="#ffffff"><span class="cn-asterix">' . __( 'Color of the button text.', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div class="cn-small">* ' . __( 'available for Cookie Compliance&trade; Pro plans only', 'cookie-notice' ) . '</div>
</div>
</div>
</div>
<div class="cn-field cn-field-submit cn-nav">
<button type="button" class="cn-btn cn-screen-button" data-screen="3"><span class="cn-spinner"></span>' . __( 'Apply Setup', 'cookie-notice' ) . '</button>
</div>';
$html .= wp_nonce_field( 'cn_api_configure', 'cn_nonce', true, false );
$html .= '
</form>
</div>';
} elseif ( $screen === 'register' ) {
$html .= '
<div class="cn-sidebar cn-sidebar-left has-loader">
<div class="cn-inner">
<div class="cn-header">
<div class="cn-top-bar">
<div class="cn-logo"><img src="' . plugins_url( '../img/cookie-notice-logo.png', __FILE__ ) . '" alt="Cookie Notice logo" /></div>
</div>
</div>
<div class="cn-body">
<h2>' . __( 'Compliance account', 'cookie-notice' ) . '</h2>
<div class="cn-lead">
<p>' . __( 'Create a Cookie Compliance&trade; account and select your preferred plan.', 'cookie-notice' ) . '</p>
</div>
<div class="cn-accordion">
<div id="cn-accordion-account" class="cn-accordion-item cn-form-container" tabindex="-1">
<div class="cn-accordion-header cn-form-header"><button class="cn-accordion-button" type="button">1. ' . __( 'Create Account', 'cookie-notice' ) . '</button></div>
<div class="cn-accordion-collapse">
<form class="cn-form" action="" data-action="register">
<div class="cn-form-feedback cn-hidden"></div>
<div class="cn-field cn-field-text">
<input type="text" name="email" value="" tabindex="1" placeholder="' . __( 'Email address', 'cookie-notice' ) . '">
</div>
<div class="cn-field cn-field-text">
<input type="password" name="pass" value="" tabindex="2" autocomplete="off" placeholder="' . __( 'Password', 'cookie-notice' ) . '">
</div>
<div class="cn-field cn-field-text">
<input type="password" name="pass2" value="" tabindex="3" autocomplete="off" placeholder="' . __( 'Confirm Password', 'cookie-notice' ) . '">
</div>
<div class="cn-field cn-field-checkbox">
<div class="cn-checkbox-wrapper">
<label for="cn_terms"><input id="cn_terms" type="checkbox" name="terms" value="1"><span>' . sprintf( __( 'I have read and agree to the <a href="%s" target="_blank">Terms of Service', 'cookie-notice' ), 'https://hu-manity.co/cookiecompliance-terms/' ) . '</a></span></label>
</div>
</div>
<div class="cn-field cn-field-submit cn-nav">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" data-screen="4"><span class="cn-spinner"></span>' . __( 'Sign Up', 'cookie-notice' ) . '</button>
</div>';
// get site language
$locale = get_locale();
$locale_code = explode( '_', $locale );
$html .= '
<input type="hidden" name="language" value="' . esc_attr( $locale_code[0] ) . '" />';
$html .= wp_nonce_field( 'cn_api_register', 'cn_nonce', true, false );
$html .= '
</form>
<p>' . __( 'Already have an account?', 'cookie-notice' ) . ' <a href="#" class="cn-screen-button" data-screen="login">' . __( 'Sign in', 'cookie-notice' ). '</a></p>
</div>
</div>';
$html .= '
<div id="cn-accordion-billing" class="cn-accordion-item cn-form-container cn-collapsed cn-disabled" tabindex="-1">
<div class="cn-accordion-header cn-form-header">
<button class="cn-accordion-button" type="button">2. ' . __( 'Select Plan', 'cookie-notice' ) . '</button>
</div>
<form class="cn-accordion-collapse cn-form cn-form-disabled" action="" data-action="payment">
<div class="cn-form-feedback cn-hidden"></div>
<div class="cn-field cn-field-radio">
<div class="cn-radio-wrapper cn-plan-wrapper">
<label for="cn_field_plan_free"><input id="cn_field_plan_free" type="radio" name="plan" value="free" checked><span><span class="cn-plan-description">' . __( 'Basic', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">Free</span></span><span class="cn-plan-overlay"></span></span></label>
<label for="cn_field_plan_monthly"><input id="cn_field_plan_monthly" type="radio" name="plan" value="monthly"><span><span class="cn-plan-description">' . __( '<b>Professional</b> Monthly', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">$14.50</span>' . __( '/mo', 'cookie-notice' ) . '</span><span class="cn-plan-overlay"></span></span></label>
<label for="cn_field_plan_yearly"><input id="cn_field_plan_yearly" type="radio" name="plan" value="yearly"><span><span class="cn-plan-description">' . __( '<b>Professional</b> Yearly', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">$149.50</span>' . __( '/yr', 'cookie-notice' ) . '</span><span class="cn-plan-overlay"></span></span></label>
</div>
</div>
<div class="cn-field cn-fieldset" id="cn_submit_free">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" data-screen="4"><span class="cn-spinner"></span>' . __( 'Confirm', 'cookie-notice' ) . '</button>
</div>
<div class="cn-field cn-fieldset cn-hidden" id="cn_submit_paid">
<div class="cn-field cn-field-radio">
<label>' . __( 'Payment Method', 'cookie-notice' ) . '</label>
<div class="cn-radio-wrapper cn-horizontal-wrapper">
<label for="cn_field_method_credit_card"><input id="cn_field_method_credit_card" type="radio" name="method" value="credit_card" checked><span>' . __( 'Credit Card', 'cookie-notice' ) . '</span></label>
<label for="cn_field_method_paypal"><input id="cn_field_method_paypal" type="radio" name="method" value="paypal"><span>' . __( 'PayPal', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div class="cn-fieldset" id="cn_payment_method_credit_card">
<input type="hidden" name="payment_nonce" value="" />
<div class="cn-field cn-field-text">
<label for="cn_card_number">' . __( 'Card Number', 'cookie-notice' ) . '</label>
<div id="cn_card_number"></div>
</div>
<div class="cn-field cn-field-text cn-field-half cn-field-first">
<label for="cn_expiration_date">' . __( 'Expiration Date', 'cookie-notice' ) . '</label>
<div id="cn_expiration_date"></div>
</div>
<div class="cn-field cn-field-text cn-field-half cn-field-last">
<label for="cn_cvv">' . __( 'CVC/CVV', 'cookie-notice' ) . '</label>
<div id="cn_cvv"></div>
</div>
<div class="cn-field cn-field-submit cn-nav">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" data-screen="4"><span class="cn-spinner"></span>' . __( 'Submit', 'cookie-notice' ) . '</button>
</div>
</div>
<div class="cn-fieldset" id="cn_payment_method_paypal" style="display: none;">
<div id="cn_paypal_button"></div>
</div>
</div>';
$html .= wp_nonce_field( 'cn_api_payment', 'cn_payment_nonce', true, false );
$html .= '
</form>
</div>';
$html .= '
</div>
</div>';
} elseif ( $screen === 'login' ) {
$html .= '
<div class="cn-sidebar cn-sidebar-left has-loader">
<div class="cn-inner">
<div class="cn-header">
<div class="cn-top-bar">
<div class="cn-logo"><img src="' . plugins_url( '../img/cookie-notice-logo.png', __FILE__ ) . '" alt="Cookie Notice logo" /></div>
</div>
</div>
<div class="cn-body">
<h2>' . __( 'Compliance Sign in', 'cookie-notice' ) . '</h2>
<div class="cn-lead">
<p>' . __( 'Sign in to your existing Cookie Compliance&trade; account and select your preferred plan.', 'cookie-notice' ) . '</p>
</div>
<div class="cn-accordion">
<div id="cn-accordion-account" class="cn-accordion-item cn-form-container" tabindex="-1">
<div class="cn-accordion-header cn-form-header"><button class="cn-accordion-button" type="button">1. ' . __( 'Account Login', 'cookie-notice' ) . '</button></div>
<div class="cn-accordion-collapse">
<form class="cn-form" action="" data-action="login">
<div class="cn-form-feedback cn-hidden"></div>
<div class="cn-field cn-field-text">
<input type="text" name="email" value="" tabindex="1" placeholder="' . __( 'Email address', 'cookie-notice' ) . '">
</div>
<div class="cn-field cn-field-text">
<input type="password" name="pass" value="" tabindex="2" autocomplete="off" placeholder="' . __( 'Password', 'cookie-notice' ) . '">
</div>
<div class="cn-field cn-field-submit cn-nav">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" ' . /* data-screen="4" */ '><span class="cn-spinner"></span>' . __( 'Sign in', 'cookie-notice' ) . '</button>
</div>';
// get site language
$locale = get_locale();
$locale_code = explode( '_', $locale );
$html .= '
<input type="hidden" name="language" value="' . esc_attr( $locale_code[0] ) . '" />';
$html .= wp_nonce_field( 'cn_api_login', 'cn_nonce', true, false );
$html .= '
</form>
<p>' . __( 'Don\'t have an account yet?', 'cookie-notice' ) . ' <a href="#" class="cn-screen-button" data-screen="register">' . __( 'Sign up', 'cookie-notice' ) . '</a></p>
</div>
</div>';
$html .= '
<div id="cn-accordion-billing" class="cn-accordion-item cn-form-container cn-collapsed cn-disabled" tabindex="-1">
<div class="cn-accordion-header cn-form-header">
<button class="cn-accordion-button" type="button">2. ' . __( 'Select Plan', 'cookie-notice' ) . '</button>
</div>
<form class="cn-accordion-collapse cn-form cn-form-disabled" action="" data-action="payment">
<div class="cn-form-feedback cn-hidden"></div>
<div class="cn-field cn-field-radio">
<div class="cn-radio-wrapper cn-plan-wrapper">
<label for="cn_field_plan_free"><input id="cn_field_plan_free" type="radio" name="plan" value="free" checked><span><span class="cn-plan-description">' . __( 'Basic', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">Free</span></span><span class="cn-plan-overlay"></span></span></label>
<label for="cn_field_plan_monthly"><input id="cn_field_plan_monthly" type="radio" name="plan" value="monthly"><span><span class="cn-plan-description">' . __( '<b>Professional</b> Monthly', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">$14.50</span>' . __( '/mo', 'cookie-notice' ) . '</span><span class="cn-plan-overlay"></span></span></label>
<label for="cn_field_plan_yearly"><input id="cn_field_plan_yearly" type="radio" name="plan" value="yearly"><span><span class="cn-plan-description">' . __( '<b>Professional</b> Yearly', 'cookie-notice' ) . '</span><span class="cn-plan-pricing"><span class="cn-plan-price">$149.50</span>' . __( '/yr', 'cookie-notice' ) . '</span><span class="cn-plan-overlay"></span></span></label>
</div>
</div>
<div class="cn-field cn-fieldset" id="cn_submit_free">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" data-screen="4"><span class="cn-spinner"></span>' . __( 'Confirm', 'cookie-notice' ) . '</button>
</div>
<div class="cn-field cn-fieldset cn-hidden" id="cn_submit_paid">
<div class="cn-field cn-field-radio">
<label>' . __( 'Payment Method', 'cookie-notice' ) . '</label>
<div class="cn-radio-wrapper cn-horizontal-wrapper">
<label for="cn_field_method_credit_card"><input id="cn_field_method_credit_card" type="radio" name="method" value="credit_card" checked><span>' . __( 'Credit Card', 'cookie-notice' ) . '</span></label>
<label for="cn_field_method_paypal"><input id="cn_field_method_paypal" type="radio" name="method" value="paypal"><span>' . __( 'PayPal', 'cookie-notice' ) . '</span></label>
</div>
</div>
<div class="cn-fieldset" id="cn_payment_method_credit_card">
<input type="hidden" name="payment_nonce" value="" />
<div class="cn-field cn-field-text">
<label for="cn_card_number">' . __( 'Card Number', 'cookie-notice' ) . '</label>
<div id="cn_card_number"></div>
</div>
<div class="cn-field cn-field-text cn-field-half cn-field-first">
<label for="cn_expiration_date">' . __( 'Expiration Date', 'cookie-notice' ) . '</label>
<div id="cn_expiration_date"></div>
</div>
<div class="cn-field cn-field-text cn-field-half cn-field-last">
<label for="cn_cvv">' . __( 'CVC/CVV', 'cookie-notice' ) . '</label>
<div id="cn_cvv"></div>
</div>
<div class="cn-field cn-field-submit cn-nav">
<button type="submit" class="cn-btn cn-screen-button" tabindex="4" data-screen="4"><span class="cn-spinner"></span>' . __( 'Submit', 'cookie-notice' ) . '</button>
</div>
</div>
<div class="cn-fieldset" id="cn_payment_method_paypal" style="display: none;">
<div id="cn_paypal_button"></div>
</div>
</div>';
$html .= wp_nonce_field( 'cn_api_payment', 'cn_payment_nonce', true, false );
$html .= '
</form>
</div>
</div>
</div>';
} elseif ( $screen === 'success' ) {
$html .= '
<div class="cn-sidebar cn-sidebar-left has-loader">
<div class="cn-inner">
<div class="cn-header">
<div class="cn-top-bar">
<div class="cn-logo"><img src="' . plugins_url( '../img/cookie-notice-logo.png', __FILE__ ) . '" alt="Cookie Notice logo" /></div>
</div>
</div>
<div class="cn-body">
<h2>' . __( 'Success!', 'cookie-notice' ) . '</h2>
<div class="cn-lead"><p><b>' . __( 'You have successfully upgraded your website to Cookie Compliance&trade;', 'cookie-notice' ) . '</b></p><p>' . sprintf( __( 'Go to Cookie Compliance&trade; application now. Or access it anytime from your <a href="%s">Cookie Notice settings page</a>.', 'cookie-notice' ), esc_url( admin_url( 'admin.php?page=cookie-notice' ) ) ) . '</p></div>
</div>';
}
$html .= '
<div class="cn-footer">';
/*
switch ( $screen ) {
case 'about':
$html .= '<a href="' . esc_url( admin_url( 'admin.php?page=cookie-notice' ) ) . '" class="cn-btn cn-btn-link cn-skip-button">' . __( 'Skip Live Setup', 'cookie-notice' ) . '</a>';
break;
case 'success':
$html .= '<a href="' . esc_url( get_dashboard_url() ) . '" class="cn-btn cn-btn-link cn-skip-button">' . __( 'WordPress Dashboard', 'cookie-notice' ) . '</a>';
break;
default:
$html .= '<a href="' . esc_url( admin_url( 'admin.php?page=cookie-notice' ) ) . '" class="cn-btn cn-btn-link cn-skip-button">' . __( 'Skip for now', 'cookie-notice' ) . '</a>';
break;
}
*/
$html .= '
</div>
</div>
</div>';
}
if ( $echo )
echo $html;
else
return $html;
if ( $is_ajax )
exit();
}
}