<!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>[8014] sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php: WordCamp Misc: Apply coding standards.</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/8014">8014</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/8014","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>2018-12-26 20:21:12 +0000 (Wed, 26 Dec 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 Misc: Apply coding standards.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginswcorgmiscphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<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 2018-12-26 20:21:08 UTC (rev 8013)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php 2018-12-26 20:21:12 UTC (rev 8014)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,7 +25,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_theme_directory( WP_CONTENT_DIR . '/themes-private' );
</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">-/*
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Include pages in the list of posts types that can have comments closed automatically
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_close_comments_for_post_types( $post_types ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,7 +47,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_enforce_public_blog_option( $value ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $private_sites = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 206, // testing.wordcamp.org
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 206, // testing.wordcamp.org.
</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"> if ( in_array( get_current_blog_id(), $private_sites, true ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,8 +60,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'pre_update_option_blog_public', 'wcorg_enforce_public_blog_option' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*
- * We want to let organizers use shortcodes inside Text widgets
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * We want to let organizers use shortcodes inside Text widgets.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'widget_text', 'do_shortcode' );
</span><span class="cx" style="display: block; padding: 0 10px"> // todo can remove this after ugprade to 4.9
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,11 +100,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_disable_network_activated_plugins_on_sites( $plugins ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * central.wordcamp.org, plan.wordcamp.org
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * These are plugins for individual WordCamp sites, so they aren't relevant for Central and Plan.
</span><span class="cx" style="display: block; padding: 0 10px"> * They clutter the admin menu and slow down page loads.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( in_array( get_current_blog_id(), array( BLOG_ID_CURRENT_SITE, 63 ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( in_array( get_current_blog_id(), array( BLOG_ID_CURRENT_SITE, 63 ), true ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $plugins['camptix-extras/camptix-extras.php'] );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $plugins['camptix-network-tools/camptix-network-tools.php'] );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $plugins['tagregator/bootstrap.php'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,7 +140,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_menu', 'wcorg_remove_admin_menu_pages_on_sites', 11 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Show Tagregator's log to network admins
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_show_tagregator_log() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,11 +172,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Redirects from /year/month/day/slug/ to /slug/ for new URL formats.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_subdomactories_redirect() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_404() )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_404() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( get_option( 'permalink_structure' ) != '/%postname%/' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( get_option( 'permalink_structure' ) !== '/%postname%/' ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // russia.wordcamp.org/2014/2014/11/25/post-name/
</span><span class="cx" style="display: block; padding: 0 10px"> // russia.wordcamp.org/2014/11/25/post-name/
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,8 +185,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // russia.wordcamp.org/2014/2014/25/post-name/
</span><span class="cx" style="display: block; padding: 0 10px"> // russia.wordcamp.org/2015-ru/...
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! preg_match( '#^/[0-9]{4}(?:-[^/]+)?/(?:[0-9]{4}/[0-9]{2}|[0-9]{2}|[0-9]{4})/[0-9]{2}/(.+)$#', $_SERVER['REQUEST_URI'], $matches ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! preg_match( '#^/[0-9]{4}(?:-[^/]+)?/(?:[0-9]{4}/[0-9]{2}|[0-9]{2}|[0-9]{4})/[0-9]{2}/(.+)$#', $_SERVER['REQUEST_URI'], $matches ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_safe_redirect( esc_url_raw( set_url_scheme( home_url( $matches[1] ) ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> die();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,7 +216,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'body_class', 'wcorg_content_slugs_to_body_tag' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
</ins><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><span class="cx" style="display: block; padding: 0 10px"> * See WordCamp_CLI_Rewrite_Rules::flush() for an explanation.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -228,7 +231,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'You are not authorized to flush the rewrite rules.' );
</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_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
</del><ins style="background-color: #dfd; text-decoration:none; 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.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_ajax_nopriv_wcorg_flush_rewrite_rules_everywhere', 'wcorg_flush_rewrite_rules' );
</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">@@ -241,41 +244,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> load_textdomain( 'wordcamporg', sprintf( '%s/languages/wordcamporg/wordcamporg-%s.mo', WP_CONTENT_DIR, get_user_locale() ) );
</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">-// WordCamp.org QBO Integration
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// WordCamp.org QBO Integration.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wordcamp_qbo_options', function( $options ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! defined( 'WORDCAMP_QBO_CONSUMER_KEY' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! defined( 'WORDCAMP_QBO_CONSUMER_KEY' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $options;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Secrets.
- $options['app_token'] = WORDCAMP_QBO_APP_TOKEN;
- $options['consumer_key'] = WORDCAMP_QBO_CONSUMER_KEY;
- $options['consumer_secret'] = WORDCAMP_QBO_CONSUMER_SECRET;
- $options['hmac_key'] = WORDCAMP_QBO_HMAC_KEY;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Secrets.
+ $options['app_token'] = WORDCAMP_QBO_APP_TOKEN;
+ $options['consumer_key'] = WORDCAMP_QBO_CONSUMER_KEY;
+ $options['consumer_secret'] = WORDCAMP_QBO_CONSUMER_SECRET;
+ $options['hmac_key'] = WORDCAMP_QBO_HMAC_KEY;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // WordCamp Payments to QBO categories mapping.
- $options['categories_map'] = array(
- 'after-party' => array( 'value' => 72, 'name' => 'After Party' ),
- 'audio-visual' => array( 'value' => 79, 'name' => 'Audio-Visual' ),
- 'food-beverages' => array( 'value' => 64, 'name' => 'Food & Beverage-WordCamps' ),
- 'office-supplies' => array( 'value' => 70, 'name' => 'Office Expense' ),
- 'signage-badges' => array( 'value' => 73, 'name' => 'Printing/Signage/Badges' ),
- 'speaker-event' => array( 'value' => 76, 'name' => 'Speaker Events' ),
- 'swag' => array( 'value' => 74, 'name' => 'Swag' ),
- 'venue' => array( 'value' => 78, 'name' => 'Venue Rental' ),
- 'other' => array( 'value' => 71, 'name' => 'Other Miscellaneous Expense' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // WordCamp Payments to QBO categories mapping.
+ $options['categories_map'] = array(
+ 'after-party' => array( 'value' => 72, 'name' => 'After Party' ),
+ 'audio-visual' => array( 'value' => 79, 'name' => 'Audio-Visual' ),
+ 'food-beverages' => array( 'value' => 64, 'name' => 'Food & Beverage-WordCamps' ),
+ 'office-supplies' => array( 'value' => 70, 'name' => 'Office Expense' ),
+ 'signage-badges' => array( 'value' => 73, 'name' => 'Printing/Signage/Badges' ),
+ 'speaker-event' => array( 'value' => 76, 'name' => 'Speaker Events' ),
+ 'swag' => array( 'value' => 74, 'name' => 'Swag' ),
+ 'venue' => array( 'value' => 78, 'name' => 'Venue Rental' ),
+ 'other' => array( 'value' => 71, 'name' => 'Other Miscellaneous Expense' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $options;
-});
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $options;
+} );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wordcamp_qbo_client_options', function( $options ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! defined( 'WORDCAMP_QBO_HMAC_KEY' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! defined( 'WORDCAMP_QBO_HMAC_KEY' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $options;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $options['hmac_key'] = WORDCAMP_QBO_HMAC_KEY;
- $options['api_base'] = 'https://central.wordcamp.org/wp-json/wordcamp-qbo/v1';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options['hmac_key'] = WORDCAMP_QBO_HMAC_KEY;
+ $options['api_base'] = 'https://central.wordcamp.org/wp-json/wordcamp-qbo/v1';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $options;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $options;
</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"> // Sponsorship payments (Stripe) credentials.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -283,13 +288,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $environment = ( defined('WORDCAMP_ENVIRONMENT') ) ? WORDCAMP_ENVIRONMENT : 'development';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $environment ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'production' :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'production':
</ins><span class="cx" style="display: block; padding: 0 10px"> $options['publishable'] = WORDCAMP_PAYMENT_STRIPE_PUBLISHABLE_LIVE;
</span><span class="cx" style="display: block; padding: 0 10px"> $options['secret'] = WORDCAMP_PAYMENT_STRIPE_SECRET_LIVE;
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'development':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- default :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ default:
</ins><span class="cx" style="display: block; padding: 0 10px"> $options['publishable'] = ( defined( 'WORDCAMP_PAYMENT_STRIPE_PUBLISHABLE' ) ) ? WORDCAMP_PAYMENT_STRIPE_PUBLISHABLE : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $options['secret'] = ( defined( 'WORDCAMP_PAYMENT_STRIPE_SECRET' ) ) ? WORDCAMP_PAYMENT_STRIPE_SECRET : '';
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,21 +305,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $options;
</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">-// Google Maps API
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Google Maps API.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wordcamp_google_maps_api_key', function( $key, $scope = 'client' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $environment = ( defined('WORDCAMP_ENVIRONMENT') ) ? WORDCAMP_ENVIRONMENT : 'development';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $environment ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'production' :
- if ( $scope === 'client' && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_API_KEY' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'production':
+ if ( 'client' === $scope && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_API_KEY' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = WORDCAMP_PROD_GOOGLE_MAPS_API_KEY;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( $scope === 'server' && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_SERVER_API_KEY') ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( 'server' === $scope && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_SERVER_API_KEY') ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = WORDCAMP_PROD_GOOGLE_MAPS_SERVER_API_KEY;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'development':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- default :
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ default:
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'WORDCAMP_DEV_GOOGLE_MAPS_API_KEY' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $key = WORDCAMP_DEV_GOOGLE_MAPS_API_KEY;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,7 +329,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $key;
</span><span class="cx" style="display: block; padding: 0 10px"> }, 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Disable admin pointers
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_disable_admin_pointers() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,7 +337,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_init', 'wcorg_disable_admin_pointers' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// Prevent password resets, since they need to be done on w.org
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Prevent password resets, since they need to be done on w.org.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'allow_password_reset', '__return_false' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'show_password_fields', '__return_false' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -377,6 +382,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Conditionally omit incident report submission feedback posts from post query results.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_Query $wp_query
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @return WP_Query
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_central_omit_incident_reports( $wp_query ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_query instanceof WP_Query ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,9 +392,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_types = $wp_query->get( 'post_type' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( BLOG_ID_CURRENT_SITE == get_current_blog_id()
- && in_array( 'feedback', (array) $post_types, true )
- && ! current_user_can( 'manage_network' ) // TODO add a subrole for this.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( BLOG_ID_CURRENT_SITE === get_current_blog_id()
+ && in_array( 'feedback', (array) $post_types, true )
+ && ! current_user_can( 'manage_network' ) // TODO add a subrole for this.
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_query = $wp_query->get( 'meta_query', array() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -399,7 +406,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'NOT LIKE',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> // This catches non-feedback posts, but may cause a performance issue.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // See https://developer.wordpress.org/reference/classes/wp_query/#comment-2315
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // See https://developer.wordpress.org/reference/classes/wp_query/#comment-2315.
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => '_feedback_email',
</span><span class="cx" style="display: block; padding: 0 10px"> 'value' => 'NOT EXISTS',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -411,7 +418,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $wp_query;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'pre_get_posts', 'wcorg_central_omit_incident_reports' );
</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">@@ -424,18 +430,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $primitive_caps The original list of primitive caps mapped to the given meta cap.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $meta_cap The meta cap in question.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @return array
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wcorg_central_modify_export_caps( $primitive_caps, $meta_cap ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( BLOG_ID_CURRENT_SITE == get_current_blog_id() && 'export' === $meta_cap ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( BLOG_ID_CURRENT_SITE === get_current_blog_id() && 'export' === $meta_cap ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array_merge( (array) $primitive_caps, array( 'manage_network' ) ); // TODO add a subrole for this.
</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"> return $primitive_caps;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'map_meta_cap', 'wcorg_central_modify_export_caps', 10, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check and create filesystem dirs to manage rate limiting in error handling.
</span><span class="cx" style="display: block; padding: 0 10px"> * For legacy bugs we are doing rate limiting via filesystem. We would be investigating to see if we can instead use memcache to rate limit sometime in the future.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -483,39 +489,39 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'last_reported_at' => time(),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'error_count' => 0, // since last reported.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'error_count' => 0, // since last reported.
</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"> if ( ! file_exists( $error_file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $text = 'Error occured. ';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- file_put_contents( $error_file, json_encode( $data ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ file_put_contents( $error_file, wp_json_encode( $data ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data = json_decode( file_get_contents( $error_file ), true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = json_decode( file_get_contents( $error_file ), true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $data['error_count'] += 1;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $time_elasped = time() - $data['last_reported_at'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $time_elasped = time() - $data['last_reported_at'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $time_elasped > 600 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $text = "Still happening. Happened ${data['error_count']} time(s) since last reported. ";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $text = "Still happening. Happened ${data['error_count']} time(s) since last reported. ";
</ins><span class="cx" style="display: block; padding: 0 10px"> $data['last_reported_at'] = time();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data['error_count'] = 0;
- file_put_contents( $error_file, json_encode( $data ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data['error_count'] = 0;
+
+ file_put_contents( $error_file, wp_json_encode( $data ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- file_put_contents( $error_file, json_encode( $data ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ file_put_contents( $error_file, wp_json_encode( $data ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</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">- $domain = get_site_url();
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $domain = get_site_url();
</ins><span class="cx" style="display: block; padding: 0 10px"> $page_slug = esc_html( trim( $_SERVER['REQUEST_URI'], '/' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $text = $text . "Message : \"$err_msg\" occured on \"$file:$line\" \n Domain: $domain \n Page: $page_slug \n Error type: $err_no";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $text = $text . "Message : \"$err_msg\" occured on \"$file:$line\" \n Domain: $domain \n Page: $page_slug \n Error type: $err_no";
-
</del><span class="cx" style="display: block; padding: 0 10px"> $message = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'fallback' => $text,
- 'color' => '#ff0000',
- 'pretext' => "Error on \"$file:$line\" ",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'fallback' => $text,
+ 'color' => '#ff0000',
+ 'pretext' => "Error on \"$file:$line\" ",
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => $domain,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'text' => $text,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'text' => $text,
</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"> $send = new \Dotorg\Slack\Send( SLACK_ERROR_REPORT_URL );
</span></span></pre>
</div>
</div>
</body>
</html>