Changeset 35527
- Timestamp:
- 11/04/2015 09:48:43 PM (9 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/admin-ajax.php
r35317 r35527 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 -
trunk/src/wp-admin/css/common.css
r35496 r35527 1084 1084 .wp-filter .drawer-toggle.current:before { 1085 1085 color: #fff; 1086 } 1087 1088 .wp-filter .favorites-form { 1089 display: none; 1090 margin: 0 -20px; 1091 padding: 20px; 1092 border-top: 1px solid #eee; 1093 background: #fafafa; 1094 overflow: hidden; 1095 width: 100%; 1096 } 1097 1098 .show-favorites-form .wp-filter .favorites-form { 1099 display: block; 1086 1100 } 1087 1101 -
trunk/src/wp-admin/includes/ajax-actions.php
r35518 r35527 2822 2822 ) ); 2823 2823 2824 if ( 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { 2825 $user = get_user_option( 'wporg_favorites' ); 2826 if ( $user ) { 2827 $args['user'] = $user; 2828 } 2829 } 2830 2824 2831 $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; 2825 2832 … … 3291 3298 wp_send_json_success( wp_generate_password( 24 ) ); 3292 3299 } 3300 3301 /** 3302 * Ajax handler for saving the user's WordPress.org username. 3303 * 3304 * @since 4.4.0 3305 */ 3306 function wp_ajax_save_wporg_username() { 3307 if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { 3308 wp_send_json_error(); 3309 } 3310 3311 $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; 3312 3313 if ( ! $username ) { 3314 wp_send_json_error(); 3315 } 3316 3317 wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); 3318 } -
trunk/src/wp-admin/js/theme.js
r35281 r35527 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 … … 1448 1450 $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass ); 1449 1451 $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass ); 1452 1453 if ( 'favorites' === sort ) { 1454 $ ( 'body' ).addClass( 'show-favorites-form' ); 1455 } else { 1456 $ ( 'body' ).removeClass( 'show-favorites-form' ); 1457 } 1450 1458 1451 1459 this.browse( sort ); … … 1508 1516 // or searching the local cache 1509 1517 this.collection.query( request ); 1518 }, 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 } ); 1510 1545 }, 1511 1546 -
trunk/src/wp-admin/theme-install.php
r35273 r35527 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 … … 145 146 146 147 <div class="search-form"></div> 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> 147 162 148 163 <div class="filter-drawer">
Note: See TracChangeset
for help on using the changeset viewer.