<!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>[475] sites/trunk/global.wordpress.org/public_html/wp-content: International Sites: initial import of a few plugins that run on the international sites</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">
<dt>Revision</dt> <dd><a href="http://meta.trac.wordpress.org/changeset/475">475</a></dd>
<dt>Author</dt> <dd>yoavf</dd>
<dt>Date</dt> <dd>2014-03-10 09:51:36 +0000 (Mon, 10 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>International Sites: initial import of a few plugins that run on the international sites
1. Roles: defines the validator role
2. Downloads: download stats
3. Showcase: site showcase custom post type (and template tag)</pre>
<h3>Added Paths</h3>
<ul>
<li>sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/</li>
<li>sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/downloads/</li>
<li><a href="#sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsdownloadsrosettadownloadsphp">sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/downloads/rosetta-downloads.php</a></li>
<li>sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/</li>
<li><a href="#sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsrolesrosettarolesphp">sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php</a></li>
<li>sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/</li>
<li><a href="#sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsshowcaserosettashowcasephp">sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsdownloadsrosettadownloadsphp"></a>
<div class="addfile"><h4>Added: sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/downloads/rosetta-downloads.php (0 => 475)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/downloads/rosetta-downloads.php (rev 0)
+++ sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/downloads/rosetta-downloads.php 2014-03-10 09:51:36 UTC (rev 475)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+<?php
+/* Plugin Name: Rosetta Downloads
+ * Author: Nacin
+ */
+
+class Rosetta_Downloads {
+
+ function __construct() {
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
+ }
+
+ function admin_menu() {
+ add_dashboard_page( 'Download Stats', 'Download Stats', 'read', 'download-stats', array( $this, 'render_download_stats' ) );
+ }
+
+ function get_counts() {
+ global $wpdb;
+ $orderby = isset( $_GET['desc'] ) ? 'SUM(`downloads`) DESC' : '`locale`';
+ $stable_branch = implode( '.', array_map( 'absint', explode( '.', WP_CORE_STABLE_BRANCH ) ) );
+ return $wpdb->get_results( "SELECT `locale`, SUM(`downloads`) FROM `download_counts` WHERE `release` LIKE '{$stable_branch}%' AND `release` NOT LIKE '%-%' GROUP BY `locale` ORDER BY $orderby", ARRAY_N );
+ }
+
+ function render_download_stats() {
+ echo '<div class="wrap">';
+ screen_icon();
+ echo '<h2>' . __( 'Download Stats', 'rosetta' ) . '</h2>';
+ echo '<table cellpadding=3 cellspacing=2>';
+
+ echo '<p>' . sprintf( __( 'This page shows the <a href="%s">Download Counter</a> number — total downloads of WordPress %s — broken down by locale.', 'rosetta' ), 'http://wordpress.org/download/counter/', esc_html( WP_CORE_STABLE_BRANCH ) ) . '</p>';
+
+ $rows = array();
+ $total = 0;
+ $this_locale = get_locale();
+ foreach ( $this->get_counts() as $value ) {
+ list( $locale, $sum ) = $value;
+ $total += $sum;
+ $sum = number_format_i18n( $sum );
+ $highlight = $locale == $this_locale ? 'background:#ffffe0;border:1px solid #e6db55;font-weight:bold;' : '';
+ $row = "<tr><td>$locale</td><td style='{$highlight}text-align:right'>$sum</td></tr>";
+ if ( $locale == 'en' ) {
+ $rows = array_merge( array( $row ), $rows );
+ } else {
+ $rows[] = $row;
+ }
+ }
+ echo "<tr><td style='width:100px'><strong>" . _x( 'All', 'locales', 'rosetta' ) . "</strong></td><td style='text-align:right'><strong>" . number_format_i18n( $total ) . "</strong></td></tr>";
+ echo implode( "\n", $rows );
+ echo '</table>';
+ }
+
+
+}
+new Rosetta_Downloads;
</ins></span></pre></div>
<a id="sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsrolesrosettarolesphp"></a>
<div class="addfile"><h4>Added: sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php (0 => 475)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php (rev 0)
+++ sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php 2014-03-10 09:51:36 UTC (rev 475)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+<?php
+
+add_filter( 'gettext_with_context', 'ros_rename_user_roles', 10, 4 );
+function ros_rename_user_roles( $translated, $text, $context, $domain ) {
+ if ( $domain !== 'default' || $context !== 'User role' ) {
+ return $translated;
+ }
+ if ( 'Validator' === $text ) {
+ return __( 'Validator', 'rosetta' );
+ }
+ return $translated;
+}
+
+add_action( 'admin_menu', 'ros_remove_widgets_menu' );
+function ros_remove_widgets_menu() {
+ remove_submenu_page( 'themes.php', 'themes.php' );
+ remove_submenu_page( 'themes.php', 'widgets.php' );
+}
+
+add_filter( 'editable_roles', 'ros_editable_roles' );
+function ros_editable_roles( $roles ) {
+ $subscriber = $roles['subscriber'];
+ unset( $roles['subscriber'] );
+ reset( $roles );
+ $roles['subscriber'] = $subscriber;
+ if ( ! is_super_admin() ) {
+ unset( $roles['administrator'] );
+ }
+ return $roles;
+}
+
+add_filter( 'admin_init', 'ros_role_modifications' );
+function ros_role_modifications() {
+ if ( ! get_role( 'validator' ) ) {
+ add_role( 'validator', __( 'Validator', 'rosetta' ), array( 'read' => true, 'level_0' => true ) );
+ }
+ $editor_role = & get_role( 'editor' );
+ if ( $editor_role && ! $editor_role->has_cap( 'remove_users' ) ) {
+ $editor_role->add_cap( 'edit_theme_options' );
+ $editor_role->add_cap( 'list_users' );
+ $editor_role->add_cap( 'promote_users' );
+ $editor_role->add_cap( 'remove_users' );
+ }
+}
</ins></span></pre></div>
<a id="sitestrunkglobalwordpressorgpublic_htmlwpcontentmupluginsshowcaserosettashowcasephp"></a>
<div class="addfile"><h4>Added: sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php (0 => 475)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php (rev 0)
+++ sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/showcase/rosetta-showcase.php 2014-03-10 09:51:36 UTC (rev 475)
</span><span class="lines">@@ -0,0 +1,146 @@
</span><ins>+<?php
+/*
+ * Plugin Name: Rosetta Showcase
+ * Author: Zé Fontainhas and Andrew Nacin
+ */
+
+
+add_action( 'init', 'rosetta_showcase_register' );
+
+function rosetta_showcase_register() {
+ $labels = array(
+ 'name' => _x( 'Showcase', 'post type general name', 'rosetta' ),
+ 'singular_name' => _x( 'Showcase Site', 'post type singular name', 'rosetta' ),
+ 'add_new' => _x( 'Add New', 'showcase item', 'rosetta' ),
+ 'add_new_item' => __( 'Add New Site', 'rosetta' ),
+ 'edit_item' => __( 'Edit Site', 'rosetta' ),
+ 'new_item' => __( 'New Site', 'rosetta' ),
+ 'view_item' => __( 'View Site', 'rosetta' ),
+ 'search_items' => __( 'Search Showcase', 'rosetta' ),
+ 'not_found' => __( 'Nothing found', 'rosetta' ),
+ 'not_found_in_trash' => __( 'Nothing found in Trash', 'rosetta' ),
+ );
+
+ $args = array(
+ 'labels' => $labels,
+ 'public' => true,
+ 'show_ui' => true,
+ 'rewrite' => false,
+ 'has_archive' => true,
+ 'capability_type' => 'post',
+ 'map_meta_cap' => true,
+ 'hierarchical' => false,
+ 'supports' => array( 'title','excerpt' ),
+ );
+
+ register_post_type( 'showcase', $args );
+}
+
+add_filter( 'post_type_link', 'rosetta_filter_showcase_permalink', 10, 2 );
+
+function rosetta_filter_showcase_permalink( $post_link, $post ) {
+ if ( 'showcase' == $post->post_type ) {
+ $url = get_post_meta( $post->ID, '_rosetta_showcase_url', true );
+ if ( $url ) {
+ return $url;
+ }
+ }
+ return $post_link;
+}
+
+add_action( 'add_meta_boxes_showcase', 'rosetta_add_showcase_meta_box' );
+
+function rosetta_add_showcase_meta_box() {
+ remove_meta_box( 'postexcerpt', 'showcase', 'normal' );
+ add_meta_box( 'rosetta_showcase_meta', __( 'Description and URL', 'rosetta' ), 'rosetta_showcase_meta_box', 'showcase', 'normal', 'default' );
+}
+
+function rosetta_showcase_meta_box( $post ) {
+ $url = get_post_meta( $post->ID, '_rosetta_showcase_url', true );
+ ?>
+ <p><label for="rosetta_showcase_url"><?php _e( 'URL' ) // core ?></label>
+ <input style="margin-left: 0; width: 98%" name="rosetta_showcase_url" type="text" value="<?php echo esc_url( $url ); ?>" /></p>
+ <label for="excerpt"><?php _e( 'Description' ) // core ?></label>
+ <textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
+ <?php
+}
+
+add_action( 'save_post', 'save_showcase_url', 10, 2 );
+
+function save_showcase_url( $post_id, $post ) {
+
+ if ( $post->post_type != 'showcase' ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ return;
+ }
+
+ if ( defined( 'DOING_AUTOSAVE' ) || defined( 'DOING_AJAX' ) ) {
+ return;
+ }
+
+ if ( ! isset( $_POST['rosetta_showcase_url' ] ) ) {
+ return;
+ }
+
+ $url = esc_url_raw( $_POST['rosetta_showcase_url'] );
+
+ update_post_meta( $post_id, '_rosetta_showcase_url', $url );
+}
+
+/* Show columns on the 'All Sites' page */
+
+add_action( 'manage_showcase_posts_columns', 'rosetta_showcase_custom_columns' );
+add_filter( 'manage_showcase_posts_custom_column', 'rosetta_showcase_custom_column', 10, 2 );
+
+function rosetta_showcase_custom_columns( $columns ) {
+ $columns = array(
+ 'cb' => $columns['cb'],
+ 'shot' => __( 'Image' ), // core
+ 'title' => __( 'Website' ), // core
+ 'description' => __( 'Description' ), // core
+ 'url' => __( 'URL' ), // core
+ );
+ return $columns;
+}
+
+function rosetta_showcase_custom_column( $column, $post_id ) {
+ $post = get_post( $post_id );
+
+ switch ( $column ) {
+ case 'description' :
+ the_excerpt();
+ break;
+ case 'url' :
+ $url = get_post_meta( $post_id, '_rosetta_showcase_url', true );
+ echo '<a href="' . esc_url( $url ) . '">' . esc_url_raw( $url ) . '</a>';
+ break;
+ case 'shot' :
+ $url = esc_url( get_post_meta( $post_id, '_rosetta_showcase_url', true ) );
+ if ( $url ) {
+ echo '<a href="' . $url . '" target="_blank"><img width="100" src="http://s.wordpress.com/mshots/v1/' . urlencode( $url ) . '?w=100" /></a>';
+ }
+ break;
+ }
+}
+
+/* Add Showcase posts to the main loop and feed */
+//add_filter( 'pre_get_posts', 'rosetta_get_posts_with_showcase' );
+function rosetta_get_posts_with_showcase( $query ) {
+ global $wp_the_query;
+ if ( ( is_home() && $wp_the_query === $query ) || is_feed() ) {
+ $query->set( 'post_type', array( 'post', 'showcase' ) );
+ }
+
+ return $query;
+}
+
+class Rosetta_Showcase {
+ function front() {
+ $posts = get_posts( array( 'post_type' => 'showcase', 'numberposts' => -1 ) );
+ shuffle( $posts );
+ return array_slice( $posts, 0, 4 );
+ }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>