<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[7228] sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks: WordCamp tickets: privacy enhancements</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/7228">7228</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/7228","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coreymckrill</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-05-24 21:33:14 +0000 (Thu, 24 May 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp tickets: privacy enhancements

* Include some custom registration fields in personal data export/erasure
* Add registration field to opt-out of the public Attendees page
* Show data confidentiality notice on Edit Attendee screen</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsaccommodationsphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsallergyphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/allergy.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonscodeofconductphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweakscamptixtweaksphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsprivacyphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/privacy.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsaccommodationsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php       2018-05-24 21:16:48 UTC (rev 7227)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php 2018-05-24 21:33:14 UTC (rev 7228)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,6 +48,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Metabox
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 12, 2 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // Privacy
+               add_filter( 'camptix_privacy_attendee_props_to_export', array( $this, 'attendee_props_to_export' ) );
+               add_filter( 'camptix_privacy_export_attendee_prop', array( $this, 'export_attendee_prop' ), 10, 4 );
+               add_filter( 'camptix_privacy_attendee_props_to_erase', array( $this, 'attendee_props_to_erase' ) );
+               add_action( 'camptix_privacy_erase_attendee_prop', array( $this, 'erase_attendee_prop' ), 10, 3 );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,6 +340,75 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function set_locale_to_en_US() {
</span><span class="cx" style="display: block; padding: 0 10px">                return 'en_US';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Include the new field in the personal data exporter.
+        *
+        * @param array $props
+        *
+        * @return array
+        */
+       public function attendee_props_to_export( $props ) {
+               $props[ 'tix_' . self::SLUG ] = $this->question;
+
+               return $props;
+       }
+
+       /**
+        * Add the new field's value and label to the aggregated personal data for export.
+        *
+        * @param array   $export
+        * @param string  $key
+        * @param string  $label
+        * @param WP_Post $post
+        *
+        * @return array
+        */
+       public function export_attendee_prop( $export, $key, $label, $post ) {
+               if ( 'tix_' . self::SLUG === $key ) {
+                       $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true );
+
+                       if ( isset( $this->options[ $value ] ) ) {
+                               $value = $this->options[ $value ];
+                       }
+
+                       if ( ! empty( $value ) ) {
+                               $export[] = array(
+                                       'name'  => $label,
+                                       'value' => $value,
+                               );
+                       }
+               }
+
+               return $export;
+       }
+
+       /**
+        * Include the new field in the personal data eraser.
+        *
+        * @param array $props
+        *
+        * @return array
+        */
+       public function attendee_props_to_erase( $props ) {
+               $props[ 'tix_' . self::SLUG ] = 'camptix_yesno';
+
+               return $props;
+       }
+
+       /**
+        * Anonymize the value of the new field during personal data erasure.
+        *
+        * @param string  $key
+        * @param string  $type
+        * @param WP_Post $post
+        */
+       public function erase_attendee_prop( $key, $type, $post ) {
+               if ( 'tix_' . self::SLUG === $key ) {
+                       $anonymized_value = wp_privacy_anonymize_data( $type );
+                       update_post_meta( $post->ID, $key, $anonymized_value );
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> camptix_register_addon( __NAMESPACE__ . '\Accommodations_Field' );
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsallergyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/allergy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/allergy.php      2018-05-24 21:16:48 UTC (rev 7227)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/allergy.php        2018-05-24 21:33:14 UTC (rev 7228)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,6 +46,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Metabox
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 11, 2 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // Privacy
+               add_filter( 'camptix_privacy_attendee_props_to_export', array( $this, 'attendee_props_to_export' ) );
+               add_filter( 'camptix_privacy_export_attendee_prop', array( $this, 'export_attendee_prop' ), 10, 4 );
+               add_filter( 'camptix_privacy_attendee_props_to_erase', array( $this, 'attendee_props_to_erase' ) );
+               add_action( 'camptix_privacy_erase_attendee_prop', array( $this, 'erase_attendee_prop' ), 10, 3 );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,6 +338,75 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function set_locale_to_en_US() {
</span><span class="cx" style="display: block; padding: 0 10px">                return 'en_US';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Include the new field in the personal data exporter.
+        *
+        * @param array $props
+        *
+        * @return array
+        */
+       public function attendee_props_to_export( $props ) {
+               $props[ 'tix_' . self::SLUG ] = $this->question;
+
+               return $props;
+       }
+
+       /**
+        * Add the new field's value and label to the aggregated personal data for export.
+        *
+        * @param array   $export
+        * @param string  $key
+        * @param string  $label
+        * @param WP_Post $post
+        *
+        * @return array
+        */
+       public function export_attendee_prop( $export, $key, $label, $post ) {
+               if ( 'tix_' . self::SLUG === $key ) {
+                       $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true );
+
+                       if ( isset( $this->options[ $value ] ) ) {
+                               $value = $this->options[ $value ];
+                       }
+
+                       if ( ! empty( $value ) ) {
+                               $export[] = array(
+                                       'name'  => $label,
+                                       'value' => $value,
+                               );
+                       }
+               }
+
+               return $export;
+       }
+
+       /**
+        * Include the new field in the personal data eraser.
+        *
+        * @param array $props
+        *
+        * @return array
+        */
+       public function attendee_props_to_erase( $props ) {
+               $props[ 'tix_' . self::SLUG ] = 'camptix_yesno';
+
+               return $props;
+       }
+
+       /**
+        * Anonymize the value of the new field during personal data erasure.
+        *
+        * @param string  $key
+        * @param string  $type
+        * @param WP_Post $post
+        */
+       public function erase_attendee_prop( $key, $type, $post ) {
+               if ( 'tix_' . self::SLUG === $key ) {
+                       $anonymized_value = wp_privacy_anonymize_data( $type );
+                       update_post_meta( $post->ID, $key, $anonymized_value );
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> camptix_register_addon( __NAMESPACE__ . '\Allergy_Field' );
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonscodeofconductphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php      2018-05-24 21:16:48 UTC (rev 7227)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php        2018-05-24 21:33:14 UTC (rev 7228)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,7 +54,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( $coc_url = $this->maybe_get_coc_url() ) :
</span><span class="cx" style="display: block; padding: 0 10px">                                        printf(
</span><span class="cx" style="display: block; padding: 0 10px">                                                /* translators: %s placeholder is a URL */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                wp_kses_post( __( 'Do you agree to follow the event <a href="%s">Code of Conduct</a>?', 'wordcamporg' ) ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         wp_kses_post( __( 'Do you agree to follow the event <a href="%s" target="_blank">Code of Conduct</a>?', 'wordcamporg' ) ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 esc_url( $coc_url )
</span><span class="cx" style="display: block; padding: 0 10px">                                        );
</span><span class="cx" style="display: block; padding: 0 10px">                                else :
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweaksaddonsprivacyphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/privacy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/privacy.php                              (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/privacy.php        2018-05-24 21:33:14 UTC (rev 7228)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,215 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordCamp\CampTix_Tweaks;
+defined( 'WPINC' ) or die();
+
+use CampTix_Plugin, CampTix_Addon;
+use WP_Post;
+
+/**
+ * Class Privacy_Field.
+ *
+ * Add an attendee checkbox field for opting into visibility on the public Attendees page.
+ *
+ * @package WordCamp\CampTix_Tweaks
+ */
+class Privacy_Field extends CampTix_Addon {
+       const SLUG = 'privacy';
+
+       public $question = '';
+
+       /**
+        * Hook into WordPress and Camptix.
+        */
+       public function camptix_init() {
+               if ( $attendees_url = $this->maybe_get_attendees_url() ) {
+                       $this->question = sprintf(
+                               /* translators: 1: placeholder for URL to Attendees page; 2: placeholder for URL to privacy policy page. */
+                               __( 'Do you want to be listed on the public <a href="%1$s" target="_blank">Attendees page</a>? <a href="%2$s" target="_blank">Learn more.</a>', 'wordcamporg' ),
+                               esc_url( $attendees_url ),
+                               esc_url( get_privacy_policy_url() )
+                       );
+               } else {
+                       $this->question = sprintf(
+                               /* translators: %s placeholder for URL to privacy policy page. */
+                               __( 'Do you want to be listed on the public Attendees page? <a href="%s" target="_blank">Learn more.</a>', 'wordcamporg' ),
+                               esc_url( get_privacy_policy_url() )
+                       );
+               }
+
+               // Registration field
+               add_action( 'camptix_attendee_form_after_questions', array( $this, 'render_registration_field' ), 10, 2 );
+               add_filter( 'camptix_checkout_attendee_info', array( $this, 'validate_registration_field' ) );
+               add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'populate_attendee_object' ), 10, 2 );
+               add_action( 'camptix_checkout_update_post_meta', array( $this, 'save_registration_field' ), 10, 2 );
+               add_action( 'camptix_ticket_emailed', array( $this, 'after_email_receipt' ) );
+
+               // Edit info field
+               add_filter( 'camptix_form_edit_attendee_ticket_info', array( $this, 'populate_ticket_info_array' ), 10, 2 );
+               add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'validate_save_ticket_info_field' ), 10, 2 );
+               add_action( 'camptix_form_edit_attendee_after_questions', array( $this, 'render_ticket_info_field' ), 10 );
+       }
+
+       /**
+        * Render the new field for the registration form during checkout.
+        *
+        * @param array $form_data
+        * @param int   $i
+        */
+       public function render_registration_field( $form_data, $i ) {
+               $current_data = ( isset( $form_data['tix_attendee_info'][ $i ] ) ) ?: array();
+
+               $current_data = wp_parse_args( $current_data, array(
+                       self::SLUG => true,
+               ) );
+
+               ?>
+
+               <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
+                       <td class="tix-left">
+                               <?php echo wp_kses_post( $this->question ); ?>
+                       </td>
+
+                       <td class="tix-right">
+                               <label><input name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][<?php echo esc_attr( self::SLUG ); ?>]" type="checkbox" <?php checked( $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html_x( 'Yes', 'ticket registration option', 'wordcamporg' ); ?></label>
+                       </td>
+               </tr>
+
+               <?php
+       }
+
+       /**
+        * Validate the value of the new field submitted to the registration form during checkout.
+        *
+        * @param array $data
+        *
+        * @return array
+        */
+       public function validate_registration_field( $data ) {
+               if ( ! isset( $data[ self::SLUG ] ) || empty( $data[ self::SLUG ] ) ) {
+                       $data[ self::SLUG ] = false;
+               } else {
+                       $data[ self::SLUG ] = true;
+               }
+
+               return $data;
+       }
+
+       /**
+        * Add the value of the new field to the attendee object during checkout processing.
+        *
+        * @param WP_Post $attendee
+        * @param array   $data
+        *
+        * @return WP_Post
+        */
+       public function populate_attendee_object( $attendee, $data ) {
+               $attendee->{ self::SLUG } = $data[ self::SLUG ];
+
+               return $attendee;
+       }
+
+       /**
+        * Save the value of the new field to the attendee post upon completion of checkout.
+        *
+        * @param int     $post_id
+        * @param WP_Post $attendee
+        *
+        * @return bool|int
+        */
+       public function save_registration_field( $post_id, $attendee ) {
+               if ( true === wp_validate_boolean( $attendee->{ self::SLUG } ) ) {
+                       $result = delete_post_meta( $post_id, 'tix_' . self::SLUG );
+               } else {
+                       $result = update_post_meta( $post_id, 'tix_' . self::SLUG, 'private' );
+               }
+
+               return $result;
+       }
+
+       /**
+        * Retrieve the stored value of the new field for use on the Edit Info form.
+        *
+        * @param array   $ticket_info
+        * @param WP_Post $attendee
+        *
+        * @return array
+        */
+       public function populate_ticket_info_array( $ticket_info, $attendee ) {
+               $raw_value = get_post_meta( $attendee->ID, 'tix_' . self::SLUG, true );
+
+               if ( 'private' === $raw_value ) {
+                       $ticket_info[ self::SLUG ] = false;
+               } else {
+                       $ticket_info[ self::SLUG ] = true;
+               }
+
+               return $ticket_info;
+       }
+
+       /**
+        * Update the stored value of the new field if it was changed in the Edit Info form.
+        *
+        * @param array   $data
+        * @param WP_Post $attendee
+        *
+        * @return bool|int
+        */
+       public function validate_save_ticket_info_field( $data, $attendee ) {
+               $data = $this->validate_registration_field( $data );
+
+               if ( true === wp_validate_boolean( $data[ self::SLUG ] ) ) {
+                       $result = delete_post_meta( $attendee->ID, 'tix_' . self::SLUG );
+               } else {
+                       $result = update_post_meta( $attendee->ID, 'tix_' . self::SLUG, 'private' );
+               }
+
+               return $result;
+       }
+
+       /**
+        * Render the new field for the Edit Info form.
+        *
+        * @param array $ticket_info
+        */
+       public function render_ticket_info_field( $ticket_info ) {
+               $current_data = $this->validate_registration_field( $ticket_info );
+
+               ?>
+
+               <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
+                       <td class="tix-left">
+                               <?php echo wp_kses_post( $this->question ); ?>
+                       </td>
+
+                       <td class="tix-right">
+                               <label><input name="tix_ticket_info[<?php echo esc_attr( self::SLUG ); ?>]" type="checkbox" <?php checked( $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html_x( 'Yes', 'ticket registration option', 'wordcamporg' ); ?></label>
+                       </td>
+               </tr>
+
+               <?php
+       }
+
+       /**
+        * If the Attendees page is still the same one created with the site, get its URL.
+        *
+        * @return false|string
+        */
+       protected function maybe_get_attendees_url() {
+               $url = '';
+
+               $attendees_page = get_posts( array(
+                       'post_type'   => 'page',
+                       'name'        => 'attendees',
+                       'numberposts' => 1,
+               ) );
+
+               if ( $attendees_page ) {
+                       $url = get_the_permalink( array_shift( $attendees_page ) );
+               }
+
+               return $url;
+       }
+}
+
+camptix_register_addon( __NAMESPACE__ . '\Privacy_Field' );
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginscamptixtweakscamptixtweaksphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php      2018-05-24 21:16:48 UTC (rev 7227)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php        2018-05-24 21:33:14 UTC (rev 7228)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,6 +23,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'camptix_name_order',                            __NAMESPACE__ . '\set_name_order'                      );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'camptix_form_edit_attendee_custom_error_flags', __NAMESPACE__ . '\disable_attendee_edits'              );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'transition_post_status',                        __NAMESPACE__ . '\log_publish_to_cancel',        10, 3 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'camptix_privacy_erase_attendee',                __NAMESPACE__ . '\retain_attendee_data',         10, 2 );
+add_action( 'admin_notices',                                 __NAMESPACE__ . '\admin_notice_attendee_privacy'       );
+add_filter( 'wp_privacy_personal_data_erasers',              __NAMESPACE__ . '\modify_erasers',                  99 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Miscellaneous
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'camptix_beta_features_enabled',                 '__return_true' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -554,6 +557,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        require_once( __DIR__ . '/addons/accommodations.php' );
</span><span class="cx" style="display: block; padding: 0 10px">        // Code of Conduct field
</span><span class="cx" style="display: block; padding: 0 10px">        require_once( __DIR__ . '/addons/code-of-conduct.php' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // Privacy field
+       require_once( __DIR__ . '/addons/privacy.php' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -564,7 +569,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function modify_default_fields_list( $default_fields ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return __( 'Top three fields: First name, last name, e-mail address.<br />Bottom three fields: Life-threatening allergy, accessibility needs, Code of Conduct agreement.', 'wordcamporg' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return __( 'Top three fields: First name, last name, e-mail address.<br />Bottom four fields: Attendee list opt-out, life-threatening allergy, accessibility needs, Code of Conduct agreement.', 'wordcamporg' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -943,3 +948,58 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        return $shortcode_contents;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Modify the list of personal data eraser callbacks.
+ *
+ * @param array $erasers
+ *
+ * @return array mixed
+ */
+function modify_erasers( $erasers ) {
+       // Temporarily disable the default eraser callbacks for CampTix.
+       unset( $erasers['camptix-attendee'] );
+
+       return $erasers;
+}
+
+/**
+ * Short-circuit the CampTix attendee data erasure callback if the attendee data is still within the retention period.
+ *
+ * @param bool|string $erase
+ * @param WP_Post     $post
+ *
+ * @return bool|string
+ */
+function retain_attendee_data( $erase, $post ) {
+       $created          = strtotime( get_the_date( 'c', $post ) );
+       $now              = time();
+       $retention_period = YEAR_IN_SECONDS * 3;
+
+       if ( ( $now - $created ) < $retention_period ) {
+               return __( 'Attendee data could not be anonymized because it is still within the data retention period.', 'wordcamporg' );
+       }
+
+       return $erase;
+}
+
+/**
+ * Add a notice about data confidentiality to the Edit Attendee screen.
+ */
+function admin_notice_attendee_privacy() {
+       $screen = get_current_screen();
+
+       if ( 'tix_attendee' === $screen->id ) {
+               $notice_classes = 'notice notice-info';
+               $message        = wp_kses_post( sprintf(
+                       __( 'The personal information displayed here is <strong>confidential</strong>, and should not be shown publicly, except under the circumstances described in the <a href="%s">privacy policy</a>.', 'wordcamporg' ),
+                       esc_url( get_privacy_policy_url() )
+               ) );
+
+               printf(
+                       '<div class="%1$s">%2$s</div>',
+                       esc_attr( $notice_classes ),
+                       wpautop( $message )
+               );
+       }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>