<!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>[1105] sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012: Central Theme: Replace sessions on the homepage with latest tweets.</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/1105">1105</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/1105","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-01-08 18:29:55 +0000 (Thu, 08 Jan 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'>Central Theme: Replace sessions on the homepage with latest tweets.
Props mj12982 for the design</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012functionsphp">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesiconssprite2xpng">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/icons-sprite-2x.png</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesiconsspritepng">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/icons-sprite.png</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012jscentraljs">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/js/central.js</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012stylecss">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/style.css</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012templatehomephp">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/template-home.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesspinner2xgif">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner-2x.gif</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesspinnergif">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner.gif</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagestwitteractionspng">sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/twitter-actions.png</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012functionsphp"></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/themes/wordcamp-central-2012/functions.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/themes/wordcamp-central-2012/functions.php 2015-01-08 18:13:42 UTC (rev 1104)
+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/functions.php 2015-01-08 18:29:55 UTC (rev 1105)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,6 +35,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', array( __CLASS__, 'process_forms' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'wp_ajax_get_latest_wordcamp_tweets', array( __CLASS__, 'get_latest_tweets' ) );
+ add_action( 'wp_ajax_nopriv_get_latest_wordcamp_tweets', array( __CLASS__, 'get_latest_tweets' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'excerpt_more', array( __CLASS__, 'excerpt_more' ), 11 );
</span><span class="cx" style="display: block; padding: 0 10px"> // add_filter( 'wcpt_register_post_type', array( __CLASS__, 'wcpt_register_post_type' ) ); // set to public in wcpt plugin
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -180,8 +182,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> static function enqueue_scripts() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( 'central', get_stylesheet_uri(), array(), 3 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_enqueue_script( 'wordcamp-central', get_stylesheet_directory_uri() . '/js/central.js', array(), '20140909', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script( 'wordcamp-central', get_stylesheet_directory_uri() . '/js/central.js', array( 'jquery', 'underscore' ), 1, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_localize_script( 'wordcamp-central', 'wordcampCentralOptions', array( 'ajaxURL' => admin_url( 'admin-ajax.php' ) ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* We add some JavaScript to pages with the comment form
</span><span class="cx" style="display: block; padding: 0 10px"> * to support sites with threaded comments (when in use).
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,6 +431,99 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Fetch the latest tweets from the @WordCamp account
+ *
+ * This is an AJAX callback returning JSON-formatted data.
+ *
+ * We're manually expiring/refreshing the transient to ensure that we only ever update it when we have a
+ * valid response from the API. If there is a problem retrieving new data from the API, then we want to
+ * continue displaying the valid cached data until we can successfully retrieve new data. The data is still
+ * stored in a transient instead of an option, though, so that it can be cached in memory.
+ *
+ * Under certain unlikely conditions, this could cause an API rate limit violation. If the data is expired
+ * and we can connect to the API at the network level, but then the request fails at the application level
+ * (invalid credentials, etc), then we'll be hitting the API every time this function is called. If that
+ * does ever happen, it could be fixed by setting the timestamp of the last attempt in a transient and only
+ * issuing another attempt if ~2 minutes have passed.
+ */
+ public static function get_latest_tweets() {
+ $transient_key = 'wcc_latest_tweets';
+ $tweets = get_transient( $transient_key );
+ $expired = $tweets['last_update'] < strtotime( 'now - 15 minutes' );
+
+ if ( ! $tweets || $expired ) {
+ $response = wp_remote_get(
+ 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=6&trim_user=true&exclude_replies=true&include_rts=false&screen_name=wordcamp',
+ array(
+ 'headers' => array( 'Authorization' => 'Bearer ' . TWITTER_BEARER_TOKEN_WORDCAMP_CENTRAL ),
+ )
+ );
+
+ if ( ! is_wp_error( $response ) ) {
+ $tweets['tweets'] = json_decode( wp_remote_retrieve_body( $response ) );
+
+ /*
+ * Remove all but the first 3 tweets
+ *
+ * The Twitter API includes retweets in the `count` parameter, even if include_rts=false is passed,
+ * so we have to request more tweets than we actually want and then cut it down here.
+ */
+ if ( $tweets['tweets'] ) {
+ $tweets['tweets'] = array_slice( $tweets['tweets'], 0, 3 );
+ $tweets['tweets'] = self::sanitize_format_tweets( $tweets['tweets'] );
+ $tweets['last_update'] = time();
+
+ set_transient( $transient_key, $tweets );
+ }
+ }
+ }
+
+ wp_send_json_success( $tweets );
+ }
+
+ /**
+ * Sanitize and format the tweet objects
+ *
+ * Whitelist the fields to cut down on how much data we're storing/transmitting, but also to force
+ * future devs to manually enable/sanitize any new fields that are used, which avoids the risk of
+ * accidentally using an unsafe value.
+ *
+ * @param array $tweets
+ *
+ * @return array
+ */
+ protected static function sanitize_format_tweets( $tweets ) {
+ $whitelisted_fields = array( 'id_str' => '', 'text' => '', 'created_at' => '' );
+
+ foreach ( $tweets as & $tweet ) {
+ $tweet = (object) shortcode_atts( $whitelisted_fields, $tweet );
+ $tweet->id_str = sanitize_text_field( $tweet->id_str );
+ $tweet->text = wp_kses( $tweet->text, wp_kses_allowed_html( 'data' ), array( 'http', 'https', 'mailto' ) );
+ $tweet->text = make_clickable( $tweet->text );
+ $tweet->text = self::link_hashtags_and_usernames( $tweet->text );
+ $tweet->time_ago = human_time_diff( strtotime( $tweet->created_at ) );
+ }
+
+ return $tweets;
+ }
+
+ /**
+ * Convert usernames and hashtags to links
+ *
+ * Based on Tagregator's TGGRSourceTwitter::link_hashtags_and_usernames().
+ *
+ * @param string $text
+ *
+ * @return string
+ */
+ protected static function link_hashtags_and_usernames( $content ) {
+ $content = preg_replace( '/@(\w+)/', '<a href="https://twitter.com/\\1" class="wc-tweets-username">@\\1</a>', $content );
+ $content = preg_replace( '/(?<!&)#(\w+)/', '<a href="https://twitter.com/search?q=\\1" class="wc-tweets-tag" >#\\1</a>', $content );
+
+ return $content;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Twenty Ten Comment
</span><span class="cx" style="display: block; padding: 0 10px"> * Overrides the twentyten_comment function in the parent theme.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesiconssprite2xpng"></a>
<div class="binary"><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/themes/wordcamp-central-2012/images/icons-sprite-2x.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesiconsspritepng"></a>
<div class="binary"><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/themes/wordcamp-central-2012/images/icons-sprite.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesspinner2xgif"></a>
<div class="binary"><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/themes/wordcamp-central-2012/images/spinner-2x.gif</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx" style="display: block; padding: 0 10px">Index: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner-2x.gif
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner-2x.gif 2015-01-08 18:13:42 UTC (rev 1104)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner-2x.gif 2015-01-08 18:29:55 UTC (rev 1105)
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner-2x.gif
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span><a id="svnexecutable"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:executable</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+*
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:mime-type</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+image/gif
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagesspinnergif"></a>
<div class="binary"><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/themes/wordcamp-central-2012/images/spinner.gif</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx" style="display: block; padding: 0 10px">Index: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner.gif
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner.gif 2015-01-08 18:13:42 UTC (rev 1104)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner.gif 2015-01-08 18:29:55 UTC (rev 1105)
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/spinner.gif
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span><a id="svnexecutable"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:executable</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+*
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="svnmimetype"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:mime-type</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+image/gif
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012imagestwitteractionspng"></a>
<div class="binary"><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/themes/wordcamp-central-2012/images/twitter-actions.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx" style="display: block; padding: 0 10px">Index: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/twitter-actions.png
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/twitter-actions.png 2015-01-08 18:13:42 UTC (rev 1104)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/twitter-actions.png 2015-01-08 18:29:55 UTC (rev 1105)
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/images/twitter-actions.png
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:mime-type</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+image/png
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012jscentraljs"></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/themes/wordcamp-central-2012/js/central.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/js/central.js 2015-01-08 18:13:42 UTC (rev 1104)
+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/js/central.js 2015-01-08 18:29:55 UTC (rev 1105)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,37 +1,108 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Toggle the navigation menu for small screens.
- */
-( function() {
- var container, button, menu;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+var WordCampCentral = ( function( $ ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- container = document.getElementById( 'access' );
- if ( ! container ) {
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // templateOptions is copied from Core in order to avoid an extra HTTP request just to get wp.template
+ var ajaxURL,
+ templateOptions = {
+ evaluate: /<#([\s\S]+?)#>/g,
+ interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
+ escape: /\{\{([^\}]+?)\}\}(?!\})/g
+ };
+
+ /**
+ * Initialization that runs as soon as this file has loaded
+ */
+ function immediateInit( options ) {
+ ajaxURL = options.ajaxURL;
+
+ toggleNavigation();
+ populateLatestTweets();
</ins><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">- button = container.getElementsByTagName( 'button' )[0];
- if ( 'undefined' === typeof button ) {
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Initialization that runs when the document has fully loaded
+ */
+ function documentReadyInit() {
</ins><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">- menu = container.getElementsByTagName( 'ul' )[0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Toggle the navigation menu for small screens.
+ */
+ function toggleNavigation() {
+ var container, button, menu;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Hide menu toggle button if menu is empty and return early.
- if ( 'undefined' === typeof menu ) {
- button.style.display = 'none';
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ container = document.getElementById( 'access' );
+ if ( ! container ) {
+ return;
+ }
+
+ button = container.getElementsByTagName( 'button' )[0];
+ if ( 'undefined' === typeof button ) {
+ return;
+ }
+
+ menu = container.getElementsByTagName( 'ul' )[0];
+
+ // Hide menu toggle button if menu is empty and return early.
+ if ( 'undefined' === typeof menu ) {
+ button.style.display = 'none';
+ return;
+ }
+
+ if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
+ menu.className += ' nav-menu';
+ }
+
+ button.onclick = function() {
+ if ( -1 !== container.className.indexOf( 'toggled' ) ) {
+ container.className = container.className.replace( ' toggled', '' );
+ } else {
+ container.className += ' toggled';
+ }
+ };
</ins><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">- if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
- menu.className += ' nav-menu';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Fetch the latest tweets and inject them into the DOM
+ */
+ function populateLatestTweets() {
+ $.getJSON(
+ ajaxURL,
+ { action: 'get_latest_wordcamp_tweets' },
+ function( response ) {
+ var index, tweets,
+ spinner = $( '#wc-tweets-spinner' ),
+ error = $( '#wc-tweets-error' ),
+ tweetsContainer = $( '#wc-tweets-container' ),
+ tweetTemplate = _.template( $( '#tmpl-wc-tweet' ).html(), null, templateOptions );
+
+ // Check for success
+ if ( response.hasOwnProperty( 'data' ) && response.data.hasOwnProperty( 'tweets' ) ) {
+ tweets = response.data.tweets;
+ } else {
+ spinner.addClass( 'hidden' );
+ error.removeClass( 'hidden' );
+ error.removeAttr( 'hidden' );
+ return;
+ }
+
+ // Populate and reveal the container
+ for ( index in tweets ) {
+ if ( tweets.hasOwnProperty( index ) ) {
+ tweetsContainer.append( tweetTemplate( { 'tweet': tweets[ index ] } ) );
+ }
+ }
+
+ spinner.addClass( 'hidden' );
+ tweetsContainer.removeClass( 'transparent' );
+ }
+ );
</ins><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">- button.onclick = function() {
- if ( -1 !== container.className.indexOf( 'toggled' ) ) {
- container.className = container.className.replace( ' toggled', '' );
- } else {
- container.className += ' toggled';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return {
+ immediateInit: immediateInit,
+ documentReadyInit: documentReadyInit
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+} )( jQuery );
</ins><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">+WordCampCentral.immediateInit( wordcampCentralOptions );
+jQuery( document ).ready( WordCampCentral.documentReadyInit );
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012stylecss"></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/themes/wordcamp-central-2012/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/style.css 2015-01-08 18:13:42 UTC (rev 1104)
+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/style.css 2015-01-08 18:29:55 UTC (rev 1105)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,6 +334,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * html li { height: 1% }
</span><span class="cx" style="display: block; padding: 0 10px"> *:first-child+html .group,
</span><span class="cx" style="display: block; padding: 0 10px"> *:first-child+html li { min-height: 1px }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.clearfix:after {
+ content: "";
+ display: table;
+ clear: both;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* !01d. Buttons */
</span><span class="cx" style="display: block; padding: 0 10px"> /* ------------------------------------- */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -512,6 +517,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> background: #ccc
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.spinner {
+ background: url( 'images/spinner.gif' ) no-repeat;
+ background-size: 20px 20px;
+ display: none;
+ float: right;
+ opacity: 0.7;
+ filter: alpha(opacity=70);
+ width: 20px;
+ height: 20px;
+ margin: 2px 5px 0;
+}
+
+.spinner-visible {
+ display: block;
+}
+
+.hidden {
+ display: none;
+}
+
+.transparent {
+ opacity: 0;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* !01f. Header & Footer */
</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">@@ -1020,6 +1049,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> margin-bottom: 9px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> #wc-content-blocks .wc-news h3 { background-position: 0 -71px }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#wc-content-blocks .wc-tweets h3 {
+ background-position: 0 -658px;
+ padding-left: 40px;
+ margin-bottom: 9px;
+}
</ins><span class="cx" style="display: block; padding: 0 10px"> #wc-content-blocks .wc-sessions h3 {
</span><span class="cx" style="display: block; padding: 0 10px"> background-position: -7px -150px;
</span><span class="cx" style="display: block; padding: 0 10px"> padding-left: 25px;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1119,6 +1153,74 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* !Latest Tweets */
+#wc-tweets-spinner {
+ float: none;
+ margin: 0 auto;
+}
+
+#wc-tweets-container {
+ transition: all 1.25s ease;
+}
+#wc-tweets-container li {
+ position: relative;
+ border-top: 1px solid #EEEEEE;
+ padding: 1em 0;
+}
+
+.wc-tweet-timestamp {
+ position: absolute;
+ bottom: 1em; /* matches #wc-tweets-container li margin-bottom */
+ right: 0;
+ margin-bottom: 0;
+}
+
+#wc-tweets-container li .wc-tweet-actions li {
+ float: left;
+ margin-right: 12px;
+ padding-top: 8px;
+ padding-bottom: 0;
+ border-top: none;
+}
+.wc-tweet-actions li a,
+.wc-tweet-timestamp a {
+ font-weight: normal;
+ color: #b2b2b2;
+}
+.wc-tweet-actions li a:hover,
+.wc-tweet-timestamp a:hover {
+ color: #666666;
+}
+.wc-tweet-action-icon {
+ position: relative;
+ top: 3px;
+ display: inline-block;
+ width: 16px;
+ height: 16px;
+ background-image: url( 'images/twitter-actions.png' );
+ background-repeat: no-repeat;
+}
+.wc-tweet-action-reply .wc-tweet-action-icon {
+ background-position: 0 0;
+}
+.wc-tweet-action-reply:hover .wc-tweet-action-icon {
+ background-position: -16px 0;
+}
+.wc-tweet-action-retweet .wc-tweet-action-icon {
+ width: 19px;
+ background-position: -80px 0;
+}
+.wc-tweet-action-retweet:hover .wc-tweet-action-icon {
+ background-position: -99px 0;
+}
+.wc-tweet-action-favorite .wc-tweet-action-icon {
+ top: 2px;
+ background-position: -32px 0;
+}
+.wc-tweet-action-favorite:hover .wc-tweet-action-icon {
+ background-position: -48px 0;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* !WordCamp Sessions */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #wc-content-blocks .wc-sessions img {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2650,6 +2752,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* !05. 2x Retina */
</span><span class="cx" style="display: block; padding: 0 10px"> /* ============================================= */
</span><span class="cx" style="display: block; padding: 0 10px"> @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .spinner {
+ background-image: url( 'images/spinner-2x.gif' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> #access .sub-menu, #header {
</span><span class="cx" style="display: block; padding: 0 10px"> background: #e0f5fa url('images/header-bg-2x.png');
</span><span class="cx" style="display: block; padding: 0 10px"> background-size: 56px 56px;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2684,6 +2789,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> #wc-content-blocks .wc-news h3 {
</span><span class="cx" style="display: block; padding: 0 10px"> background-position: 0 -71px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ #wc-content-blocks .wc-tweets h3 {
+ background-position: 0 -658px;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> #wc-content-blocks .wc-sessions h3 {
</span><span class="cx" style="display: block; padding: 0 10px"> background-position: -7px -150px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2903,6 +3011,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .search #content h1.page-title {
</span><span class="cx" style="display: block; padding: 0 10px"> margin-right: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ .wc-tweet-timestamp {
+ position: relative;
+ bottom: auto;
+ right: auto;
+ margin-top: 10px;
+ }
+ .wc-tweet-timestamp a::after {
+ content: " ago"
+ }
+ #wc-tweets-container li .wc-tweet-actions li {
+ padding-top: 0;
+ }
</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"> @media screen and (max-width: 768px) {
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentthemeswordcampcentral2012templatehomephp"></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/themes/wordcamp-central-2012/template-home.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/themes/wordcamp-central-2012/template-home.php 2015-01-08 18:13:42 UTC (rev 1104)
+++ sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-central-2012/template-home.php 2015-01-08 18:29:55 UTC (rev 1105)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,26 +88,51 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> </div><!-- .wc-news -->
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="wc-sessions last">
- <h3>WordCamp <strong>Sessions</strong></h3>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="wc-tweets last">
+ <h3><strong>Latest Tweets</strong></h3>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php $sessions = WordCamp_Central_Theme::get_sessions(); ?>
- <?php if ( ! empty( $sessions ) ) : ?>
- <ul>
- <?php foreach( $sessions as $session ) : ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div id="wc-tweets-spinner" class="spinner spinner-visible"></div>
+ <ul id="wc-tweets-container" class="transparent"></ul>
+
+ <p id="wc-tweets-error" class="hidden" hidden>
+ Tweets from <a href="https://twitter.com/wordcamp">@WordCamp</a> are currently unavailable.
+ </p>
+
+ <a href="https://twitter.com/wordcamp" class="more">Follow @WordCamp on Twitter →</a>
+
+ <script id="tmpl-wc-tweet" type="text/html">
</ins><span class="cx" style="display: block; padding: 0 10px"> <li>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo $session['wordcamp_thumb']; ?>
- <a href="<?php echo esc_url( $session['permalink'] ); ?>" class="wc-session-name"><?php echo esc_html( $session['name'] ); ?></a>
- <span class="wc-session-speakers">by <?php echo esc_html( $session['speakers'] ); ?></span>
- <a href="<?php echo esc_url( $session['wordcamp_permalink'] ); ?>" class="wc-session-wordcamp"><?php echo esc_html( $session['wordcamp_title'] ); ?></a>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="wc-tweet-content">{{{tweet.text}}}</div>
+
+ <p class="wc-tweet-timestamp">
+ <a href="https://twitter.com/wordcamp/status/{{tweet.id_str}}">{{tweet.time_ago}}</a>
+ </p>
+
+ <ul class="wc-tweet-actions clearfix">
+ <li class="wc-tweet-action-reply">
+ <a href="https://twitter.com/intent/tweet?in_reply_to={{tweet.id_str}}">
+ <span class="wc-tweet-action-icon"></span>
+ Reply
+ </a>
+ </li>
+
+ <li class="wc-tweet-action-retweet">
+ <a href="https://twitter.com/intent/retweet?tweet_id={{tweet.id_str}}">
+ <span class="wc-tweet-action-icon"></span>
+ Retweet
+ </a>
+ </li>
+
+ <li class="wc-tweet-action-favorite">
+ <a href="https://twitter.com/intent/favorite?tweet_id={{tweet.id_str}}">
+ <span class="wc-tweet-action-icon"></span>
+ Favorite
+ </a>
+ </li>
+ </ul>
</ins><span class="cx" style="display: block; padding: 0 10px"> </li>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php endforeach; ?>
- </ul>
- <!--<a href="#" class="more">More Speakers →</a>-->
- <?php else : // ! empty( $sessions ) ?>
- <p>We're sorry, the speakers list is temporarily unavailable.</p>
- <?php endif; ?>
- </div> <!-- .wc-speakers -->
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ </script>
+ </div> <!-- .wc-tweets -->
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> </div> <!-- #wc-content-blocks -->
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span></span></pre>
</div>
</div>
</body>
</html>