Ticket #27055: 27055.7.diff
| File 27055.7.diff, 29.6 KB (added by , 12 years ago) |
|---|
-
wp-admin/includes/theme.php
452 452 */ 453 453 $prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes ); 454 454 return array_values( $prepared_themes ); 455 } 456 457 458 /** 459 * Get public themes from the themes directory 460 * and prepare them for JavaScript 461 * 462 * @since 3.8.0 463 * 464 * @uses themes_api themes_directory_sections 465 * @return array with $theme objects 466 */ 467 function prepare_public_themes_for_js( $themes = array() ) { 468 469 $sections = array( 470 'featured' => __( 'Featured Themes' ), 471 'popular' => __( 'Popular Themes' ), 472 'new' => __( 'Newest Themes' ), 473 ); 474 475 $sections = array_keys( $sections ); 476 477 $args = array( 478 'page' => 1, 479 'per_page' => 24, 480 ); 481 482 foreach ( $sections as $section ) { 483 $args['browse'] = $section; 484 $themes[ $section ] = themes_api( 'query_themes', $args ); 485 } 486 487 return $themes; 455 488 } 489 No newline at end of file -
wp-admin/update.php
202 202 203 203 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. 204 204 205 check_admin_referer( 'install-theme_' . $theme);205 check_admin_referer( 'install-theme' ); 206 206 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 207 207 208 208 if ( is_wp_error($api) ) -
wp-admin/js/theme.js
12 12 themes.data = _wpThemeSettings; 13 13 l10n = themes.data.l10n; 14 14 15 // Shortcut for (bool) isBrowsing check 16 themes.isInstall = themes.data.settings.isBrowsing; 17 15 18 // Setup app structure 16 _.extend( themes, { model: {}, view: {}, routes: {}, router: {}, template: wp.template });19 _.extend( themes, { model: {}, view: {}, routes: {}, router: {}, template: wp.template, orgAPI: {} }); 17 20 18 21 themes.model = Backbone.Model.extend({}); 19 22 … … 55 58 this.$el.append( '<br class="clear"/>' ); 56 59 }, 57 60 61 // Defines search element container 62 searchContainer: $( '#wpbody h2:first' ), 63 58 64 // Search input and view 59 65 // for current theme collection 60 66 search: function() { … … 66 72 return; 67 73 } 68 74 69 view = new themes.view.Search({ collection: self.collection, parent: this }); 75 view = new themes.view.Search({ 76 collection: self.collection, 77 parent: this 78 }); 70 79 71 80 // Render and append after screen title 72 81 view.render(); 73 $('#wpbody h2:first')82 this.searchContainer 74 83 .append( $.parseHTML( '<label class="screen-reader-text" for="theme-search-input">' + l10n.search + '</label>' ) ) 75 84 .append( view.el ); 76 85 }, … … 805 814 self.view.trigger( 'theme:close' ); 806 815 self.themes.doSearch( query ); 807 816 }); 817 818 this.extraRoutes(); 819 }, 820 821 extraRoutes: function() { 822 return false; 808 823 } 809 824 }; 810 825 826 // -------------------- 827 // PUBLIC THEME BROWSER 828 // -------------------- 829 // 830 // The public theme browser relies on the basic structure of the script 831 // but overwrites some aspects of the main views 832 // 833 // The theme collection is the same but models have different attributes 834 // as determined by the public themes_api 835 // 836 // @ bool check if it's the 'browsing themes' screen 837 if ( themes.isInstall ) { 838 839 // Extend the main view controller 840 // @see themes.view.Appearance {} 841 // 842 // Overwrites properties and functions as needed 843 _.extend( themes.view.Appearance.prototype, { 844 845 el: '#wpbody-content .wrap', 846 847 // Register events for sorting and filters in theme-navigation 848 events: { 849 'click .theme-section': 'setSort', 850 'click .theme-filter': 'setFilter', 851 'click .more-filters': 'moreFilters' 852 }, 853 854 // Handles all the rendering of the public theme directory 855 install: function( section ) { 856 // Create a new collection with the proper theme data 857 // for each section 858 this.collection = new themes.Collection( themes.data.browse.publicThemes[ section ].themes ); 859 860 // Set ups the view and passes the section argument 861 this.view = new themes.view.Themes({ 862 collection: this.collection, 863 section: section, 864 parent: this 865 }); 866 867 // Reset pagination every time the install view handler is run 868 this.page = 0; 869 870 // Render and append 871 this.$el.find( '.themes' ).remove(); 872 this.view.render(); 873 this.$el.find( '.theme-browser' ).append( this.view.el ); 874 875 this.uploader(); 876 }, 877 878 // Initial render method 879 render: function() { 880 this.search(); 881 return this.install( this.options.section ); 882 }, 883 884 // Sorting navigation 885 setSort: function( event ) { 886 var $el = $( event.target ), 887 sort = $el.data( 'sort' ); 888 889 // Bail if this is already active 890 if ( $el.hasClass( this.activeClass ) ) { 891 return; 892 } 893 894 $( '#theme-search-input' ).val( '' ); 895 896 $( '.theme-section, .theme-filter' ).removeClass( this.activeClass ); 897 $el.addClass( this.activeClass ); 898 899 this.install( sort ); 900 901 // Trigger a router.naviagte update 902 themes.router.navigate( themes.router.baseUrl( '?sort=' + sort ), { replace: true } ); 903 }, 904 905 // Filters and Tags 906 setFilter: function( event ) { 907 var $el = $( event.target ), 908 filter = $el.data( 'filter' ), 909 self = this, 910 data; 911 912 // Bail if this is already active 913 if ( $el.hasClass( this.activeClass ) ) { 914 return; 915 } 916 917 $( '.theme-filter, .theme-section' ).removeClass( this.activeClass ); 918 $el.addClass( this.activeClass ); 919 920 if ( ! filter ) { 921 return; 922 } 923 924 // Construct the filter request 925 // using the default values 926 data = _.defaults( {}, themes.orgAPI.data ); 927 928 data.request = _.defaults({ 929 tag: [ filter ] 930 }, themes.orgAPI.data.request ); 931 932 // Send Ajax POST request to api.wordpress.org/themes 933 $.ajax({ 934 url: themes.orgAPI.url, 935 936 // We want JSON data 937 dataType: 'json', 938 type: 'POST', 939 940 // Request data 941 data: data, 942 943 beforeSend: function() { 944 // Spin it 945 $( 'body' ).addClass( 'loading-themes' ); 946 } 947 }) 948 .done( function( data ) { 949 // Update the collection with the queried data 950 self.collection.reset( data.themes ); 951 // Trigger a collection refresh event to render the views 952 self.collection.trigger( 'update' ); 953 954 // Un-spin it 955 $( 'body' ).removeClass( 'loading-themes' ); 956 $( '#appearance' ).find( 'div.error' ).remove(); 957 }) 958 .fail( function() { 959 $( '#appearance' ).find( 'div.error' ).remove(); 960 $( '#appearance' ).append( '<div class="error"><p>' + l10n['error'] + '</p></div>' ); 961 }); 962 }, 963 964 activeClass: 'current', 965 966 // Overwrite search container class to append search 967 // in new location 968 searchContainer: $( '.theme-navigation' ), 969 970 uploader: function() { 971 $( 'a.upload.button' ).on( 'click', function() { 972 $( '.upload-theme' ) 973 .toggleClass( 'opened' ) 974 .hasClass( 'opened' ) ? $( this ).text( l10n.back ) : $( this ).text( l10n.upload ); 975 }); 976 }, 977 978 moreFilters: function( event ) { 979 $( 'body' ).toggleClass( 'more-filters-opened' ); 980 } 981 }); 982 983 // Extend the main Search view 984 _.extend( themes.view.Search.prototype, { 985 986 events: { 987 'keyup': 'search' 988 }, 989 990 // Handles Ajax request for searching through themes in public repo 991 search: function() { 992 var data, 993 self = this; 994 995 this.collection = this.options.parent.view.collection; 996 997 // Clear on escape. 998 if ( event.type === 'keyup' && event.which === 27 ) { 999 event.target.value = ''; 1000 } 1001 1002 // Construct the main `search` request 1003 // using the default values 1004 data = _.defaults( {}, themes.orgAPI.data ); 1005 1006 data.request['search'] = event.target.value; 1007 1008 // Intercept an [author] search. 1009 // 1010 // If input value starts with `author:` send a request 1011 // for `author` instead of a regular `search` 1012 if ( event.target.value.substring( 0, 7 ) === 'author:' ) { 1013 data.request['search'] = ''; 1014 data.request['author'] = event.target.value.slice( 7 ); 1015 } 1016 1017 // Intercept a [tag] search. 1018 // 1019 // If input value starts with `tag:` send a request 1020 // for `tag` instead of a regular `search` 1021 if ( event.target.value.substring( 0, 4 ) === 'tag:' ) { 1022 data.request['search'] = ''; 1023 data.request['tag'] = [ event.target.value.slice( 4 ) ]; 1024 } 1025 1026 // Send Ajax POST request to api.wordpress.org/themes 1027 $.ajax({ 1028 url: themes.orgAPI.url, 1029 1030 // We want JSON data 1031 dataType: 'json', 1032 type: 'POST', 1033 1034 // Request data 1035 data: data, 1036 1037 beforeSend: function() { 1038 // Spin it 1039 $( 'body' ).addClass( 'loading-themes' ); 1040 } 1041 }) 1042 .done( function( data ) { 1043 // Update the collection with the queried data 1044 self.collection.reset( data.themes ); 1045 // Trigger a collection refresh event to render the views 1046 self.collection.trigger( 'update' ); 1047 1048 // Un-spin it 1049 $( 'body' ).removeClass( 'loading-themes' ); 1050 $( '#appearance' ).find( 'div.error' ).remove(); 1051 }) 1052 .fail( function() { 1053 $( '#appearance' ).find( 'div.error' ).remove(); 1054 $( '#appearance' ).append( '<div class="error"><p>' + l10n['error'] + '</p></div>' ); 1055 }); 1056 } 1057 }); 1058 1059 // Set up the `theme` model with relevant action attributes 1060 _.extend( themes.model.prototype, { 1061 1062 // Adds attributes to the defaul data coming through the .org themes api 1063 // Map `id` to `slug` for shared code 1064 initialize: function() { 1065 var actions, install, preview; 1066 1067 // Install url for the theme 1068 // using the install nonce 1069 install = { 1070 action: 'install-theme', 1071 theme: this.get( 'slug' ), 1072 _wpnonce: themes.data.settings._nonceInstall 1073 } 1074 1075 // Build the url query 1076 install = themes.data.settings.updateURI + '?' + $.param( install ); 1077 1078 // Preview url for the theme 1079 preview = { 1080 tab: 'theme-information', 1081 theme: this.get( 'slug' ) 1082 } 1083 1084 preview = themes.data.settings.installURI + '?' + $.param( preview ); 1085 1086 // Set the attributes 1087 this.set({ 1088 installURI: install, 1089 previewURI: preview, 1090 id: this.get( 'slug' ) 1091 }); 1092 } 1093 }); 1094 1095 // Store api.wordpress.org/themes values and structure 1096 // for internal access 1097 themes.orgAPI = { 1098 1099 // Default data request 1100 data: { 1101 action: 'query_themes', 1102 request: { 1103 fields: { 1104 tags: true, 1105 } 1106 } 1107 }, 1108 1109 url: 'http://api.wordpress.org/themes/info/1.1/?action=query_themes' 1110 }; 1111 1112 _.extend( themes.view.Theme.prototype.events, { 1113 'click .preview': 'preview' 1114 }); 1115 1116 _.extend( themes.view.Theme.prototype, { 1117 preview: function( event ) { 1118 event.preventDefault(); 1119 1120 event = event || window.event; 1121 1122 // this.trigger( 'theme:preview', this.model.cid ); 1123 1124 var preview = new themes.view.Preview({ 1125 model: this.model 1126 }); 1127 1128 preview.render(); 1129 $( '#appearance' ).append( preview.el ); 1130 } 1131 }); 1132 1133 // Theme Preview view 1134 // Set ups a modal overlay with the expanded theme data 1135 themes.view.Preview = wp.Backbone.View.extend({ 1136 1137 className: 'wp-full-overlay expanded', 1138 el: '#theme-installer', 1139 1140 events: { 1141 'click .close-full-overlay': 'close', 1142 'click .collapse-sidebar': 'collapse' 1143 }, 1144 1145 // The HTML template for the theme preview 1146 html: themes.template( 'theme-preview' ), 1147 1148 render: function() { 1149 var data = this.model.toJSON(); 1150 this.$el.html( this.html( data ) ); 1151 1152 themes.router.navigate( themes.router.baseUrl( '?preview=' + this.model.get( 'id' ) ), { replace: true } ); 1153 1154 this.$el.fadeIn( 200, function() { 1155 $( 'body' ).addClass( 'theme-installer-active full-overlay-active' ); 1156 }); 1157 }, 1158 1159 close: function() { 1160 this.$el.fadeOut( 200, function() { 1161 $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ); 1162 }); 1163 1164 themes.router.navigate( themes.router.baseUrl( '' ) ); 1165 }, 1166 1167 collapse: function( event ) { 1168 this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' ); 1169 } 1170 }); 1171 1172 // Modify routes 1173 _.extend( themes.routes.prototype, { 1174 routes: { 1175 'theme-install.php?theme=:slug': 'theme', 1176 '': 'themes', 1177 'theme-install.php?sort=:sortBy': 'sort', 1178 'theme-install.php?preview=:slug': 'preview' 1179 }, 1180 1181 baseUrl: function( url ) { 1182 return 'theme-install.php' + url; 1183 } 1184 }); 1185 1186 themes.Run.extraRoutes = function() { 1187 var self = this; 1188 // Handles sort route events 1189 themes.router.on( 'route:sort', function( sortBy ) { 1190 $( '.theme-section[data-sort="' + sortBy + '"]' ).trigger( 'click' ); 1191 }); 1192 }, 1193 1194 // Overwrite main application initializer 1195 themes.Run.init = function() { 1196 // Initializes the main view 1197 // and bootstraps the default sorting section 1198 1199 // Set up the view 1200 // Passes the default 'section' as an option 1201 this.view = new themes.view.Appearance({ 1202 el: $( '#appearance' ), 1203 section: 'featured' 1204 }); 1205 1206 // Render results 1207 this.render(); 1208 } 1209 1210 } 1211 811 1212 // Ready... 812 1213 jQuery( document ).ready( 813 1214 … … 843 1244 }; 844 1245 845 1246 $(window).resize(function(){ tb_position(); }); 846 }); 1247 }); 1248 No newline at end of file -
wp-admin/css/themes.css
25 25 margin-left: 20px; 26 26 } 27 27 28 .themes-php .wrap .theme-count { 28 .themes-php .wrap .theme-count, 29 .theme-navigation .theme-count { 29 30 color: #fff; 30 31 -webkit-border-radius: 30px; 31 32 border-radius: 30px; … … 1064 1065 16.2 - Install Themes 1065 1066 ------------------------------------------------------------------------------*/ 1066 1067 1067 .theme-install-php h 4{1068 margin : 2.5em 0 8px;1068 .theme-install-php h2 .upload { 1069 margin-left: 10px; 1069 1070 } 1070 1071 .theme-install-php .tablenav { 1072 height: auto; 1071 .theme-navigation { 1072 background: #fff; 1073 box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); 1074 -moz-box-sizing: border-box; 1075 box-sizing: border-box; 1076 color: #555; 1077 display: inline-block; 1078 font-size: 13px; 1079 margin: 20px 0 30px; 1080 padding: 0 20px; 1081 position: relative; 1082 width: 100%; 1073 1083 } 1074 1075 .theme-install-php .spinner { 1076 margin-top: 9px; 1077 } 1078 1079 .available-theme { 1080 display: inline-block; 1081 margin-right: 10px; 1084 .upload-theme { 1085 -moz-box-sizing: border-box; 1086 box-sizing: border-box; 1087 display: none; 1088 margin: 0px 0 0; 1089 padding: 0; 1090 width: 100%; 1082 1091 overflow: hidden; 1083 padding: 20px 20px 20px 0; 1084 vertical-align: top; 1085 width: 300px; 1092 position: relative; 1093 top: 10px; 1086 1094 } 1087 1088 .available-theme .screenshot { 1089 width: 300px; 1090 height: 225px; 1095 .upload-theme.opened { 1091 1096 display: block; 1092 border: 1px solid #ccc;1093 margin-bottom: 10px;1094 overflow: hidden;1095 background-color: #fff;1096 1097 } 1097 1098 .available-theme img { 1099 width: 300px; 1098 .upload-theme .wp-upload-form { 1099 background: #fafafa; 1100 border: 1px solid #e5e5e5; 1101 padding: 30px; 1102 margin: 30px auto; 1103 max-width: 380px; 1100 1104 } 1101 1102 .available-theme h3 { 1103 margin: 15px 0 0; 1105 .upload-theme .install-help { 1106 color: #999; 1107 font-size: 18px; 1108 font-style: normal; 1109 margin: 0; 1110 padding: 40px 0 0; 1111 text-align: center; 1104 1112 } 1105 1106 . available-theme .theme-author {1107 line-height: 18px;1113 .upload-theme.opened + .theme-navigation, 1114 .upload-theme.opened + .theme-navigation + .theme-browser { 1115 display: none; 1108 1116 } 1109 1110 .available-theme .action-links { 1111 margin-top: 10px; 1112 overflow: hidden; 1117 .theme-navigation .theme-count { 1118 top: 3px; 1119 margin-left: 0; 1113 1120 } 1114 1115 .available-theme a.screenshot:focus { 1116 border-color: #777; 1121 .theme-section, 1122 .theme-filter { 1123 border-bottom: 4px solid #fff; 1124 color: #666; 1125 cursor: pointer; 1126 display: inline-block; 1127 margin: 0 10px; 1128 padding: 15px 0; 1129 -moz-transition: border-color .1s ease-in; 1130 -webkit-transition: border-color .1s ease-in; 1117 1131 } 1118 1119 .available-theme .action-links li { 1120 float: left; 1121 padding-right: 10px; 1122 margin-right: 10px; 1123 border-right: 1px solid #dfdfdf; 1132 .theme-section.current, 1133 .theme-filter.current { 1134 border-bottom: 4px solid #666; 1135 color: #222; 1124 1136 } 1125 1126 .available-theme .action-links li { 1127 padding-right: 8px; 1128 margin-right: 8px; 1137 .theme-top-filters { 1138 display: inline-block; 1129 1139 } 1130 1131 .ie8 .available-theme .action-links li { 1132 padding-right: 7px; 1133 margin-right: 7px; 1140 .theme-navigation .more-filters { 1141 color: #666; 1142 cursor: pointer; 1143 display: inline-block; 1144 margin: 0 10px; 1145 padding: 4px 5px; 1146 -moz-transition: color .1s ease-in, background .1s ease-in; 1147 -webkit-transition: color .1s ease-in, background .1s ease-in; 1148 transition: color .1s ease-in, background .1s ease-in; 1134 1149 } 1135 1136 .available-theme .action-links li:last-child { 1137 padding-right: 0; 1138 margin-right: 0; 1139 border-right: 0; 1150 body.more-filters-opened .more-filters, 1151 .theme-navigation .more-filters.current { 1152 background: rgb(46, 162, 204); 1153 border-radius: 2px; 1154 border: none; 1155 color: #fff; 1140 1156 } 1141 1142 .available-theme .action-links .delete-theme { 1143 float: right; 1144 margin-left: 8px; 1145 margin-right: 0; 1157 .theme-install-php .theme-search { 1158 position: absolute; 1159 right: 10px; 1160 top: 9px; 1161 font-size: 16px; 1162 font-weight: 300; 1163 line-height: 1.5; 1164 width: 280px; 1146 1165 } 1147 1148 .available-theme .action-links .delete-theme a { 1149 color: red; 1150 padding: 2px; 1166 .more-filters:before { 1167 color: #777; 1168 text-align: center; 1169 margin: 0 5px 0 0; 1170 content: "\f111"; 1171 display: inline-block; 1172 width: 16px; 1173 height: 16px; 1174 -webkit-font-smoothing: antialiased; 1175 font-size: 16px; 1176 line-height: 1; 1177 font-family: "dashicons"; 1178 text-decoration: inherit; 1179 font-weight: normal; 1180 font-style: normal; 1181 vertical-align: top; 1182 -moz-transition: color .1s ease-in 0; 1183 -webkit-transition: color .1s ease-in 0; 1184 transition: color .1s ease-in 0; 1185 text-align: center; 1151 1186 } 1152 1153 .available-theme .action-links .delete-theme a:hover { 1154 background: red; 1187 .more-filters.current:before { 1155 1188 color: #fff; 1156 text-decoration: none;1157 1189 } 1158 1159 .available-theme .action-links p { 1160 float: left; 1190 .more-filters-container { 1191 display: none; 1192 padding: 30px; 1193 border-top: 1px solid #eee; 1194 margin: 0 -20px; 1195 background: #fafafa; 1161 1196 } 1162 1163 /* Allow for three-up in small windows when sidebar is collapsed */ 1164 @media only screen and (max-width: 1200px) { 1165 .folded .available-theme, 1166 .folded .available-theme .screenshot { 1167 width: 300px; 1168 } 1169 1170 .folded .available-theme .screenshot { 1171 height: 225px; 1172 } 1197 body.more-filters-opened .more-filters-container { 1198 display: block; 1173 1199 } 1174 1175 /* Adjust three-up display in smaller windows when sidebar is collapsed */ 1176 @media only screen and (max-width: 1079px) { 1177 .folded .available-theme, 1178 .folded .available-theme .screenshot { 1179 width: 270px; 1180 } 1181 1182 .folded .available-theme .screenshot { 1183 height: 203px; 1184 } 1200 .theme-install-php .add-new-theme { 1201 display: none !important; 1185 1202 } 1186 1203 1187 /* Allow for three-up on 1024px wide screens, e.g. tablets */ 1188 @media only screen and (max-width: 1200px) { 1189 .available-theme, 1190 .available-theme .screenshot { 1191 width: 240px; 1192 } 1193 1194 .available-theme .screenshot { 1195 height: 180px; 1196 } 1197 1198 .available-theme img { 1199 width: 100%; 1200 } 1204 .rating { 1205 margin: 30px 0; 1201 1206 } 1202 1203 .feature-filter { 1204 padding: 8px 12px 0; 1205 } 1206 1207 .feature-filter .feature-group { 1208 float: left; 1209 margin: 5px 10px 10px; 1210 } 1211 1212 .feature-filter .feature-group li { 1207 .rating span:before { 1208 color: #e6b800; 1209 content: "\f154"; 1213 1210 display: inline-block; 1211 -webkit-font-smoothing: antialiased; 1212 font: normal 20px/1 'dashicons'; 1214 1213 vertical-align: top; 1215 list-style-type: none;1216 padding-right: 25px;1217 width: 150px;1218 1214 } 1215 /* Half stars */ 1216 .rating-10 span.one:before, 1217 .rating-30 span.two:before, 1218 .rating-50 span.three:before, 1219 .rating-70 span.four:before, 1220 .rating-90 span.five:before { 1221 content: "\f459"; 1222 } 1223 /* Full stars */ 1224 .rating-20 span.one:before { 1225 content: "\f155"; 1226 } 1227 .rating-30 span.one:before, 1228 .rating-40 span.one:before, 1229 .rating-40 span.two:before { 1230 content: "\f155"; 1231 } 1232 .rating-50 span.one:before, 1233 .rating-50 span.two:before, 1234 .rating-60 span.one:before, 1235 .rating-60 span.two:before, 1236 .rating-60 span.three:before { 1237 content: "\f155"; 1238 } 1239 .rating-70 span.one:before, 1240 .rating-70 span.two:before, 1241 .rating-70 span.three:before, 1242 .rating-80 span.one:before, 1243 .rating-80 span.two:before, 1244 .rating-80 span.three:before, 1245 .rating-80 span.four:before { 1246 content: "\f155"; 1247 } 1248 .rating-90 span.one:before, 1249 .rating-90 span.two:before, 1250 .rating-90 span.three:before, 1251 .rating-90 span.four:before, 1252 .rating-100 span.one:before, 1253 .rating-100 span.two:before, 1254 .rating-100 span.three:before, 1255 .rating-100 span.four:before, 1256 .rating-100 span.five:before { 1257 content: "\f155"; 1258 } 1259 .rating .votes { 1260 display: inline; 1261 margin-left: 10px; 1262 line-height: 20px; 1263 } 1264 .loading-themes .theme-browser, 1265 .error .theme-browser { 1266 display: none; 1267 } 1268 .loading-themes .spinner { 1269 display: block; 1270 margin: 40px auto 0; 1271 float: none; 1272 } 1219 1273 1220 1274 /*------------------------------------------------------------------------------ 1221 1275 16.3 - Custom Header Screen -
wp-admin/theme-install.php
20 20 exit(); 21 21 } 22 22 23 $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');24 $pagenum = $wp_list_table->get_pagenum();25 $wp_list_table->prepare_items();23 // $wp_list_table = _get_list_table('WP_Theme_Install_List_Table'); 24 // $pagenum = $wp_list_table->get_pagenum(); 25 // $wp_list_table->prepare_items(); 26 26 27 $title = __( 'Install Themes');27 $title = __( 'Add Themes' ); 28 28 $parent_file = 'themes.php'; 29 if ( !is_network_admin() ) 29 30 if ( ! is_network_admin() ) { 30 31 $submenu_file = 'themes.php'; 32 } 31 33 32 wp_enqueue_script( 'theme-install' );34 // wp_enqueue_script( 'theme-install' ); 33 35 wp_enqueue_script( 'theme-preview' ); 34 36 35 $body_id = $tab; 37 wp_localize_script( 'theme', '_wpThemeSettings', array( 38 'themes' => false, 39 'settings' => array( 40 'isBrowsing' => (bool) ( get_current_screen()->id == 'theme-install' ), 41 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 42 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 43 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ), 44 'updateURI' => admin_url( 'update.php' ), 45 '_nonceInstall' => wp_create_nonce( 'install-theme' ) 46 ), 47 'l10n' => array( 48 'addNew' => __( 'Add New Theme' ), 49 'search' => __( 'Search Themes' ), 50 'searchPlaceholder' => __( 'Search themes...' ), 51 'upload' => __( 'Upload Theme' ), 52 'back' => __( 'Back' ), 53 'error' => __( 'There was a problem trying to load the themes. Please, try again.' ), 54 ), 55 'browse' => array( 56 'sections' => apply_filters( 'install_theme_sections', array( 57 'featured' => __( 'Featured Themes' ), 58 'popular' => __( 'Popular Themes' ), 59 'new' => __( 'Newest Themes' ), 60 ) ), 61 'publicThemes' => ( get_current_screen()->id == 'theme-install' ) ? prepare_public_themes_for_js() : null, 62 ), 63 ) ); 36 64 65 wp_enqueue_script( 'theme' ); 66 67 // $body_id = $tab; 68 37 69 /** 38 70 * Fires before each of the tabs are rendered on the Install Themes page. 39 71 * … … 43 75 * 44 76 * @since 2.8.0 45 77 */ 46 do_action( "install_themes_pre_{$tab}" );78 // do_action( "install_themes_pre_{$tab}" ); 47 79 48 80 $help_overview = 49 81 '<p>' . sprintf(__('You can find additional themes for your site by using the Theme Browser/Installer on this screen, which will display themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. These themes are designed and developed by third parties, are available free of charge, and are compatible with the license WordPress uses.'), 'http://wordpress.org/themes/') . '</p>' . … … 73 105 ); 74 106 75 107 include(ABSPATH . 'wp-admin/admin-header.php'); 108 109 /** 110 * Uploader 111 */ 112 function install_themes_upload() { 113 ?> 114 <div class="upload-theme"> 115 <p class="install-help"><?php _e( 'If you have a theme in a .zip format, you may install it by uploading it here.' ); ?></p> 116 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>"> 117 <?php wp_nonce_field( 'theme-upload'); ?> 118 <input type="file" name="themezip" /> 119 <?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?> 120 </form> 121 </div> 122 <?php 123 } 124 add_action( 'install_themes_upload', 'install_themes_upload', 10, 1 ); 125 76 126 ?> 77 <div class="wrap"> 78 <h2><?php echo esc_html( $title ); ?></h2> 79 <?php 127 <div id="appearance" class="wrap"> 128 <h2> 129 <?php echo esc_html( $title ); ?> 130 <a class="upload button button-secondary"><?php esc_html_e( 'Upload Theme' ); ?></a> 131 </h2> 80 132 81 $wp_list_table->views(); ?>133 <?php install_themes_upload(); ?> 82 134 83 <br class="clear" /> 135 <div class="theme-navigation"> 136 <span class="theme-count"></span> 137 <span class="theme-section current" data-sort="featured"><?php esc_html_e( 'Featured' ); ?></span> 138 <span class="theme-section" data-sort="popular"><?php esc_html_e( 'Popular' ); ?></span> 139 <span class="theme-section" data-sort="new"><?php esc_html_e( 'Latest' ); ?></span> 140 <div class="theme-top-filters"> 141 <span class="theme-filter" data-filter="photoblogging">Photography</span> 142 <span class="theme-filter" data-filter="responsive-layout">Responsive</span> 143 <span class="theme-filter more-filters">More</span> 144 </div> 145 <div class="more-filters-container"> 146 Display more filters. 147 </div> 148 </div> 149 <div class="theme-browser"></div> 150 <div class="theme-overlay"></div> 151 <div id="theme-installer" class="wp-full-overlay expanded"></div> 152 153 <span class="spinner"></span> 154 155 <br class="clear" /> 84 156 <?php 85 157 /** 86 158 * Fires at the top of each of the tabs on the Install Themes page. … … 93 165 * 94 166 * @param int $paged Number of the current page of results being viewed. 95 167 */ 96 do_action( "install_themes_{$tab}", $paged );168 // do_action( "install_themes_{$tab}", $paged ); 97 169 ?> 98 170 </div> 171 172 173 <script id="tmpl-theme" type="text/template"> 174 <# if ( data.screenshot_url ) { #> 175 <div class="theme-screenshot"> 176 <img src="{{ data.screenshot_url }}" alt="" /> 177 </div> 178 <# } else { #> 179 <div class="theme-screenshot blank"></div> 180 <# } #> 181 <span class="more-details"><?php _e( 'Theme Details' ); ?></span> 182 <div class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></div> 183 <h3 class="theme-name">{{{ data.name }}}</h3> 184 185 <div class="theme-actions"> 186 <a class="button button-primary" href="{{{ data.installURI }}}"><?php esc_html_e( 'Install' ); ?></a> 187 <a class="button button-secondary preview install-theme-preview" href=""><?php esc_html_e( 'Preview' ); ?></a> 188 </div> 189 </script> 190 191 <script id="tmpl-theme-single" type="text/template"> 192 <div class="theme-backdrop"></div> 193 <div class="theme-wrap"> 194 <div class="theme-header"> 195 <button alt="<?php _e( 'Show previous theme' ); ?>" class="left dashicons dashicons-no"></button> 196 <button alt="<?php _e( 'Show next theme' ); ?>" class="right dashicons dashicons-no"></button> 197 <button alt="<?php _e( 'Close overlay' ); ?>" class="close dashicons dashicons-no"></button> 198 </div> 199 <div class="theme-about"> 200 <div class="theme-screenshots"> 201 <# if ( data.screenshot_url ) { #> 202 <div class="screenshot"><img src="{{ data.screenshot_url }}" alt="" /></div> 203 <# } else { #> 204 <div class="screenshot blank"></div> 205 <# } #> 206 </div> 207 208 <div class="theme-info"> 209 <h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{{ data.version }}}' ); ?></span></h3> 210 <h4 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></h4> 211 <p class="theme-description">{{{ data.description }}}</p> 212 213 <div class="rating rating-{{ Math.round( data.rating / 10 ) * 10 }}"> 214 <span class="one"></span> 215 <span class="two"></span> 216 <span class="three"></span> 217 <span class="four"></span> 218 <span class="five"></span> 219 <p class="votes"><?php printf( __( 'Based on %s ratings.' ), '{{{ data.num_ratings }}}' ); ?></p> 220 </div> 221 222 <# if ( data.tags ) { #> 223 <p class="theme-tags"> 224 <span><?php _e( 'Tags:' ); ?></span> 225 <# _.each( data.tags, function( tag ) { #> 226 {{{ tag }}} 227 <# }); #> 228 </p> 229 <# } #> 230 </div> 231 </div> 232 233 <div class="theme-actions"> 234 <a href="{{{ data.installURI }}}" class="button button-primary"><?php _e( 'Install' ); ?></a> 235 <a href="" class="button button-secondary"><?php _e( 'Preview' ); ?></a> 236 <a href="{{{ data.homepage }}}" class="button button-secondary"><?php _e( 'More Info' ); ?></a> 237 </div> 238 </div> 239 </script> 240 241 <script id="tmpl-theme-preview" type="text/template"> 242 <div class="wp-full-overlay-sidebar"> 243 <div class="wp-full-overlay-header"> 244 <a href="" class="close-full-overlay button-secondary"><?php _e( 'Close' ); ?></a> 245 <a href="{{{ data.installURI }}}" class="button button-primary theme-install"><?php _e( 'Install' ); ?></a> 246 </div> 247 <div class="wp-full-overlay-sidebar-content"> 248 <div class="install-theme-info"> 249 <h3 class="theme-name">{{{ data.name }}}</h3> 250 <span class="theme-by"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></span> 251 252 <img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" /> 253 254 <div class="theme-details"> 255 <div class="star-rating" title="4.5 rating based on 25 ratings"></div> 256 <div class="theme-version"><?php printf( __( 'Version: %s' ), '{{{ data.version }}}' ); ?></div> 257 <div class="theme-description">{{{ data.description }}}</div> 258 </div> 259 </div> 260 </div> 261 <div class="wp-full-overlay-footer"> 262 <a href="" class="collapse-sidebar" title="<?php esc_attr_e( 'Collapse Sidebar' ); ?>"> 263 <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span> 264 <span class="collapse-sidebar-arrow"></span> 265 </a> 266 </div> 267 </div> 268 <div class="wp-full-overlay-main"> 269 <iframe src="{{{ data.preview_url }}}" /> 270 </div> 271 </script> 272 99 273 <?php 100 274 include(ABSPATH . 'wp-admin/admin-footer.php');