Ticket #27055: 27055.38.diff
| File 27055.38.diff, 6.7 KB (added by , 12 years ago) |
|---|
-
wp-admin/css/themes.css
216 216 * Displays a theme update notice 217 217 * when an update is available. 218 218 */ 219 .theme-browser .theme .theme-update { 219 .theme-browser .theme .theme-update, 220 .theme-browser .theme .theme-installed { 220 221 background: #d54e21; 221 222 background: rgba(213, 78, 33, 0.95); 222 223 color: #fff; … … 234 235 overflow: hidden; 235 236 } 236 237 237 .theme-browser .theme .theme-update:before { 238 .theme-browser .theme .theme-update:before, 239 .theme-browser .theme .theme-installed:before { 238 240 content: '\f463'; 239 241 display: inline-block; 240 242 font: normal 20px/1 'dashicons'; … … 1074 1076 16.2 - Install Themes 1075 1077 ------------------------------------------------------------------------------*/ 1076 1078 1079 /* Already installed theme */ 1080 .theme-browser .theme.is-installed { 1081 cursor: default; 1082 } 1083 .theme-browser .theme .theme-installed { 1084 background: #0074a2; 1085 } 1086 .theme-browser .theme .theme-installed:before { 1087 content: '\f147'; 1088 } 1089 .theme-browser .theme.is-installed .theme-actions, 1090 .theme-browser.rendered .theme.is-installed .more-details { 1091 display: none !important; 1092 } 1093 .theme-browser.rendered .theme.is-installed:hover .theme-screenshot img, 1094 .theme-browser.rendered .theme.is-installed:focus .theme-screenshot img { 1095 opacity: 1 !important; 1096 } 1097 1077 1098 .theme-navigation { 1078 1099 background: #fff; 1079 1100 -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); -
wp-admin/js/theme.js
22 22 // Adds attributes to the default data coming through the .org themes api 23 23 // Map `id` to `slug` for shared code 24 24 initialize: function() { 25 var install, preview;25 var install, installed; 26 26 27 27 // Install url for the theme 28 28 // using the install nonce … … 35 35 // Build the url query 36 36 install = themes.data.settings.updateURI + '?' + $.param( install ); 37 37 38 // Preview url for the theme 39 preview = { 40 tab: 'theme-information', 41 theme: this.get( 'slug' ) 42 }; 38 // If theme is already installed, set an attribute. 39 if ( _.indexOf( themes.data.installedThemes, this.get( 'slug' ) ) !== -1 ) { 40 this.set({ installed: true }); 41 } 43 42 44 preview = themes.data.settings.installURI + '?' + $.param( preview );45 46 43 // Set the attributes 47 44 this.set({ 48 installURI: install, 49 previewURI: preview, 45 installURI: ( this.get( 'slug' ) ) ? install : false, 50 46 // slug is for installation, id is for existing. 51 47 id: this.get( 'slug' ) || this.get( 'id' ) 52 48 }); … … 391 387 if ( this.model.get( 'displayAuthor' ) ) { 392 388 this.$el.addClass( 'display-author' ); 393 389 } 390 391 if ( this.model.get( 'installed' ) ) { 392 this.$el.addClass( 'is-installed' ); 393 this.$el.unbind(); 394 } 394 395 }, 395 396 396 397 // Adds a class to the currently active theme … … 451 452 return this.touchDrag = false; 452 453 } 453 454 455 // Allow direct link path to installing a theme. 456 if ( $( event.target ).hasClass( 'button-primary' ) ) { 457 return; 458 } 459 454 460 // 'enter' and 'space' keys expand the details view when a theme is :focused 455 461 if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { 456 462 return; … … 494 500 495 501 // If we have no more themes, bail. 496 502 if ( _.isUndefined( self.current ) ) { 503 self.options.parent.parent.trigger( 'theme:end' ); 497 504 return self.current = current; 498 505 } 499 506 … … 505 512 // Render and append. 506 513 preview.render(); 507 514 $( 'div.wrap' ).append( preview.el ); 515 $( '.next-theme' ).focus(); 508 516 }) 509 517 .listenTo( preview, 'theme:previous', function() { 510 518 … … 532 540 // Render and append. 533 541 preview.render(); 534 542 $( 'div.wrap' ).append( preview.el ); 543 $( '.previous-theme' ).focus(); 535 544 }); 536 545 } 537 546 }); … … 882 891 // Loop through the themes and setup each theme view 883 892 self.instance.each( function( theme ) { 884 893 self.theme = new themes.view.Theme({ 885 model: theme 894 model: theme, 895 parent: self 886 896 }); 887 897 888 898 // Render the views... … … 1224 1234 // Get the themes by sending Ajax POST request to api.wordpress.org/themes 1225 1235 // or searching the local cache 1226 1236 this.collection.query( request ); 1237 1238 // Set route 1239 themes.router.navigate( themes.router.baseUrl( '?search=' + value ), { replace: true } ); 1227 1240 }, 300 ) 1228 1241 }); 1229 1242 … … 1329 1342 }, 1330 1343 1331 1344 sort: function( sort ) { 1332 $( '#theme-search-input' ).val( '');1345 this.clearSearch(); 1333 1346 1334 1347 $( '.theme-section, .theme-filter' ).removeClass( this.activeClass ); 1335 1348 $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass ); … … 1450 1463 return this.addFilter(); 1451 1464 } 1452 1465 1466 this.clearSearch(); 1467 1468 themes.router.navigate( themes.router.baseUrl( '' ) ); 1453 1469 $( 'body' ).toggleClass( 'more-filters-opened' ); 1454 1470 }, 1455 1471 … … 1474 1490 1475 1491 backToFilters: function() { 1476 1492 $( 'body' ).removeClass( 'filters-applied' ); 1493 }, 1494 1495 clearSearch: function() { 1496 $( '#theme-search-input').val( '' ); 1477 1497 } 1478 1498 }); 1479 1499 -
wp-admin/theme-install.php
33 33 'new' => __( 'Newest Themes' ), 34 34 ); 35 35 36 $installed_themes = search_theme_directories(); 37 foreach ( $installed_themes as $k => $v ) { 38 if ( false !== strpos( $k, '/' ) ) { 39 unset( $installed_themes[ $k ] ); 40 } 41 } 42 36 43 wp_localize_script( 'theme', '_wpThemeSettings', array( 37 44 'themes' => false, 38 45 'settings' => array( … … 51 58 'back' => __( 'Back' ), 52 59 'error' => ( 'There was a problem trying to load the themes. Please, try again.' ), // @todo improve 53 60 ), 61 'installedThemes' => array_keys( $installed_themes ), 54 62 'browse' => array( 55 63 'sections' => $sections, 56 64 ), … … 190 198 <a class="button button-primary" href="{{ data.installURI }}"><?php esc_html_e( 'Install' ); ?></a> 191 199 <a class="button button-secondary preview install-theme-preview" href="#"><?php esc_html_e( 'Preview' ); ?></a> 192 200 </div> 201 202 <# if ( data.installed ) { #> 203 <div class="theme-installed"><?php _e( 'Already Installed' ); ?></div> 204 <# } #> 193 205 </script> 194 206 195 207 <script id="tmpl-theme-preview" type="text/template"> 196 208 <div class="wp-full-overlay-sidebar"> 197 209 <div class="wp-full-overlay-header"> 198 210 <a href="#" class="close-full-overlay button-secondary"><?php _e( 'Close' ); ?></a> 199 <a href="{{ data.installURI }}" class="button button-primary theme-install"><?php _e( 'Install' ); ?></a> 211 <# if ( data.installed ) { #> 212 <a href="#" class="button button-primary theme-install disabled"><?php _e( 'Installed' ); ?></a> 213 <# } #> 200 214 </div> 201 215 <div class="wp-full-overlay-sidebar-content"> 202 216 <div class="install-theme-info">