<!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>[2165] sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins: WordCamp WP-CLI: Centralize WP-CLI commands for consistency and organization.</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/2165">2165</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/2165","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>2015-12-05 17:33:32 +0000 (Sat, 05 Dec 2015)</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 WP-CLI: Centralize WP-CLI commands for consistency and organization.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswcorgjsonapiphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswcorgmiscphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsrestapiphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands/rest-api.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsrewriterulesphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands/rewrite-rules.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginswcorgjsonapiphp"></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/wcorg-json-api.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/wcorg-json-api.php     2015-12-05 17:08:40 UTC (rev 2164)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php       2015-12-05 17:33:32 UTC (rev 2165)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * is particularly important when it comes to areas where we're customizing the output, like post meta.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Before making any changes to this plugin or updating the JSON API to a new version, make sure you run the
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * automated tests -- wp wcorg-json-api verify-data-is-scrubbed -- in your sandbox, and then again on production
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * automated tests -- wp wc-rest verify-data-is-scrubbed -- in your sandbox, and then again on production
</ins><span class="cx" style="display: block; padding: 0 10px">  * after you deploy any updates.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * You may also need to add new tests when making changes to this or other plugins, and/or update existing tests.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -303,136 +303,3 @@
</span><span class="cx" style="display: block; padding: 0 10px">        remove_filter( 'json_prepare_post', array( $wp_json_media, 'add_thumbnail_data' ), 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_json_server_before_serve', 'wcorg_json_avoid_nested_callback_conflicts', 11 );    // after the default endpoints are added in `json_api_default_filters()`
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-
-/*
- * WP-CLI Commands
- */
-if ( defined( 'WP_CLI' ) && WP_CLI ) {
-       /**
-        * WordCamp.org JSON API
-        */
-       class WordCamp_JSON_API_Commands extends WP_CLI_Command {
-               /**
-                * Verify that no sensitive data is being exposed via the API.
-                *
-                * @subcommand verify-data-is-scrubbed
-                */
-               public function verify_data_is_scrubbed() {
-                       $errors          = false;
-                       $start_timestamp = microtime( true );
-
-                       // These calls are not formatted in a more compact way because we don't want to short-circuit any of them if one fails
-                       if ( $this->post_types_exposed() ) {
-                               $errors = true;
-                       }
-
-                       if ( $this->post_meta_exposed() ) {
-                               $errors = true;
-                       }
-
-                       WP_CLI::line();
-                       WP_CLI::line( sprintf( 'Tests completed in %s seconds', number_format( microtime( true ) - $start_timestamp, 3 ) ) );
-
-                       if ( $errors ) {
-                               WP_CLI::error( 'Not all sensitive data has been scrubbed.' );
-                       } else {
-                               WP_CLI::success( 'All of the tests passed. If the tests are comprehensive and working properly, then all sensitive data has been properly scrubbed.' );
-                       }
-               }
-
-               /**
-                * Check if any sensitive post types are being exposed.
-                *
-                * See note in post_meta_exposed() about test data.
-                *
-                * @return bool
-                */
-               protected function post_types_exposed() {
-                       $errors = false;
-
-                       WP_CLI::line();
-                       WP_CLI::line( 'Checking post types.' );
-
-                       // Check Central and a normal site, because they can have different types loaded
-                       $post_types_endpoints = array(
-                               'http://central.wordcamp.org/wp-json/posts/types',
-                               'http://europe.wordcamp.org/2014/wp-json/posts/types',
-                       );
-
-                       $whitelisted_post_types = array(
-                               'post', 'page', 'attachment', 'revision', 'wcb_speaker', 'wcb_session', 'wcb_sponsor', 'mes',
-                               'mes-sponsor-level', 'wordcamp'
-                       );
-
-                       foreach ( $post_types_endpoints as $request_url ) {
-                               $request_url = apply_filters( 'wcorg_json_api_verify_data_scrubbed_url', $request_url );    // Use this filter to override the URLs with corresponding endpoints on your sandbox
-                               $response    = json_decode( wp_remote_retrieve_body( wp_remote_get( $request_url ) ) );
-
-                               if ( empty( $response->post->slug ) ) {
-                                       $errors = true;
-                                       WP_CLI::warning( "Unable to retrieve post types from $request_url", false );
-                                       continue;
-                               }
-
-                               foreach ( $response as $post_type ) {
-                                       if ( in_array( $post_type->slug, $whitelisted_post_types ) ) {
-                                               WP_CLI::line( "{$post_type->slug} is whitelisted." );
-                                       } else {
-                                               $errors = true;
-                                               WP_CLI::warning( "{$post_type->slug} is being exposed at $request_url" );
-                                       }
-                               }
-                       }
-
-                       return $errors;
-               }
-
-               /**
-                * Check if any sensitive post meta is being exposed.
-                *
-                * If this were a proper test we'd insert the data into a test db during setup rather than relying on the
-                * existence of production data, but this is good enough for our current needs. Just make sure to double
-                * check that the meta where checking still exists, otherwise the tests could result in a false-negative.
-                *
-                * @return bool
-                */
-               protected function post_meta_exposed() {
-                       $errors = false;
-
-                       WP_CLI::line();
-                       WP_CLI::line( 'Checking post meta.' );
-
-                       // This is just a representative sample, not a complete list
-                       $sensitive_post_meta = array(
-                               'http://central.wordcamp.org/wp-json/posts/3038288'    => array( 'Email Address', 'Telephone', 'Mailing Address' ), // A wordcamp post on Central
-                               'http://central.wordcamp.org/wp-json/posts/2347409'    => array( 'mes_email_address' ),                             // A Multi-Event Sponsor post on Central
-                               'http://europe.wordcamp.org/2014/wp-json/posts/216283' => array( '_wcb_speaker_email' ),                            // A Speaker post on a camp site
-                       );
-
-                       foreach ( $sensitive_post_meta as $request_url => $sensitive_meta_keys ) {
-                               $request_url = apply_filters( 'wcorg_json_api_verify_data_scrubbed_url', $request_url );    // Use this filter to override the URLs with corresponding posts on your sandbox
-                               $response    = json_decode( wp_remote_retrieve_body( wp_remote_get( esc_url_raw( $request_url ) ) ) );
-
-                               if ( ! isset( $response->post_meta ) ) {
-                                       $errors = true;
-                                       WP_CLI::warning( "Unable to retrieve post meta from $request_url", false );
-                                       continue;
-                               }
-
-                               foreach ( $response->post_meta as $post_meta ) {
-                                       if ( in_array( $post_meta->key, $sensitive_meta_keys ) ) {
-                                               $errors = true;
-                                               WP_CLI::warning( "{$post_meta->key} is being exposed at $request_url" );
-                                       } else {
-                                               WP_CLI::line( "{$post_meta->key} is whitelisted." );
-                                       }
-                               }
-                       }
-
-                       return $errors;
-               }
-       }
-
-       WP_CLI::add_command( 'wcorg-json-api', 'WordCamp_JSON_API_Commands' );
-}
</del></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginswcorgmiscphp"></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/wcorg-misc.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/wcorg-misc.php 2015-12-05 17:08:40 UTC (rev 2164)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php   2015-12-05 17:33:32 UTC (rev 2165)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -178,7 +178,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px">  * Flush the rewrite rules on the current site.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * See WordCamp_Miscellaneous_Commands::flush_rewrite_rules_everywhere() for an explanation.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * See WordCamp_CLI_Rewrite_Rules::flush() for an explanation.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Requires authentication because flush_rewrite_rules() is expensive and could be used as a DoS vector.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,78 +192,3 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_wcorg_flush_rewrite_rules_everywhere',        'wcorg_flush_rewrite_rules' ); // This isn't used by the wp-cli command, but is useful for manual testing
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_nopriv_wcorg_flush_rewrite_rules_everywhere', 'wcorg_flush_rewrite_rules' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-
-/*
- * WP-CLI Commands
- */
-if ( defined( 'WP_CLI' ) && WP_CLI ) {
-       /**
-        * WordCamp.org Miscellaneous Commands
-        */
-       class WordCamp_Miscellaneous_Commands extends WP_CLI_Command {
-               /**
-                * Flush rewrite rules on all sites.
-                *
-                * Periodically they break for various reasons and need to be reset on all sites. If we
-                * just called flush_rewrite_rules() inside a switch_to_blog() loop then each site's
-                * plugins wouldn't be loaded and the rewrite rules wouldn't be correct.
-                *
-                * So instead, this issues an HTTP request to wcorg_flush_rewrite_rules() on each site so
-                * that flush_rewrite_rules() will run in the context of the loaded site.
-                *
-                * @subcommand flush-rewrite-rules-everywhere
-                */
-               public function flush_rewrite_rules_everywhere() {
-                       $start_timestamp = microtime( true );
-                       $error           = '';
-                       $sites           = wp_get_sites( array( 'limit' => false ) );
-
-                       WP_CLI::line();
-
-                       foreach ( $sites as $site ) {
-                               $ajax_url    = sprintf( 'http://%s%swp-admin/admin-ajax.php', $site['domain'], $site['path'] );
-                               $display_url = $site['domain'] . rtrim( $site['path'], '/' );
-                               $nonce       = wp_create_nonce( 'flush-rewrite-rules-everywhere-' . $site['blog_id'] );
-
-                               $response = wp_remote_get( esc_url_raw( add_query_arg(
-                                       array(
-                                               'action' => 'wcorg_flush_rewrite_rules_everywhere',
-                                               'nonce'  => $nonce,
-                                       ),
-                                       $ajax_url
-                               ) ) );
-
-                               if ( is_wp_error( $response ) ) {
-                                       $success = false;
-                                       $error   = $response->get_error_message();
-                               } else {
-                                       $response = json_decode( wp_remote_retrieve_body( $response ) );
-
-                                       if ( isset( $response->success ) && $response->success ) {
-                                               $success = true;
-                                       } else {
-                                               $success = false;
-                                               $error   = isset( $response->data ) ? $response->data : 'Unknown error';
-                                       }
-                               }
-
-                               if ( $success ) {
-                                       WP_CLI::line( sprintf( '%s: Flushed', $display_url ) );
-                               } else {
-                                       WP_CLI::warning( sprintf( '%s: Failed with error: %s', $display_url, $error     ) );
-                               }
-                       }
-                       $execution_time = microtime( true ) - $start_timestamp;
-
-                       WP_CLI::line();
-                       WP_CLI::line( sprintf(
-                               'Flushed all rewrite rules in %d minute(s) and %d second(s).',
-                               floor( $execution_time / 60 ),
-                               $execution_time % 60
-                       ) );
-               }
-       }
-
-       WP_CLI::add_command( 'wcorg-misc', 'WordCamp_Miscellaneous_Commands' );
-}
</del></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsrestapiphp"></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/wp-cli-commands/rest-api.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/wp-cli-commands/rest-api.php                           (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands/rest-api.php     2015-12-05 17:33:32 UTC (rev 2165)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,128 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WP_CLI' ) or die();
+
+/**
+ * Test REST API customizations.
+ */
+class WordCamp_CLI_REST_API extends WP_CLI_Command {
+       /**
+        * Verify that no sensitive data is being exposed via the API.
+        *
+        * @subcommand verify-data-is-scrubbed
+        */
+       public function verify_data_is_scrubbed() {
+               $errors          = false;
+               $start_timestamp = microtime( true );
+
+               // These calls are not formatted in a more compact way because we don't want to short-circuit any of them if one fails
+               if ( $this->post_types_exposed() ) {
+                       $errors = true;
+               }
+
+               if ( $this->post_meta_exposed() ) {
+                       $errors = true;
+               }
+
+               WP_CLI::line();
+               WP_CLI::line( sprintf( 'Tests completed in %s seconds', number_format( microtime( true ) - $start_timestamp, 3 ) ) );
+
+               if ( $errors ) {
+                       WP_CLI::error( 'Not all sensitive data has been scrubbed.' );
+               } else {
+                       WP_CLI::success( 'All of the tests passed. If the tests are comprehensive and working properly, then all sensitive data has been properly scrubbed.' );
+               }
+       }
+
+       /**
+        * Check if any sensitive post types are being exposed.
+        *
+        * See note in post_meta_exposed() about test data.
+        *
+        * @return bool
+        */
+       protected function post_types_exposed() {
+               $errors = false;
+
+               WP_CLI::line();
+               WP_CLI::line( 'Checking post types.' );
+
+               // Check Central and a normal site, because they can have different types loaded
+               $post_types_endpoints = array(
+                       'http://central.wordcamp.org/wp-json/posts/types',
+                       'http://europe.wordcamp.org/2014/wp-json/posts/types',
+               );
+
+               $whitelisted_post_types = array(
+                       'post', 'page', 'attachment', 'revision', 'wcb_speaker', 'wcb_session', 'wcb_sponsor', 'mes',
+                       'mes-sponsor-level', 'wordcamp'
+               );
+
+               foreach ( $post_types_endpoints as $request_url ) {
+                       $request_url = apply_filters( 'wcorg_json_api_verify_data_scrubbed_url', $request_url );    // Use this filter to override the URLs with corresponding endpoints on your sandbox
+                       $response    = json_decode( wp_remote_retrieve_body( wp_remote_get( $request_url ) ) );
+
+                       if ( empty( $response->post->slug ) ) {
+                               $errors = true;
+                               WP_CLI::warning( "Unable to retrieve post types from $request_url", false );
+                               continue;
+                       }
+
+                       foreach ( $response as $post_type ) {
+                               if ( in_array( $post_type->slug, $whitelisted_post_types ) ) {
+                                       WP_CLI::line( "{$post_type->slug} is whitelisted." );
+                               } else {
+                                       $errors = true;
+                                       WP_CLI::warning( "{$post_type->slug} is being exposed at $request_url" );
+                               }
+                       }
+               }
+
+               return $errors;
+       }
+
+       /**
+        * Check if any sensitive post meta is being exposed.
+        *
+        * If this were a proper test we'd insert the data into a test db during setup rather than relying on the
+        * existence of production data, but this is good enough for our current needs. Just make sure to double
+        * check that the meta where checking still exists, otherwise the tests could result in a false-negative.
+        *
+        * @return bool
+        */
+       protected function post_meta_exposed() {
+               $errors = false;
+
+               WP_CLI::line();
+               WP_CLI::line( 'Checking post meta.' );
+
+               // This is just a representative sample, not a complete list
+               $sensitive_post_meta = array(
+                       'http://central.wordcamp.org/wp-json/posts/3038288'    => array( 'Email Address', 'Telephone', 'Mailing Address' ), // A wordcamp post on Central
+                       'http://central.wordcamp.org/wp-json/posts/2347409'    => array( 'mes_email_address' ),                             // A Multi-Event Sponsor post on Central
+                       'http://europe.wordcamp.org/2014/wp-json/posts/216283' => array( '_wcb_speaker_email' ),                            // A Speaker post on a camp site
+               );
+
+               foreach ( $sensitive_post_meta as $request_url => $sensitive_meta_keys ) {
+                       $request_url = apply_filters( 'wcorg_json_api_verify_data_scrubbed_url', $request_url );    // Use this filter to override the URLs with corresponding posts on your sandbox
+                       $response    = json_decode( wp_remote_retrieve_body( wp_remote_get( esc_url_raw( $request_url ) ) ) );
+
+                       if ( ! isset( $response->post_meta ) ) {
+                               $errors = true;
+                               WP_CLI::warning( "Unable to retrieve post meta from $request_url", false );
+                               continue;
+                       }
+
+                       foreach ( $response->post_meta as $post_meta ) {
+                               if ( in_array( $post_meta->key, $sensitive_meta_keys ) ) {
+                                       $errors = true;
+                                       WP_CLI::warning( "{$post_meta->key} is being exposed at $request_url" );
+                               } else {
+                                       WP_CLI::line( "{$post_meta->key} is whitelisted." );
+                               }
+                       }
+               }
+
+               return $errors;
+       }
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsrewriterulesphp"></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/wp-cli-commands/rewrite-rules.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/wp-cli-commands/rewrite-rules.php                              (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands/rewrite-rules.php        2015-12-05 17:33:32 UTC (rev 2165)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,70 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+defined( 'WP_CLI' ) or die();
+
+/**
+ * Manage rewrite rules.
+ */
+class WordCamp_CLI_Rewrite_Rules extends WP_CLI_Command {
+       /**
+        * Flush rewrite rules on all sites.
+        *
+        * Periodically they break for various reasons and need to be reset on all sites. If we
+        * just called flush_rewrite_rules() inside a switch_to_blog() loop then each site's
+        * plugins wouldn't be loaded and the rewrite rules wouldn't be correct.
+        *
+        * So instead, this issues an HTTP request to wcorg_flush_rewrite_rules() on each site so
+        * that flush_rewrite_rules() will run in the context of the loaded site.
+        */
+       public function flush() {
+               $start_timestamp = microtime( true );
+               $error           = '';
+               $sites           = wp_get_sites( array( 'limit' => false ) );
+
+               WP_CLI::line();
+
+               foreach ( $sites as $site ) {
+                       $nonce       = wp_create_nonce( 'flush-rewrite-rules-everywhere-' . $site['blog_id'] );
+                       $display_url = $site['domain'] . rtrim( $site['path'], '/' );
+                       $ajax_url    = sprintf( 'http://%s%swp-admin/admin-ajax.php', $site['domain'], $site['path'] );
+                       $ajax_url    = add_query_arg( array(
+                               'action' => 'wcorg_flush_rewrite_rules_everywhere',
+                               'nonce'  => $nonce,
+                               ),
+                               $ajax_url
+                       );
+
+                       $response = wp_remote_get( esc_url_raw( $ajax_url ) );
+
+                       if ( is_wp_error( $response ) ) {
+                               $success = false;
+                               $error   = $response->get_error_message();
+                       } else {
+                               $response = json_decode( wp_remote_retrieve_body( $response ) );
+
+                               if ( isset( $response->success ) && $response->success ) {
+                                       $success = true;
+                               } else {
+                                       $success = false;
+                                       $error   = isset( $response->data ) ? $response->data : 'Unknown error';
+
+                               }
+                       }
+
+                       if ( $success ) {
+                               WP_CLI::line( sprintf( '%s: Flushed', $display_url ) );
+                       } else {
+                               WP_CLI::warning( sprintf( '%s: Failed with error: %s', $display_url, $error ) );
+                       }
+               }
+
+               $execution_time = microtime( true ) - $start_timestamp;
+
+               WP_CLI::line();
+               WP_CLI::line( sprintf(
+                       'Flushed all rewrite rules in %d minute(s) and %d second(s).',
+                       floor( $execution_time / 60 ),
+                       $execution_time % 60
+               ) );
+       }
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginswpclicommandsphp"></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/wp-cli-commands.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/wp-cli-commands.php                            (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wp-cli-commands.php      2015-12-05 17:33:32 UTC (rev 2165)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,16 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
+       return;
+}
+
+$wp_cli_commands = glob( __DIR__ . '/wp-cli-commands/*.php' );
+
+if ( is_array( $wp_cli_commands ) ) {
+       foreach ( $wp_cli_commands as $command ) {
+               require_once( $command );
+       }
+}
+
+WP_CLI::add_command( 'wc-rewrite', 'WordCamp_CLI_Rewrite_Rules' );
+WP_CLI::add_command( 'wc-rest',    'WordCamp_CLI_REST_API'      );
</ins></span></pre>
</div>
</div>

</body>
</html>