<!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>[7873] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports: WordCamp Reports: Add a WordCamp Counts report</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/7873">7873</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/7873","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-11-19 20:57:27 +0000 (Mon, 19 Nov 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 Reports: Add a WordCamp Counts report

This report counts up various post types (speakers, sponsors, etc) for all
WordCamps within a given date range and outputs a total number and a unique
number for each post type.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsindexphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/index.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsclassesreportclasswordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewshtmlwordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewsreportwordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsclassesreportclasswordcampcountsphp"></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/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.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/wordcamp-reports/classes/report/class-wordcamp-counts.php                         (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php   2018-11-19 20:57:27 UTC (rev 7873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,471 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @package WordCamp\Reports
+ */
+
+namespace WordCamp\Reports\Report;
+defined( 'WPINC' ) || die();
+
+use Exception;
+use WP_Query;
+use function WordCamp\Reports\{get_views_dir_path};
+use WordCamp\Reports\Utility\Date_Range;
+use function WordCamp\Reports\Validation\{validate_date_range, validate_wordcamp_status, validate_wordcamp_id};
+use WordCamp_Loader;
+
+
+class WordCamp_Counts extends Base {
+       /**
+        * Report name.
+        *
+        * @var string
+        */
+       public static $name = 'WordCamp Counts';
+
+       /**
+        * Report slug.
+        *
+        * @var string
+        */
+       public static $slug = 'wordcamp-counts';
+
+       /**
+        * Report description.
+        *
+        * @var string
+        */
+       public static $description = 'Total and unique counts of various post types for all WordCamps occurring within a given date range.';
+
+       /**
+        * Report methodology.
+        *
+        * @var string
+        */
+       public static $methodology = "
+               <ol>
+                       <li>Retrieve a list of WordCamps that occur within the specified date range using the WordCamp Details report.</li>
+                       <li>Filter out WordCamps that don't have a value in their URL field (and thus don't have a website), and WordCamps that don't match the selected statuses, if applicable.</li>
+                       <li>
+                               For each remaining WordCamp, retrieve the following unique, cross-site identifiers:
+                               <ul>
+                                       <li>The email address of each published Attendee post</li>
+                                       <li>The WordPress.org user ID of each published Organizer post</li>
+                                       <li>The post ID of each published Session post</li>
+                                       <li>The email address of each published Speaker post</li>
+                                       <li>The website domain of each published Sponsor post</li>
+                               </ul>
+                       </li>
+                       <li>Generate a unique ID for any post that does not have the desired meta value.</li>
+                       <li>For each post type except Sessions, compile the posts from every WordCamp site into one array and then remove duplicates.</li>
+               </ol>
+       ";
+
+       /**
+        * Report group.
+        *
+        * @var string
+        */
+       public static $group = 'wordcamp';
+
+       /**
+        * The date range that defines the scope of the report data.
+        *
+        * @var null|Date_Range
+        */
+       public $range = null;
+
+       /**
+        * The statuses to filter for in the report.
+        *
+        * @var array
+        */
+       public $statuses = [];
+
+       /**
+        * Data fields that can be visible in a public context.
+        *
+        * @var array An associative array of key/default value pairs.
+        */
+       protected $public_data_fields = [
+               'ID'                      => 0,
+               'Name'                    => '',
+               'URL'                     => '',
+               'Start Date (YYYY-mm-dd)' => '',
+               'Status'                  => '',
+               'attendees'               => 0,
+               'organizers'              => 0,
+               'sessions'                => 0,
+               'speakers'                => 0,
+               'sponsors'                => 0,
+       ];
+
+       /**
+        * WordCamp_Counts constructor.
+        *
+        * @param string $start_date  The start of the date range for the report.
+        * @param string $end_date    The end of the date range for the report.
+        * @param array  $statuses    Optional. Status IDs to filter for in the report.
+        * @param array  $options    {
+        *     Optional. Additional report parameters.
+        *     See Base::__construct and Date_Range::__construct for additional parameters.
+        * }
+        */
+       public function __construct( $start_date, $end_date, array $statuses = [], array $options = [] ) {
+               parent::__construct( $options );
+
+               try {
+                       $this->range = validate_date_range( $start_date, $end_date, $options );
+               } catch ( Exception $e ) {
+                       $this->error->add(
+                               self::$slug . '-date-error',
+                               $e->getMessage()
+                       );
+               }
+
+               foreach ( $statuses as $status ) {
+                       try {
+                               $this->statuses[] = validate_wordcamp_status( $status, $options );
+                       } catch ( Exception $e ) {
+                               $this->error->add(
+                                       self::$slug . '-status-error',
+                                       $e->getMessage()
+                               );
+
+                               break;
+                       }
+               }
+       }
+
+       /**
+        * Generate a cache key.
+        *
+        * @return string
+        */
+       protected function get_cache_key() {
+               $cache_key_segments = [
+                       parent::get_cache_key(),
+                       $this->range->generate_cache_key_segment(),
+               ];
+
+               if ( ! empty( $this->statuses ) ) {
+                       $cache_key_segments[] = implode( '-', $this->statuses );
+               }
+
+               return implode( '_', $cache_key_segments );
+       }
+
+       /**
+        * Generate a cache expiration interval.
+        *
+        * @return int A time interval in seconds.
+        */
+       protected function get_cache_expiration() {
+               return $this->range->generate_cache_duration( parent::get_cache_expiration() );
+       }
+
+       /**
+        * Query and parse the data for the report.
+        *
+        * @return array
+        */
+       public function get_data() {
+               // Bail if there are errors.
+               if ( ! empty( $this->error->get_error_messages() ) ) {
+                       return [];
+               }
+
+               // Maybe use cached data.
+               $data = $this->maybe_get_cached_data();
+               if ( is_array( $data ) ) {
+                       return $data;
+               }
+
+               // @todo Maybe find a way to run this without having to hack the memory limit.
+               ini_set( 'memory_limit', '900M' );
+
+               $details_options = [
+                       'public' => false,
+               ];
+               $details_report = new WordCamp_Details( $this->range, [], false, $details_options );
+
+               if ( ! empty( $details_report->error->get_error_messages() ) ) {
+                       $this->error = $this->merge_errors( $this->error, $details_report->error );
+
+                       return [];
+               }
+
+               $wordcamps = array_filter( $details_report->get_data(), function( $wordcamp ) {
+                       // Skip camps with no website URL.
+                       if ( ! $wordcamp['URL'] ) {
+                               return false;
+                       }
+
+                       if ( ! empty( $this->statuses ) && ! in_array( $wordcamp['Status'], $this->statuses ) ) {
+                               return false;
+                       }
+
+                       return true;
+               } );
+
+               $wordcamps = array_reduce( $wordcamps, function( $carry, $item ) {
+                       $keep = [
+                               'ID'                      => '',
+                               'Name'                    => '',
+                               'URL'                     => '',
+                               'Start Date (YYYY-mm-dd)' => '',
+                               'Status'                  => '',
+                       ];
+
+                       $carry[ $item['ID'] ] = array_intersect_key( $item, $keep );
+
+                       return $carry;
+               }, [] );
+
+               $wordcamp_ids = array_keys( $wordcamps );
+
+               $data = [];
+
+               foreach ( $wordcamp_ids as $wordcamp_id ) {
+                       try {
+                               $valid = validate_wordcamp_id( $wordcamp_id );
+
+                               $data[ $wordcamp_id ] = array_merge(
+                                       $wordcamps[ $wordcamp_id ],
+                                       $this->get_data_for_site( $valid->site_id )
+                               );
+                       } catch ( Exception $e ) {
+                               $this->error->add(
+                                       self::$slug . '-wordcamp-id-error',
+                                       $e->getMessage()
+                               );
+
+                               break;
+                       }
+               }
+
+               $uniques = [
+                       'attendees'  => [],
+                       'organizers' => [],
+                       'speakers'   => [],
+                       'sponsors'   => [],
+               ];
+
+               $totals = [
+                       'attendees'  => 0,
+                       'organizers' => 0,
+                       'sessions'   => 0,
+                       'speakers'   => 0,
+                       'sponsors'   => 0,
+               ];
+
+               foreach ( $data as $id => &$event ) {
+                       foreach ( $totals as $key => $bucket ) {
+                               if ( isset( $uniques[ $key ] ) ) {
+                                       $uniques[ $key ] = array_unique( array_merge( $uniques[ $key ], $event[ $key ] ) );
+                               }
+
+                               $event[ $key ] = count( $event[ $key ] );
+
+                               $totals[ $key ] += $event[ $key ];
+                       }
+               }
+
+               $data['totals'] = $totals;
+
+               $data['uniques'] = array_map( function( $group ) {
+                       return count( $group );
+               }, $uniques );
+
+               $data = $this->filter_data_fields( $data );
+               $this->maybe_cache_data( $data );
+
+               return $data;
+       }
+
+       /**
+        * Compile the report data into results.
+        *
+        * @param array $data The data to compile.
+        *
+        * @return array
+        */
+       public function compile_report_data( array $data ) {
+               return $data;
+       }
+
+       /**
+        * Format the data for human-readable display.
+        *
+        * @param array $data The data to prepare.
+        *
+        * @return array
+        */
+       public function prepare_data_for_display( array $data ) {
+               $all_statuses = WordCamp_Loader::get_post_statuses();
+
+               array_walk( $data, function( &$row ) use ( $all_statuses ) {
+                       foreach ( $row as $key => $value ) {
+                               switch ( $key ) {
+                                       case 'Status':
+                                               $row[ $key ] = $all_statuses[ $value ];
+                                               break;
+                                       case 'Start Date (YYYY-mm-dd)':
+                                               $row[ $key ] = ( $value ) ? date( 'Y-m-d', $value ) : '';
+                                               break;
+                               }
+                       }
+               } );
+
+               return $data;
+       }
+
+       /**
+        * Retrieve all of the data for one site.
+        *
+        * @param int $site_id
+        *
+        * @return array
+        */
+       protected function get_data_for_site( $site_id ) {
+               $site_data = [
+                       'attendees'  => [],
+                       'organizers' => [],
+                       'sessions'   => [],
+                       'speakers'   => [],
+                       'sponsors'   => [],
+               ];
+
+               switch_to_blog( $site_id );
+
+               $attendees = new WP_Query( [
+                       'posts_per_page' => -1,
+                       'post_type'      => 'tix_attendee',
+                       'post_status'    => 'publish',
+               ] );
+
+               $site_data['attendees'] = wp_list_pluck( $attendees->posts, 'tix_email', 'ID' );
+
+               $organizers = new WP_Query( [
+                       'posts_per_page' => -1,
+                       'post_type'      => 'wcb_organizer',
+                       'post_status'    => 'publish',
+               ] );
+
+               $site_data['organizers'] = wp_list_pluck( $organizers->posts, '_wcpt_user_id', 'ID' );
+
+               $sessions = new WP_Query( [
+                       'posts_per_page' => - 1,
+                       'post_type'      => 'wcb_session',
+                       'post_status'    => 'publish',
+                       'meta_query'     => [
+                               [
+                                       'key'   => '_wcpt_session_type',
+                                       'value' => 'session',
+                               ]
+                       ],
+               ] );
+
+               $site_data['sessions'] = wp_list_pluck( $sessions->posts, 'ID' );
+
+               $speakers = new WP_Query( [
+                       'posts_per_page' => -1,
+                       'post_type'      => 'wcb_speaker',
+                       'post_status'    => 'publish',
+               ] );
+
+               $site_data['speakers'] = wp_list_pluck( $speakers->posts, '_wcb_speaker_email', 'ID' );
+
+               $sponsors = new WP_Query( [
+                       'posts_per_page' => -1,
+                       'post_type'      => 'wcb_sponsor',
+                       'post_status'    => 'publish',
+               ] );
+
+               $site_data['sponsors'] = array_map( function( $url ) {
+                       return preg_replace( '/^www\./', '', wp_parse_url( $url, PHP_URL_HOST ) );
+               }, wp_list_pluck( $sponsors->posts, '_wcpt_sponsor_website' ) );
+
+               restore_current_blog();
+
+               foreach ( $site_data as $type => &$data ) {
+                       if ( 'sessions' === $type ) {
+                               continue;
+                       }
+
+                       // Convert blanks to unique values.
+                       array_walk( $data, function( &$value, $key ) use ( $site_id ) {
+                               if ( ! $value ) {
+                                       $value = "{$site_id}_{$key}";
+                               }
+                       } );
+               }
+
+               return $site_data;
+       }
+
+       /**
+        * Render an HTML version of the report output.
+        *
+        * @return void
+        */
+       public function render_html() {
+               $data = $this->prepare_data_for_display( $this->get_data() );
+               $start_date = $this->range->start;
+               $end_date   = $this->range->end;
+               $statuses   = $this->statuses;
+
+               $uniques = array_pop( $data );
+               $totals  = array_pop( $data );
+
+               if ( ! empty( $this->error->get_error_messages() ) ) {
+                       $this->render_error_html();
+               } else {
+                       include get_views_dir_path() . 'html/wordcamp-counts.php';
+               }
+       }
+
+       /**
+        * Render the page for this report in the WP Admin.
+        *
+        * @return void
+        */
+       public static function render_admin_page() {
+               $start_date = filter_input( INPUT_POST, 'start-date' );
+               $end_date   = filter_input( INPUT_POST, 'end-date' );
+               $statuses   = filter_input( INPUT_POST, 'statuses', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ) ?: [];
+               $refresh    = filter_input( INPUT_POST, 'refresh', FILTER_VALIDATE_BOOLEAN );
+               $action     = filter_input( INPUT_POST, 'action' );
+               $nonce      = filter_input( INPUT_POST, self::$slug . '-nonce' );
+
+               $all_statuses = WordCamp_Loader::get_post_statuses();
+
+               $report = null;
+
+               if ( 'Show results' === $action
+                    && wp_verify_nonce( $nonce, 'run-report' )
+                    && current_user_can( 'manage_network' )
+               ) {
+                       $options = array(
+                               'public' => false,
+                       );
+
+                       if ( $refresh ) {
+                               $options['flush_cache'] = true;
+                       }
+
+                       $report = new self( $start_date, $end_date, $statuses, $options );
+               }
+
+               include get_views_dir_path() . 'report/wordcamp-counts.php';
+       }
+
+       /**
+        * Enqueue JS and CSS assets for this report's admin interface.
+        *
+        * @return void
+        */
+       public static function enqueue_admin_assets() {
+               wp_enqueue_script( 'select2' );
+               wp_enqueue_style( 'select2' );
+       }
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsindexphp"></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/wordcamp-reports/index.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/wordcamp-reports/index.php        2018-11-19 20:54:21 UTC (rev 7872)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/index.php  2018-11-19 20:57:27 UTC (rev 7873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,6 +137,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                __NAMESPACE__ . '\Report\WordCamp_Payment_Methods',
</span><span class="cx" style="display: block; padding: 0 10px">                __NAMESPACE__ . '\Report\Meetup_Status',
</span><span class="cx" style="display: block; padding: 0 10px">                __NAMESPACE__ . '\Report\Meetup_Details',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                __NAMESPACE__ . '\Report\WordCamp_Counts',
</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></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewshtmlwordcampcountsphp"></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/plugins/wordcamp-reports/views/html/wordcamp-counts.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/wordcamp-reports/views/html/wordcamp-counts.php                           (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php     2018-11-19 20:57:27 UTC (rev 7873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,102 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @package WordCamp\Reports
+ */
+
+namespace WordCamp\Reports\Views\HTML\WordCamp_Counts;
+defined( 'WPINC' ) || die();
+
+use DateTime;
+
+/** @var DateTime $start_date */
+/** @var DateTime $end_date */
+/** @var string $statuses */
+/** @var array $data */
+/** @var array $totals */
+/** @var array $uniques */
+?>
+
+<?php if ( count( $data ) ) : ?>
+       <h3 id="active-heading">
+               Numbers for WordCamps occurring
+               <?php if ( $start_date->format( 'Y-m-d' ) === $end_date->format( 'Y-m-d' ) ) : ?>
+                       on <?php echo esc_html( $start_date->format( 'M jS, Y' ) ); ?>
+               <?php else : ?>
+                       between <?php echo esc_html( $start_date->format( 'M jS, Y' ) ); ?> and <?php echo esc_html( $end_date->format( 'M jS, Y' ) ); ?>
+               <?php endif; ?>
+       </h3>
+
+       <table class="striped widefat but-not-too-wide">
+               <tr>
+                       <td>WordCamps</td>
+                       <td class="number total"><?php echo number_format_i18n( count( $data ) ); ?></td>
+               </tr>
+       </table>
+
+       <table class="striped widefat but-not-too-wide">
+               <tr>
+                       <td></td>
+                       <td>Totals</td>
+                       <td>Uniques</td>
+               </tr>
+               <tr>
+                       <td>Attendees</td>
+                       <td class="number"><?php echo number_format_i18n( $totals['attendees'] ); ?></td>
+                       <td class="number"><?php echo number_format_i18n( $uniques['attendees'] ); ?></td>
+               </tr>
+               <tr>
+                       <td>Organizers</td>
+                       <td class="number"><?php echo number_format_i18n( $totals['organizers'] ); ?></td>
+                       <td class="number"><?php echo number_format_i18n( $uniques['organizers'] ); ?></td>
+               </tr>
+               <tr>
+                       <td>Sessions</td>
+                       <td class="number"><?php echo number_format_i18n( $totals['sessions'] ); ?></td>
+                       <td class="number">n/a</td>
+               </tr>
+               <tr>
+                       <td>Speakers</td>
+                       <td class="number"><?php echo number_format_i18n( $totals['speakers'] ); ?></td>
+                       <td class="number"><?php echo number_format_i18n( $uniques['speakers'] ); ?></td>
+               </tr>
+               <tr>
+                       <td>Sponsors</td>
+                       <td class="number"><?php echo number_format_i18n( $totals['sponsors'] ); ?></td>
+                       <td class="number"><?php echo number_format_i18n( $uniques['sponsors'] ); ?></td>
+               </tr>
+       </table>
+
+       <table class="striped widefat but-not-too-wide">
+               <tr>
+                       <td>WordCamp</td>
+                       <td>Date</td>
+                       <td>Status</td>
+                       <td>Attendees</td>
+                       <td>Organizers</td>
+                       <td>Sessions</td>
+                       <td>Speakers</td>
+                       <td>Sponsors</td>
+               </tr>
+               <?php foreach ( $data as $event ) : ?>
+                       <tr>
+                               <td><a href="<?php echo esc_attr( $event['URL'] ); ?>"><?php echo esc_html( $event['Name'] ); ?></a></td>
+                               <td><?php echo esc_html( $event['Start Date (YYYY-mm-dd)'] ); ?></td>
+                               <td><?php echo esc_html( $event['Status'] ); ?></td>
+                               <td class="number"><?php echo number_format_i18n( $event['attendees'] ); ?></td>
+                               <td class="number"><?php echo number_format_i18n( $event['organizers'] ); ?></td>
+                               <td class="number"><?php echo number_format_i18n( $event['sessions'] ); ?></td>
+                               <td class="number"><?php echo number_format_i18n( $event['speakers'] ); ?></td>
+                               <td class="number"><?php echo number_format_i18n( $event['sponsors'] ); ?></td>
+                       </tr>
+               <?php endforeach; ?>
+       </table>
+<?php else : ?>
+       <p>
+               No data
+               <?php if ( $start_date->format( 'Y-m-d' ) === $end_date->format( 'Y-m-d' ) ) : ?>
+                       on <?php echo esc_html( $start_date->format( 'M jS, Y' ) ); ?>
+               <?php else : ?>
+                       between <?php echo esc_html( $start_date->format( 'M jS, Y' ) ); ?> and <?php echo esc_html( $end_date->format( 'M jS, Y' ) ); ?>
+               <?php endif; ?>
+       </p>
+<?php endif; ?>
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewsreportwordcampcountsphp"></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/plugins/wordcamp-reports/views/report/wordcamp-counts.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/wordcamp-reports/views/report/wordcamp-counts.php                         (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php   2018-11-19 20:57:27 UTC (rev 7873)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,77 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @package WordCamp\Reports
+ */
+
+namespace WordCamp\Reports\Views\Report\WordCamp_Counts;
+defined( 'WPINC' ) || die();
+
+use WordCamp\Reports;
+use WordCamp\Reports\Report;
+
+/** @var string $start_date */
+/** @var string $end_date */
+/** @var array  $statuses */
+/** @var array  $all_statuses */
+/** @var Report\WordCamp_Counts|null $report */
+?>
+
+<div class="wrap">
+       <h1>
+               <a href="<?php echo esc_attr( Reports\get_page_url() ); ?>">WordCamp Reports</a>
+               &raquo;
+               <?php echo esc_html( Report\WordCamp_Counts::$name ); ?>
+       </h1>
+
+       <?php echo wpautop( wp_kses_post( Report\WordCamp_Counts::$description ) ); ?>
+
+       <h4>Methodology</h4>
+
+       <?php echo wpautop( wp_kses_post( Report\WordCamp_Counts::$methodology ) ); ?>
+
+       <form method="post" action="">
+               <input type="hidden" name="action" value="run-report" />
+               <?php wp_nonce_field( 'run-report', Report\WordCamp_Counts::$slug . '-nonce' ); ?>
+
+               <table class="form-table">
+                       <tbody>
+                       <tr>
+                               <th scope="row"><label for="start-date">Start Date</label></th>
+                               <td><input type="date" id="start-date" name="start-date" value="<?php echo esc_attr( $start_date ) ?>" required /></td>
+                       </tr>
+                       <tr>
+                               <th scope="row"><label for="end-date">End Date</label></th>
+                               <td><input type="date" id="end-date" name="end-date" value="<?php echo esc_attr( $end_date ) ?>" required /></td>
+                       </tr>
+                       <tr>
+                               <th scope="row"><label for="statuses">Statuses (optional)</label></th>
+                               <td>
+                                       <select id="statuses" name="statuses[]" class="select2-container" multiple>
+                                               <?php foreach ( $all_statuses as $value => $label ) : ?>
+                                                       <option value="<?php echo esc_attr( $value ); ?>"<?php selected( in_array( $value, $statuses ) ); ?>><?php echo esc_attr( $label ); ?></option>
+                                               <?php endforeach; ?>
+                                       </select>
+                               </td>
+                       </tr>
+                       <tr>
+                               <th scope="row"><label for="refresh">Refresh results</label></th>
+                               <td><input type="checkbox" id="refresh" name="refresh" /></td>
+                       </tr>
+                       </tbody>
+               </table>
+
+               <?php submit_button( 'Show results', 'primary', 'action', false ); ?>
+       </form>
+
+       <?php if ( $report instanceof Report\WordCamp_Counts ) : ?>
+               <div class="report-results">
+                       <?php $report->render_html(); ?>
+               </div>
+       <?php endif; ?>
+</div>
+
+<script type="application/javascript">
+       jQuery( document ).ready( function() {
+               jQuery( '#statuses' ).select2();
+       } );
+</script>
</ins></span></pre>
</div>
</div>

</body>
</html>