diff --git src/wp-admin/admin-ajax.php src/wp-admin/admin-ajax.php
index 64915aa..5597aec 100644
|
|
|
$core_actions_post = array( |
| 62 | 62 | 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', |
| 63 | 63 | 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', |
| 64 | 64 | 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post', |
| 65 | | 'press-this-add-category', 'crop-image', 'generate-password', |
| | 65 | 'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | // Deprecated |
diff --git src/wp-admin/css/common.css src/wp-admin/css/common.css
index c084b20..df864d3 100644
|
|
|
th.action-links { |
| 1087 | 1087 | color: #fff; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| | 1090 | .wp-filter .favorites-form { |
| | 1091 | display: none; |
| | 1092 | margin: 0 -20px; |
| | 1093 | padding: 20px; |
| | 1094 | border-top: 1px solid #eee; |
| | 1095 | background: #fafafa; |
| | 1096 | overflow: hidden; |
| | 1097 | width: 100%; |
| | 1098 | } |
| | 1099 | |
| | 1100 | .show-favorites-form .wp-filter .favorites-form { |
| | 1101 | display: block; |
| | 1102 | } |
| | 1103 | |
| 1090 | 1104 | .filter-drawer { |
| 1091 | 1105 | display: none; |
| 1092 | 1106 | margin: 0 -20px; |
diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php
index 0170cd9..4258fac 100644
|
|
|
function wp_ajax_query_themes() { |
| 2815 | 2815 | 'fields' => $theme_field_defaults |
| 2816 | 2816 | ) ); |
| 2817 | 2817 | |
| | 2818 | if ( 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { |
| | 2819 | $user = get_user_option( 'wporg_favorites' ); |
| | 2820 | if ( $user ) { |
| | 2821 | $args['user'] = $user; |
| | 2822 | } |
| | 2823 | } |
| | 2824 | |
| 2818 | 2825 | $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; |
| 2819 | 2826 | |
| 2820 | 2827 | /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ |
| … |
… |
function wp_ajax_crop_image() { |
| 3279 | 3286 | function wp_ajax_generate_password() { |
| 3280 | 3287 | wp_send_json_success( wp_generate_password( 24 ) ); |
| 3281 | 3288 | } |
| | 3289 | |
| | 3290 | /** |
| | 3291 | * Ajax handler for saving the user's WordPress.org username. |
| | 3292 | * |
| | 3293 | * @since 4.4.0 |
| | 3294 | */ |
| | 3295 | function wp_ajax_save_wporg_username() { |
| | 3296 | if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { |
| | 3297 | wp_send_json_error(); |
| | 3298 | } |
| | 3299 | |
| | 3300 | $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; |
| | 3301 | |
| | 3302 | if ( ! $username ) { |
| | 3303 | wp_send_json_error(); |
| | 3304 | } |
| | 3305 | |
| | 3306 | wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); |
| | 3307 | } |
diff --git src/wp-admin/js/theme.js src/wp-admin/js/theme.js
index 0961922..a8a869c 100644
|
|
|
themes.view.Installer = themes.view.Appearance.extend({ |
| 1356 | 1356 | 'click .filter-drawer .apply-filters': 'applyFilters', |
| 1357 | 1357 | 'click .filter-group [type="checkbox"]': 'addFilter', |
| 1358 | 1358 | 'click .filter-drawer .clear-filters': 'clearFilters', |
| 1359 | | 'click .filtered-by': 'backToFilters' |
| | 1359 | 'click .filtered-by': 'backToFilters', |
| | 1360 | 'click .favorites-form-submit' : 'saveUsername', |
| | 1361 | 'keyup #wporg-username-input': 'saveUsername', |
| 1360 | 1362 | }, |
| 1361 | 1363 | |
| 1362 | 1364 | // Initial render method |
| … |
… |
themes.view.Installer = themes.view.Appearance.extend({ |
| 1448 | 1450 | $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass ); |
| 1449 | 1451 | $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass ); |
| 1450 | 1452 | |
| | 1453 | if ( 'favorites' === sort ) { |
| | 1454 | $ ( 'body' ).addClass( 'show-favorites-form' ); |
| | 1455 | } else { |
| | 1456 | $ ( 'body' ).removeClass( 'show-favorites-form' ); |
| | 1457 | } |
| | 1458 | |
| 1451 | 1459 | this.browse( sort ); |
| 1452 | 1460 | }, |
| 1453 | 1461 | |
| … |
… |
themes.view.Installer = themes.view.Appearance.extend({ |
| 1509 | 1517 | this.collection.query( request ); |
| 1510 | 1518 | }, |
| 1511 | 1519 | |
| | 1520 | // Save the user's WordPress.org username and get his favorite themes. |
| | 1521 | saveUsername: function ( event ) { |
| | 1522 | var username = $( '#wporg-username-input' ).val(), |
| | 1523 | request = { browse: 'favorites', user: username }, |
| | 1524 | that = this; |
| | 1525 | |
| | 1526 | if ( event ) { |
| | 1527 | event.preventDefault(); |
| | 1528 | } |
| | 1529 | |
| | 1530 | // save username on enter |
| | 1531 | if ( event.type === 'keyup' && event.which !== 13 ) { |
| | 1532 | return; |
| | 1533 | } |
| | 1534 | |
| | 1535 | return wp.ajax.send( 'save-wporg-username', { |
| | 1536 | data: { |
| | 1537 | username: username |
| | 1538 | }, |
| | 1539 | success: function () { |
| | 1540 | // Get the themes by sending Ajax POST request to api.wordpress.org/themes |
| | 1541 | // or searching the local cache |
| | 1542 | that.collection.query( request ); |
| | 1543 | } |
| | 1544 | } ); |
| | 1545 | }, |
| | 1546 | |
| 1512 | 1547 | // Get the checked filters |
| 1513 | 1548 | // @return {array} of tags or false |
| 1514 | 1549 | filtersChecked: function() { |
diff --git src/wp-admin/theme-install.php src/wp-admin/theme-install.php
index 6213a5a..289f395 100644
|
|
|
include(ABSPATH . 'wp-admin/admin-header.php'); |
| 139 | 139 | <li><a href="#" data-sort="featured"><?php _ex( 'Featured', 'themes' ); ?></a></li> |
| 140 | 140 | <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li> |
| 141 | 141 | <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li> |
| | 142 | <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li> |
| 142 | 143 | </ul> |
| 143 | 144 | |
| 144 | 145 | <a class="drawer-toggle" href="#"><?php _e( 'Feature Filter' ); ?></a> |
| 145 | 146 | |
| 146 | 147 | <div class="search-form"></div> |
| 147 | 148 | |
| | 149 | <div class="favorites-form"> |
| | 150 | <?php |
| | 151 | $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
| | 152 | update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
| | 153 | ?> |
| | 154 | <p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p> |
| | 155 | |
| | 156 | <p> |
| | 157 | <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> |
| | 158 | <input type="search" id="wporg-username-input" value="<?php echo esc_attr( $user ); ?>" /> |
| | 159 | <input type="button" class="button button-secondary favorites-form-submit" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> |
| | 160 | </p> |
| | 161 | </div> |
| | 162 | |
| 148 | 163 | <div class="filter-drawer"> |
| 149 | 164 | <div class="buttons"> |
| 150 | 165 | <a class="apply-filters button button-secondary" href="#"><?php _e( 'Apply Filters' ); ?><span></span></a> |