]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/themes.php
Wordpress 3.3
[autoinstalls/wordpress.git] / wp-admin / themes.php
1 <?php
2 /**
3  * Themes administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('./admin.php');
11
12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
13         wp_die( __( 'Cheatin&#8217; uh?' ) );
14
15 $wp_list_table = _get_list_table('WP_Themes_List_Table');
16
17 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
18         if ( 'activate' == $_GET['action'] ) {
19                 check_admin_referer('switch-theme_' . $_GET['template']);
20                 switch_theme($_GET['template'], $_GET['stylesheet']);
21                 wp_redirect( admin_url('themes.php?activated=true') );
22                 exit;
23         } elseif ( 'delete' == $_GET['action'] ) {
24                 check_admin_referer('delete-theme_' . $_GET['template']);
25                 if ( !current_user_can('delete_themes') )
26                         wp_die( __( 'Cheatin&#8217; uh?' ) );
27                 delete_theme($_GET['template']);
28                 wp_redirect( admin_url('themes.php?deleted=true') );
29                 exit;
30         }
31 }
32
33 $wp_list_table->prepare_items();
34
35 $title = __('Manage Themes');
36 $parent_file = 'themes.php';
37
38 if ( current_user_can( 'switch_themes' ) ) :
39
40 $help_manage = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>' .
41         '<p>' . __('You can see your active theme at the top of the screen. Below are the other themes you have installed that are not currently in use. You can see what your site would look like with one of these themes by clicking the Preview link. To change themes, click the Activate link.') . '</p>';
42
43 get_current_screen()->add_help_tab( array(
44         'id'      => 'overview',
45         'title'   => __('Overview'),
46         'content' => $help_manage,
47 ) );
48
49 if ( current_user_can( 'install_themes' ) ) {
50         if ( is_multisite() ) {
51                 $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
52         } else {
53                 $help_install = '<p>' . sprintf( __('If you would like to see more themes to choose from, click on the &#8220;Install Themes&#8221; tab and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!'), 'http://wordpress.org/extend/themes/' ) . '</p>';
54         }
55
56         get_current_screen()->add_help_tab( array(
57                 'id'      => 'adding-themes',
58                 'title'   => __('Adding Themes'),
59                 'content' => $help_install,
60         ) );
61 }
62
63 get_current_screen()->set_help_sidebar(
64         '<p><strong>' . __('For more information:') . '</strong></p>' .
65         '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
66         '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
67 );
68
69 add_thickbox();
70 wp_enqueue_script( 'theme-preview' );
71 wp_enqueue_script( 'theme' );
72
73 endif;
74
75 require_once('./admin-header.php');
76 ?>
77
78 <?php if ( ! validate_current_theme() ) : ?>
79 <div id="message1" class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
80 <?php elseif ( isset($_GET['activated']) ) :
81                 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?>
82 <div id="message2" class="updated"><p><?php printf( __('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url( 'widgets.php' ) ); ?></p></div><?php
83                 } else { ?>
84 <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php
85                 }
86         elseif ( isset($_GET['deleted']) ) : ?>
87 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div>
88 <?php endif; ?>
89
90 <div class="wrap"><?php
91 screen_icon();
92 if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
93 <h2 class="nav-tab-wrapper">
94 <a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a><a href="<?php echo admin_url( 'theme-install.php'); ?>" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a>
95 <?php else : ?>
96 <h2><?php echo esc_html( $title ); ?>
97 <?php endif; ?>
98 </h2>
99
100 <h3><?php _e('Current Theme'); ?></h3>
101 <div id="current-theme">
102 <?php if ( $ct->screenshot ) : ?>
103 <img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php esc_attr_e('Current theme preview'); ?>" />
104 <?php endif; ?>
105 <h4><?php
106         /* translators: 1: theme title, 2: theme version, 3: theme author */
107         printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4>
108 <p class="theme-description"><?php echo $ct->description; ?></p>
109 <div class="theme-options">
110         <span><?php _e( 'Options:' )?></span>
111         <?php
112         // Pretend you didn't see this.
113         $options = array();
114         if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
115                 foreach ( (array) $submenu['themes.php'] as $item) {
116                         $class = '';
117                         if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] )
118                                 continue;
119                         // 0 = name, 1 = capability, 2 = file
120                         if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) $class = ' class="current"';
121
122                         if ( !empty($submenu[$item[2]]) ) {
123                                 $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
124                                 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
125                                 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
126                                         $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
127                                 else
128                                         $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
129                         } else if ( current_user_can($item[1]) ) {
130                                 if ( file_exists(ABSPATH . 'wp-admin/' . $item[2]) ) {
131                                         $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
132                                 } else {
133                                         $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
134                                 }
135                         }
136                 }
137         }
138         echo implode ( ' | ', $options );
139
140         if ( $ct->tags ) : ?>
141         <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
142         <?php endif; ?>
143 </div>
144 <?php theme_update_available($ct); ?>
145
146 </div>
147
148 <br class="clear" />
149 <?php
150 if ( ! current_user_can( 'switch_themes' ) ) {
151         echo '</div>';
152         require( './admin-footer.php' );
153         exit;
154 }
155 ?>
156
157 <h3><?php _e('Available Themes'); ?></h3>
158
159 <?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['filter'] ) || $wp_list_table->has_items() ) : ?>
160
161 <form class="search-form filter-form" action="" method="get">
162
163 <p class="search-box">
164         <label class="screen-reader-text" for="theme-search-input"><?php _e('Search Installed Themes'); ?>:</label>
165         <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
166         <?php submit_button( __( 'Search Installed Themes' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
167         <a id="filter-click" href="?filter=1"><?php _e( 'Feature Filter' ); ?></a>
168 </p>
169
170 <br class="clear"/>
171
172 <div id="filter-box" style="<?php if ( empty($_REQUEST['filter']) ) echo 'display: none;'; ?>">
173 <?php $feature_list = get_theme_feature_list(); ?>
174         <div class="feature-filter">
175                 <p class="install-help"><?php _e('Theme filters') ?></p>
176         <?php if ( !empty( $_REQUEST['filter'] ) ) : ?>
177                 <input type="hidden" name="filter" value="1" />
178         <?php endif; ?>
179         <?php foreach ( $feature_list as $feature_name => $features ) :
180                         $feature_name = esc_html( $feature_name ); ?>
181
182                 <div class="feature-container">
183                         <div class="feature-name"><?php echo $feature_name ?></div>
184
185                         <ol class="feature-group">
186                                 <?php foreach ( $features as $key => $feature ) :
187                                                 $feature_name = $feature;
188                                                 $feature_name = esc_html( $feature_name );
189                                                 $feature = esc_attr( $feature );
190                                                 ?>
191                                 <li>
192                                         <input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
193                                         <label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label>
194                                 </li>
195                                 <?php endforeach; ?>
196                         </ol>
197                 </div>
198         <?php endforeach; ?>
199
200         <div class="feature-container">
201                 <?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', false, false, array( 'style' => 'margin-left: 120px', 'id' => 'filter-submit' ) ); ?>
202                 &nbsp;
203                 <small><a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a></small>
204         </div>
205         <br/>
206         </div>
207         <br class="clear"/>
208 </div>
209
210 <br class="clear" />
211
212 <?php endif; ?>
213
214 <?php $wp_list_table->display(); ?>
215
216 </form>
217 <br class="clear" />
218
219 <?php
220 // List broken themes, if any.
221 $broken_themes = get_broken_themes();
222 if ( current_user_can('edit_themes') && count( $broken_themes ) ) {
223 ?>
224
225 <h3><?php _e('Broken Themes'); ?></h3>
226 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
227
228 <table id="broken-themes">
229         <tr>
230                 <th><?php _ex('Name', 'theme name'); ?></th>
231                 <th><?php _e('Description'); ?></th>
232         </tr>
233 <?php
234         $theme = '';
235
236         $theme_names = array_keys($broken_themes);
237         natcasesort($theme_names);
238
239         foreach ($theme_names as $theme_name) {
240                 $title = $broken_themes[$theme_name]['Title'];
241                 $description = $broken_themes[$theme_name]['Description'];
242
243                 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
244                 echo "
245                 <tr $theme>
246                          <td>$title</td>
247                          <td>$description</td>
248                 </tr>";
249         }
250 ?>
251 </table>
252 <?php
253 }
254 ?>
255 </div>
256
257 <?php require('./admin-footer.php'); ?>