<!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>[35527] trunk/src/wp-admin: Themes: Add a Favorites tab to the Add Themes screen.</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="https://core.trac.wordpress.org/changeset/35527">35527</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/35527","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-11-04 21:48:43 +0000 (Wed, 04 Nov 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'>Themes: Add a Favorites tab to the Add Themes screen.
You can now browse and install your wordpress.org theme favorites from the theme installer, just like with plugins.
Props swissspidy.
Fixes <a href="https://core.trac.wordpress.org/ticket/34206">#34206</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminadminajaxphp">trunk/src/wp-admin/admin-ajax.php</a></li>
<li><a href="#trunksrcwpadmincsscommoncss">trunk/src/wp-admin/css/common.css</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminjsthemejs">trunk/src/wp-admin/js/theme.js</a></li>
<li><a href="#trunksrcwpadminthemeinstallphp">trunk/src/wp-admin/theme-install.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminadminajaxphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/admin-ajax.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/admin-ajax.php 2015-11-04 21:46:04 UTC (rev 35526)
+++ trunk/src/wp-admin/admin-ajax.php 2015-11-04 21:48:43 UTC (rev 35527)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,7 +62,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
</span><span class="cx" style="display: block; padding: 0 10px"> 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
</span><span class="cx" style="display: block; padding: 0 10px"> 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'press-this-add-category', 'crop-image', 'generate-password',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username',
</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"> // Deprecated
</span></span></pre></div>
<a id="trunksrcwpadmincsscommoncss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/common.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/common.css 2015-11-04 21:46:04 UTC (rev 35526)
+++ trunk/src/wp-admin/css/common.css 2015-11-04 21:48:43 UTC (rev 35527)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1085,6 +1085,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> color: #fff;
</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">+.wp-filter .favorites-form {
+ display: none;
+ margin: 0 -20px;
+ padding: 20px;
+ border-top: 1px solid #eee;
+ background: #fafafa;
+ overflow: hidden;
+ width: 100%;
+}
+
+.show-favorites-form .wp-filter .favorites-form {
+ display: block;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> .filter-drawer {
</span><span class="cx" style="display: block; padding: 0 10px"> display: none;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0 -20px;
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php 2015-11-04 21:46:04 UTC (rev 35526)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2015-11-04 21:48:43 UTC (rev 35527)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2821,6 +2821,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'fields' => $theme_field_defaults
</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">+ if ( 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
+ $user = get_user_option( 'wporg_favorites' );
+ if ( $user ) {
+ $args['user'] = $user;
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3290,3 +3297,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_ajax_generate_password() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_success( wp_generate_password( 24 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Ajax handler for saving the user's WordPress.org username.
+ *
+ * @since 4.4.0
+ */
+function wp_ajax_save_wporg_username() {
+ if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) {
+ wp_send_json_error();
+ }
+
+ $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false;
+
+ if ( ! $username ) {
+ wp_send_json_error();
+ }
+
+ wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) );
+}
</ins></span></pre></div>
<a id="trunksrcwpadminjsthemejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/theme.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/theme.js 2015-11-04 21:46:04 UTC (rev 35526)
+++ trunk/src/wp-admin/js/theme.js 2015-11-04 21:48:43 UTC (rev 35527)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1356,7 +1356,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'click .filter-drawer .apply-filters': 'applyFilters',
</span><span class="cx" style="display: block; padding: 0 10px"> 'click .filter-group [type="checkbox"]': 'addFilter',
</span><span class="cx" style="display: block; padding: 0 10px"> 'click .filter-drawer .clear-filters': 'clearFilters',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'click .filtered-by': 'backToFilters'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'click .filtered-by': 'backToFilters',
+ 'click .favorites-form-submit' : 'saveUsername',
+ 'keyup #wporg-username-input': 'saveUsername',
</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"> // Initial render method
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1448,6 +1450,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass );
</span><span class="cx" style="display: block; padding: 0 10px"> $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'favorites' === sort ) {
+ $ ( 'body' ).addClass( 'show-favorites-form' );
+ } else {
+ $ ( 'body' ).removeClass( 'show-favorites-form' );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> this.browse( sort );
</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">@@ -1509,6 +1517,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.collection.query( request );
</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">+ // Save the user's WordPress.org username and get his favorite themes.
+ saveUsername: function ( event ) {
+ var username = $( '#wporg-username-input' ).val(),
+ request = { browse: 'favorites', user: username },
+ that = this;
+
+ if ( event ) {
+ event.preventDefault();
+ }
+
+ // save username on enter
+ if ( event.type === 'keyup' && event.which !== 13 ) {
+ return;
+ }
+
+ return wp.ajax.send( 'save-wporg-username', {
+ data: {
+ username: username
+ },
+ success: function () {
+ // Get the themes by sending Ajax POST request to api.wordpress.org/themes
+ // or searching the local cache
+ that.collection.query( request );
+ }
+ } );
+ },
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Get the checked filters
</span><span class="cx" style="display: block; padding: 0 10px"> // @return {array} of tags or false
</span><span class="cx" style="display: block; padding: 0 10px"> filtersChecked: function() {
</span></span></pre></div>
<a id="trunksrcwpadminthemeinstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/theme-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/theme-install.php 2015-11-04 21:46:04 UTC (rev 35526)
+++ trunk/src/wp-admin/theme-install.php 2015-11-04 21:48:43 UTC (rev 35527)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,12 +139,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <li><a href="#" data-sort="featured"><?php _ex( 'Featured', 'themes' ); ?></a></li>
</span><span class="cx" style="display: block; padding: 0 10px"> <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li>
</span><span class="cx" style="display: block; padding: 0 10px"> <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li>
</ins><span class="cx" style="display: block; padding: 0 10px"> </ul>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <a class="drawer-toggle" href="#"><?php _e( 'Feature Filter' ); ?></a>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="search-form"></div>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="favorites-form">
+ <?php
+ $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
+ update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
+ ?>
+ <p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p>
+
+ <p>
+ <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label>
+ <input type="search" id="wporg-username-input" value="<?php echo esc_attr( $user ); ?>" />
+ <input type="button" class="button button-secondary favorites-form-submit" value="<?php esc_attr_e( 'Get Favorites' ); ?>" />
+ </p>
+ </div>
+
</ins><span class="cx" style="display: block; padding: 0 10px"> <div class="filter-drawer">
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="buttons">
</span><span class="cx" style="display: block; padding: 0 10px"> <a class="apply-filters button button-secondary" href="#"><?php _e( 'Apply Filters' ); ?><span></span></a>
</span></span></pre>
</div>
</div>
</body>
</html>