<!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>[4316] sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator: CampTix Badge Generator: Move attendee data functionality to `common.php`</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 { 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/4316">4316</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/4316","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iandunn</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-11-01 20:58:43 +0000 (Tue, 01 Nov 2016)</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'>CampTix Badge Generator: Move attendee data functionality to `common.php`

This makes it accessible by both the HTML module and the InDesign module.

See <a href="http://meta.trac.wordpress.org/ticket/262">#262</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorbootstrapphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/bootstrap.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorincludescommonphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/common.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorincludeshtmlbadgesphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/html-badges.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorviewshtmlbadgestemplatebadgesphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-badges.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorviewsindesignbadgespageindesignbadgesphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorbootstrapphp"></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/plugins/camptix-badge-generator/bootstrap.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/plugins/camptix-badge-generator/bootstrap.php     2016-11-01 20:58:38 UTC (rev 4315)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/bootstrap.php       2016-11-01 20:58:43 UTC (rev 4316)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,9 +14,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> const REQUIRED_CAPABILITY = 'manage_options';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require_once( __DIR__ . '/includes/common.php'      );
+require_once( __DIR__ . '/includes/html-badges.php' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_admin() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        require_once( __DIR__ . '/includes/common.php'          );
</del><span class="cx" style="display: block; padding: 0 10px">         require_once( __DIR__ . '/includes/indesign-badges.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-require_once( __DIR__ . '/includes/html-badges.php' );
</del></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorincludescommonphp"></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/plugins/camptix-badge-generator/includes/common.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/plugins/camptix-badge-generator/includes/common.php       2016-11-01 20:58:38 UTC (rev 4315)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/common.php 2016-11-01 20:58:43 UTC (rev 4316)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,10 +5,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_filter( 'camptix_menu_tools_tabs',   __NAMESPACE__ . '\add_badges_tab'     );
-add_action( 'camptix_menu_tools_badges', __NAMESPACE__ . '\render_badges_page' );
-add_action( 'admin_print_styles',        __NAMESPACE__ . '\print_admin_styles' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+if ( is_admin() ) {
+       add_filter( 'camptix_menu_tools_tabs',   __NAMESPACE__ . '\add_badges_tab'     );
+       add_action( 'camptix_menu_tools_badges', __NAMESPACE__ . '\render_badges_page' );
+       add_action( 'admin_print_styles',        __NAMESPACE__ . '\print_admin_styles' );
+}
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'get_post_metadata', __NAMESPACE__ . '\add_dynamic_post_meta', 10, 3 );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Add the Generate Badges tab to the CampTix Tools page
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,3 +61,97 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Get the attendees
+ *
+ * @return array
+ */
+function get_attendees() {
+       $attendees = get_posts( array(
+               'post_type'      => 'tix_attendee',
+               'posts_per_page' => 12000,
+               'orderby'        => 'title',
+       ) );
+
+       return $attendees;
+}
+
+/**
+ * Add dynamically-generated "post meta" to `\WP_Post` objects
+ *
+ * This makes it possible to access dynamic data related to a post object by simply referencing `$post->foo`.
+ * That keeps the calling code much cleaner than if it were to have to do something like
+ * `$foo = some_custom_logic( get_post_meta( $post->ID, 'bar', true ) ); echo esc_html( $foo )`.
+ *
+ * @param mixed  $value
+ * @param int    $post_id
+ * @param string $meta_key
+ *
+ * @return mixed
+ *      `null` to instruct `get_metadata()` to pull the value from the database
+ *      Any non-null value will be returned as if it were pulled from the database
+ */
+function add_dynamic_post_meta( $value, $post_id, $meta_key ) {
+       /** @global \CampTix_Plugin $camptix */
+       global $camptix;
+
+       $attendee = get_post( $post_id );
+
+       if ( 'tix_attendee' != $attendee->post_type ) {
+               return $value;
+       }
+
+       switch ( $meta_key ) {
+               case 'avatar_url':
+                       $value = get_avatar_url( $attendee->tix_email, array( 'size' => 600 ) );
+                       break;
+
+               case 'coupon':
+                       if ( $attendee->tix_coupon_id ) {
+                               $coupon = get_post( $attendee->tix_coupon_id );
+                               $value  = $coupon->post_name;
+                       }
+                       break;
+
+               case 'css_classes':
+                       $value = get_css_classes( $attendee );
+                       break;
+
+               case 'formatted_name':
+                       $value = $camptix->format_name_string(
+                               '<span class="first-name">%first%</span>
+                                <span class="last-name">%last%</span>',
+                               $attendee->tix_first_name,
+                               $attendee->tix_last_name
+                       );
+                       break;
+
+               case 'ticket':
+                       $ticket = get_post( $attendee->tix_ticket_id );
+                       $value  = $ticket->post_name;
+                       break;
+       }
+
+       return $value;
+}
+
+/**
+ * Get the CSS classes for an attendee element
+ *
+ * @param \WP_Post $attendee
+ *
+ * @return string
+ */
+function get_css_classes( $attendee ) {
+       $classes = array(
+               'attendee-' . $attendee->post_name,
+               'ticket-'   . $attendee->ticket
+       );
+
+       if ( $attendee->coupon ) {
+               $classes[] = 'coupon-' . $attendee->coupon;
+       }
+
+       return implode( ' ', $classes );
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorincludeshtmlbadgesphp"></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/plugins/camptix-badge-generator/includes/html-badges.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/plugins/camptix-badge-generator/includes/html-badges.php  2016-11-01 20:58:38 UTC (rev 4315)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/html-badges.php    2016-11-01 20:58:43 UTC (rev 4316)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,7 +11,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts',    __NAMESPACE__ . '\remove_all_previewer_styles', 998 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts',    __NAMESPACE__ . '\enqueue_previewer_scripts',   999 );  // after remove_all_previewer_styles()
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'template_include',      __NAMESPACE__ . '\use_badges_template'              );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_filter( 'get_post_metadata',     __NAMESPACE__ . '\add_dynamic_post_meta', 10, 3     );
</del><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">  * Register our Customizer settings, panels, sections, and controls
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -214,87 +213,12 @@
</span><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $attendees = get_posts( array(
-               'post_type'      => 'tix_attendee',
-               'posts_per_page' => -1,
-               'orderby'        => 'title',
-       ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attendees = Badge_Generator\get_attendees();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        require( dirname( __DIR__ ) . '/views/html-badges/template-badges.php' );
</span><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Add dynamically-generated "post meta" to `\WP_Post` objects
- *
- * This makes it possible to access dynamic data related to a post object by simply referencing `$post->foo`.
- * That keeps the calling code much cleaner than if it were to have to do something like
- * `$foo = some_custom_logic( get_post_meta( $post->ID, 'bar', true ) ); echo esc_html( $foo )`.
- *
- * @param mixed  $value
- * @param int    $post_id
- * @param string $meta_key
- *
- * @return mixed
- *      `null` to instruct `get_metadata()` to pull the value from the database
- *      Any non-null value will be returned as if it were pulled from the database
- */
-function add_dynamic_post_meta( $value, $post_id, $meta_key ) {
-       /** @global \CampTix_Plugin $camptix */
-       global $camptix;
-
-       $attendee = get_post( $post_id );
-
-       if ( 'tix_attendee' != $attendee->post_type ) {
-               return $value;
-       }
-
-       switch ( $meta_key ) {
-               case 'avatar_url':
-                       $value = get_avatar_url( $attendee->tix_email, array( 'size' => 600 ) );
-                       break;
-
-               case 'css_classes':
-                       $value = get_css_classes( $attendee );
-                       break;
-
-               case 'formatted_name':
-                       $value = $camptix->format_name_string(
-                               '<span class="first-name">%first%</span>
-                                <span class="last-name">%last%</span>',
-                               $attendee->tix_first_name,
-                               $attendee->tix_last_name
-                       );
-                       break;
-       }
-
-       return $value;
-}
-
-/**
- * Get the CSS classes for an attendee element
- *
- * @param \WP_Post $attendee
- *
- * @return string
- */
-function get_css_classes( $attendee ) {
-       // Name
-       $classes = array( 'attendee-' . $attendee->post_name );
-
-       // Ticket
-       $ticket    = get_post( $attendee->tix_ticket_id );
-       $classes[] = 'ticket-' . $ticket->post_name;
-
-       // Coupon
-       if ( $attendee->tix_coupon_id ) {
-               $coupon    = get_post( $attendee->tix_coupon_id );
-               $classes[] = 'coupon-' . $coupon->post_name;
-       }
-
-       return implode( ' ', $classes );
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px">  * Remove all other styles from the Previewer, to avoid conflicts
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function remove_all_previewer_styles() {
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorviewshtmlbadgestemplatebadgesphp"></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/plugins/camptix-badge-generator/views/html-badges/template-badges.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/plugins/camptix-badge-generator/views/html-badges/template-badges.php     2016-11-01 20:58:38 UTC (rev 4315)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-badges.php       2016-11-01 20:58:43 UTC (rev 4316)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,6 +3,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace CampTix\Badge_Generator\HTML;
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @global string   $template
+ * @var    array    $attendees
+ * @var    \WP_Post $attendee
+ */
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px">  * template-loader.php includes this file in the global scope, which is ugly. So, include this again from a
</span><span class="cx" style="display: block; padding: 0 10px">  * function, so that we get a nice, clean, local scope.
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginscamptixbadgegeneratorviewsindesignbadgespageindesignbadgesphp"></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/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.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/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.php    2016-11-01 20:58:38 UTC (rev 4315)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.php      2016-11-01 20:58:43 UTC (rev 4316)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,6 +3,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> namespace CampTix\Badge_Generator\InDesign;
</span><span class="cx" style="display: block; padding: 0 10px"> defined( 'WPINC' ) or die();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * @var string $html_customizer_url
+ */
+
</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"> <h2>
</span></span></pre>
</div>
</div>

</body>
</html>