public function start()
 {
     global $current_user;
     wp_get_current_user();
     // By default, users to skip:
     // * Super admins (Automattic employees visiting your site)
     // * Users who don't have /wp-admin/ access
     $is_privileged_user = !is_proxied_automattician() && current_user_can('edit_posts');
     if (false === apply_filters('ndn_run_for_current_user', $is_privileged_user)) {
         return;
     }
     // Set up the per-blog salt
     $salt = get_option('newdevicenotification_salt');
     if (!$salt) {
         $salt = wp_generate_password(64, true, true);
         add_option('newdevicenotification_salt', $salt);
     }
     $this->cookie_hash = hash_hmac('md5', $current_user->ID, $salt);
     // Seen this device before?
     if ($this->verify_cookie()) {
         return;
     }
     // Attempt to mark this device as seen via a cookie
     $this->set_cookie();
     // Maybe we've seen this user+IP+agent before but they don't accept cookies?
     $memcached_key = 'lastseen_' . $current_user->ID . '_' . md5($_SERVER['REMOTE_ADDR'] . '|' . $_SERVER['HTTP_USER_AGENT']);
     if (wp_cache_get($memcached_key, 'newdevicenotification')) {
         return;
     }
     // As a backup to the cookie, record this IP address (only in memcached for now, proper logging will come later)
     wp_cache_set($memcached_key, time(), 'newdevicenotification');
     add_filter('ndn_send_email', array($this, 'maybe_send_email'), 10, 2);
     $this->notify_of_new_device();
 }
 private function can_purge_cache()
 {
     if (!function_exists('is_proxied_automattician')) {
         // Local environment; no purging necessary here
         return false;
     }
     return is_proxied_automattician();
 }