]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/theme-install.php
WordPress 4.2.4
[autoinstalls/wordpress.git] / wp-admin / theme-install.php
1 <?php
2 /**
3  * Install theme administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once( dirname( __FILE__ ) . '/admin.php' );
11 require( ABSPATH . 'wp-admin/includes/theme-install.php' );
12
13 wp_reset_vars( array( 'tab' ) );
14
15 if ( ! current_user_can('install_themes') )
16         wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
17
18 if ( is_multisite() && ! is_network_admin() ) {
19         wp_redirect( network_admin_url( 'theme-install.php' ) );
20         exit();
21 }
22
23 $title = __( 'Add Themes' );
24 $parent_file = 'themes.php';
25
26 if ( ! is_network_admin() ) {
27         $submenu_file = 'themes.php';
28 }
29
30 $installed_themes = search_theme_directories();
31 foreach ( $installed_themes as $k => $v ) {
32         if ( false !== strpos( $k, '/' ) ) {
33                 unset( $installed_themes[ $k ] );
34         }
35 }
36
37 wp_localize_script( 'theme', '_wpThemeSettings', array(
38         'themes'   => false,
39         'settings' => array(
40                 'isInstall'     => true,
41                 'canInstall'    => current_user_can( 'install_themes' ),
42                 'installURI'    => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null,
43                 'adminUrl'      => parse_url( self_admin_url(), PHP_URL_PATH )
44         ),
45         'l10n' => array(
46                 'addNew' => __( 'Add New Theme' ),
47                 'search' => __( 'Search Themes' ),
48                 'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis)
49                 'upload' => __( 'Upload Theme' ),
50                 'back'   => __( 'Back' ),
51                 'error'  => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ),
52                 'themesFound'   => __( 'Number of Themes found: %d' ),
53                 'noThemesFound' => __( 'No themes found. Try a different search.' ),
54         ),
55         'installedThemes' => array_keys( $installed_themes ),
56 ) );
57
58 wp_enqueue_script( 'theme' );
59
60 if ( $tab ) {
61         /**
62          * Fires before each of the tabs are rendered on the Install Themes page.
63          *
64          * The dynamic portion of the hook name, `$tab`, refers to the current
65          * theme install tab. Possible values are 'dashboard', 'search', 'upload',
66          * 'featured', 'new', or 'updated'.
67          *
68          * @since 2.8.0
69          */
70         do_action( "install_themes_pre_{$tab}" );
71 }
72
73 $help_overview =
74         '<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.'), 'https://wordpress.org/themes/') . '</p>' .
75         '<p>' . __( 'You can Search for themes by keyword, author, or tag, or can get more specific and search by criteria listed in the feature filter.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
76         '<p>' . __( 'Alternately, you can browse the themes that are Featured, Popular, or Latest. When you find a theme you like, you can preview it or install it.' ) . '</p>' .
77         '<p>' . __('You can Upload a theme manually if you have already downloaded its ZIP archive onto your computer (make sure it is from a trusted and original source). You can also do it the old-fashioned way and copy a downloaded theme&#8217;s folder via FTP into your <code>/wp-content/themes</code> directory.') . '</p>';
78
79 get_current_screen()->add_help_tab( array(
80         'id'      => 'overview',
81         'title'   => __('Overview'),
82         'content' => $help_overview
83 ) );
84
85 $help_installing =
86         '<p>' . __('Once you have generated a list of themes, you can preview and install any of them. Click on the thumbnail of the theme you&#8217;re interested in previewing. It will open up in a full-screen Preview page to give you a better idea of how that theme will look.') . '</p>' .
87         '<p>' . __('To install the theme so you can preview it with your site&#8217;s content and customize its theme options, click the "Install" button at the top of the left-hand pane. The theme files will be downloaded to your website automatically. When this is complete, the theme is now available for activation, which you can do by clicking the "Activate" link, or by navigating to your Manage Themes screen and clicking the "Live Preview" link under any installed theme&#8217;s thumbnail image.') . '</p>';
88
89 get_current_screen()->add_help_tab( array(
90         'id'      => 'installing',
91         'title'   => __('Previewing and Installing'),
92         'content' => $help_installing
93 ) );
94
95 get_current_screen()->set_help_sidebar(
96         '<p><strong>' . __('For more information:') . '</strong></p>' .
97         '<p>' . __('<a href="https://codex.wordpress.org/Using_Themes#Adding_New_Themes" target="_blank">Documentation on Adding New Themes</a>') . '</p>' .
98         '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
99 );
100
101 include(ABSPATH . 'wp-admin/admin-header.php');
102
103 ?>
104 <div class="wrap">
105         <h2><?php
106         echo esc_html( $title );
107
108         /**
109          * Filter the tabs shown on the Add Themes screen.
110          *
111          * This filter is for backwards compatibility only, for the suppression
112          * of the upload tab.
113          *
114          * @since 2.8.0
115          *
116          * @param array $tabs The tabs shown on the Add Themes screen. Default is 'upload'.
117          */
118         $tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) );
119         if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) {
120                 echo ' <a href="#" class="upload add-new-h2">' . __( 'Upload Theme' ) . '</a>';
121                 echo ' <a href="#" class="browse-themes add-new-h2">' . _x( 'Browse', 'themes' ) . '</a>';
122         }
123         ?></h2>
124
125         <div class="upload-theme">
126         <?php install_themes_upload(); ?>
127         </div>
128
129         <div class="wp-filter">
130                 <div class="filter-count">
131                         <span class="count theme-count"></span>
132                 </div>
133
134                 <ul class="filter-links">
135                         <li><a href="#" data-sort="featured"><?php _ex( 'Featured', 'themes' ); ?></a></li>
136                         <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li>
137                         <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li>
138                 </ul>
139
140                 <a class="drawer-toggle" href="#"><?php _e( 'Feature Filter' ); ?></a>
141
142                 <div class="search-form"></div>
143
144                 <div class="filter-drawer">
145                         <div class="buttons">
146                                 <a class="apply-filters button button-secondary" href="#"><?php _e( 'Apply Filters' ); ?><span></span></a>
147                                 <a class="clear-filters button button-secondary" href="#"><?php _e( 'Clear' ); ?></a>
148                         </div>
149                 <?php
150                 $feature_list = get_theme_feature_list();
151                 foreach ( $feature_list as $feature_name => $features ) {
152                         echo '<div class="filter-group">';
153                         $feature_name = esc_html( $feature_name );
154                         echo '<h4>' . $feature_name . '</h4>';
155                         echo '<ol class="feature-group">';
156                         foreach ( $features as $feature => $feature_name ) {
157                                 $feature = esc_attr( $feature );
158                                 echo '<li><input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> ';
159                                 echo '<label for="filter-id-' . $feature . '">' . $feature_name . '</label></li>';
160                         }
161                         echo '</ol>';
162                         echo '</div>';
163                 }
164                 ?>
165                         <div class="filtered-by">
166                                 <span><?php _e( 'Filtering by:' ); ?></span>
167                                 <div class="tags"></div>
168                                 <a href="#"><?php _e( 'Edit' ); ?></a>
169                         </div>
170                 </div>
171         </div>
172         <div class="theme-browser content-filterable"></div>
173         <div class="theme-install-overlay wp-full-overlay expanded"></div>
174
175         <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
176         <span class="spinner"></span>
177
178         <br class="clear" />
179 <?php
180 if ( $tab ) {
181         /**
182          * Fires at the top of each of the tabs on the Install Themes page.
183          *
184          * The dynamic portion of the hook name, `$tab`, refers to the current
185          * theme install tab. Possible values are 'dashboard', 'search', 'upload',
186          * 'featured', 'new', or 'updated'.
187          *
188          * @since 2.8.0
189          *
190          * @param int $paged Number of the current page of results being viewed.
191          */
192         do_action( "install_themes_{$tab}", $paged );
193 }
194 ?>
195 </div>
196
197 <script id="tmpl-theme" type="text/template">
198         <# if ( data.screenshot_url ) { #>
199                 <div class="theme-screenshot">
200                         <img src="{{ data.screenshot_url }}" alt="" />
201                 </div>
202         <# } else { #>
203                 <div class="theme-screenshot blank"></div>
204         <# } #>
205         <span class="more-details"><?php _ex( 'Details &amp; Preview', 'theme' ); ?></span>
206         <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.author }}' ); ?></div>
207         <h3 class="theme-name">{{ data.name }}</h3>
208
209         <div class="theme-actions">
210                 <a class="button button-primary" href="{{ data.install_url }}"><?php esc_html_e( 'Install' ); ?></a>
211                 <a class="button button-secondary preview install-theme-preview" href="#"><?php esc_html_e( 'Preview' ); ?></a>
212         </div>
213
214         <# if ( data.installed ) { #>
215                 <div class="theme-installed"><?php _ex( 'Already Installed', 'theme' ); ?></div>
216         <# } #>
217 </script>
218
219 <script id="tmpl-theme-preview" type="text/template">
220         <div class="wp-full-overlay-sidebar">
221                 <div class="wp-full-overlay-header">
222                         <a href="#" class="close-full-overlay"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></a>
223                         <a href="#" class="previous-theme"><span class="screen-reader-text"><?php _ex( 'Previous', 'Button label for a theme' ); ?></span></a>
224                         <a href="#" class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a theme' ); ?></span></a>
225                 <# if ( data.installed ) { #>
226                         <a href="#" class="button button-primary theme-install disabled"><?php _ex( 'Installed', 'theme' ); ?></a>
227                 <# } else { #>
228                         <a href="{{ data.install_url }}" class="button button-primary theme-install"><?php _e( 'Install' ); ?></a>
229                 <# } #>
230                 </div>
231                 <div class="wp-full-overlay-sidebar-content">
232                         <div class="install-theme-info">
233                                 <h3 class="theme-name">{{ data.name }}</h3>
234                                 <span class="theme-by"><?php printf( __( 'By %s' ), '{{ data.author }}' ); ?></span>
235
236                                 <img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
237
238                                 <div class="theme-details">
239                                         <# if ( data.rating ) { #>
240                                                 <div class="rating rating-{{ Math.round( data.rating / 10 ) * 10 }}">
241                                                         <span class="one"></span>
242                                                         <span class="two"></span>
243                                                         <span class="three"></span>
244                                                         <span class="four"></span>
245                                                         <span class="five"></span>
246                                                         <small class="ratings">{{ data.num_ratings }}</small>
247                                                 </div>
248                                         <# } else { #>
249                                                 <div class="rating">
250                                                         <small class="ratings"><?php _e( 'This theme has not been rated yet.' ); ?></small>
251                                                 </div>
252                                         <# } #>
253                                         <div class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></div>
254                                         <div class="theme-description">{{{ data.description }}}</div>
255                                 </div>
256                         </div>
257                 </div>
258                 <div class="wp-full-overlay-footer">
259                         <a href="#" class="collapse-sidebar" title="<?php esc_attr_e( 'Collapse Sidebar' ); ?>">
260                                 <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span>
261                                 <span class="collapse-sidebar-arrow"></span>
262                         </a>
263                 </div>
264         </div>
265         <div class="wp-full-overlay-main">
266                 <iframe src="{{ data.preview_url }}" title="<?php esc_attr_e( 'Preview' ); ?>" />
267         </div>
268 </script>
269
270 <?php
271 include(ABSPATH . 'wp-admin/admin-footer.php');