| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress MU 2.9.2Provided by Yoast |
[Summary view] [Print] [Text view]
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') ) 13 wp_die( __( 'Cheatin’ uh?' ) ); 14 15 if ( is_multisite() ) { 16 $themes = get_themes(); 17 $ct = current_theme_info(); 18 $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() ); 19 if( $allowed_themes == false ) 20 $allowed_themes = array(); 21 22 $blog_allowed_themes = wpmu_get_blog_allowedthemes(); 23 if( is_array( $blog_allowed_themes ) ) 24 $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes ); 25 if( $blog_id != 1 ) 26 unset( $allowed_themes[ "h3" ] ); 27 28 if( isset( $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] ) == false ) 29 $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] = true; 30 31 reset( $themes ); 32 foreach( $themes as $key => $theme ) { 33 if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) { 34 unset( $themes[ $key ] ); 35 } 36 } 37 reset( $themes ); 38 } 39 if ( isset($_GET['action']) ) { 40 if ( 'activate' == $_GET['action'] ) { 41 check_admin_referer('switch-theme_' . $_GET['template']); 42 switch_theme($_GET['template'], $_GET['stylesheet']); 43 wp_redirect('themes.php?activated=true'); 44 exit; 45 } else if ( 'delete' == $_GET['action'] ) { 46 check_admin_referer('delete-theme_' . $_GET['template']); 47 if ( !current_user_can('update_themes') ) 48 wp_die( __( 'Cheatin’ uh?' ) ); 49 delete_theme($_GET['template']); 50 wp_redirect('themes.php?deleted=true'); 51 exit; 52 } 53 } 54 55 $title = __('Manage Themes'); 56 $parent_file = 'themes.php'; 57 58 $help = '<p>' . __('Themes give your WordPress style. Once a theme is installed, you may preview it, activate it or deactivate it here.') . '</p>'; 59 if ( is_multisite() && is_site_admin() || is_multisite() == false && current_user_can('install_themes') ) { 60 $help .= '<p>' . sprintf(__('You can find additional themes for your site by using the new <a href="%1$s">Theme Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/themes/">WordPress Theme Directory</a> directly and installing manually. To install a theme <em>manually</em>, <a href="%2$s">upload its ZIP archive with the new uploader</a> or copy its folder via FTP into your <code>wp-content/themes</code> directory.'), 'theme-install.php', 'theme-install.php?tab=upload' ) . '</p>'; 61 $help .= '<p>' . __('Once a theme is uploaded, you should see it on this page.') . '</p>' ; 62 } 63 64 add_contextual_help('themes', $help); 65 66 add_thickbox(); 67 wp_enqueue_script( 'theme-preview' ); 68 69 require_once ('admin-header.php'); 70 if( is_multisite() && is_site_admin() ) { 71 ?><div id="message0" class="updated fade"><p><?php _e('Administrator: new themes must be activated in the <a href="wpmu-themes.php">Themes Admin</a> page before they appear here.'); ?></p></div><?php 72 } 73 ?> 74 75 <?php if ( ! validate_current_theme() ) : ?> 76 <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 77 <?php elseif ( isset($_GET['activated']) ) : 78 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) ) { ?> 79 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings page</a> to configure them.'), admin_url('widgets.php') ); ?></p></div><?php 80 } else { ?> 81 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">Visit site</a>'), get_bloginfo('url') . '/'); ?></p></div><?php 82 } 83 elseif ( isset($_GET['deleted']) ) : ?> 84 <div id="message3" class="updated fade"><p><?php _e('Theme deleted.') ?></p></div> 85 <?php endif; ?> 86 87 <?php 88 if( false == is_multisite() ) 89 $themes = get_themes(); 90 $ct = current_theme_info(); 91 unset($themes[$ct->name]); 92 93 uksort( $themes, "strnatcasecmp" ); 94 $theme_total = count( $themes ); 95 $per_page = 15; 96 97 if ( isset( $_GET['pagenum'] ) ) 98 $page = absint( $_GET['pagenum'] ); 99 100 if ( empty($page) ) 101 $page = 1; 102 103 $start = $offset = ( $page - 1 ) * $per_page; 104 105 $page_links = paginate_links( array( 106 'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav', 107 'format' => '', 108 'prev_text' => __('«'), 109 'next_text' => __('»'), 110 'total' => ceil($theme_total / $per_page), 111 'current' => $page 112 )); 113 114 $themes = array_slice( $themes, $start, $per_page ); 115 116 /** 117 * Check if there is an update for a theme available. 118 * 119 * Will display link, if there is an update available. 120 * 121 * @since 2.7.0 122 * 123 * @param object $theme Theme data object. 124 * @return bool False if no valid info was passed. 125 */ 126 function theme_update_available( $theme ) { 127 static $themes_update; 128 129 if( is_multisite() && false == is_site_admin() ) 130 return; 131 132 if ( !isset($themes_update) ) 133 $themes_update = get_transient('update_themes'); 134 135 if ( is_object($theme) && isset($theme->stylesheet) ) 136 $stylesheet = $theme->stylesheet; 137 elseif ( is_array($theme) && isset($theme['Stylesheet']) ) 138 $stylesheet = $theme['Stylesheet']; 139 else 140 return false; //No valid info passed. 141 142 if ( isset($themes_update->response[ $stylesheet ]) ) { 143 $update = $themes_update->response[ $stylesheet ]; 144 $theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : ''); 145 $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list. 146 $update_url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet); 147 $update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Upgrading this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to upgrade.") ) . '\') ) {return true;}return false;"'; 148 149 if ( ! current_user_can('update_themes') ) 150 printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']); 151 else if ( empty($update->package) ) 152 printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']); 153 else 154 printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s" %5$s >upgrade automatically</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick ); 155 } 156 } 157 158 ?> 159 160 <div class="wrap"> 161 <?php screen_icon(); ?> 162 <h2><?php echo esc_html( $title ); if ( is_multisite() && is_site_admin() || is_multisite() == false ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a> <?php } ?></h2> 163 164 <h3><?php _e('Current Theme'); ?></h3> 165 <div id="current-theme"> 166 <?php if ( $ct->screenshot ) : ?> 167 <img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" /> 168 <?php endif; ?> 169 <h4><?php 170 /* translators: 1: theme title, 2: theme version, 3: theme author */ 171 printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4> 172 <p class="theme-description"><?php echo $ct->description; ?></p> 173 <?php if( is_multisite() && is_site_admin() || is_multisite() == false ) if ($ct->parent_theme) { ?> 174 <p><?php printf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $ct->title, str_replace( WP_CONTENT_DIR, '', $ct->template_dir ), str_replace( WP_CONTENT_DIR, '', $ct->stylesheet_dir ), $ct->title, $ct->parent_theme); ?></p> 175 <?php } else { ?> 176 <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $ct->title, str_replace( WP_CONTENT_DIR, '', $ct->template_dir ), str_replace( WP_CONTENT_DIR, '', $ct->stylesheet_dir ) ); ?></p> 177 <?php } ?> 178 <?php if ( $ct->tags ) : ?> 179 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p> 180 <?php endif; ?> 181 <?php theme_update_available($ct); ?> 182 183 </div> 184 185 <div class="clear"></div> 186 <h3><?php _e('Available Themes'); ?></h3> 187 <div class="clear"></div> 188 189 <?php if ( $theme_total ) { ?> 190 191 <?php if ( $page_links ) : ?> 192 <div class="tablenav"> 193 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 194 number_format_i18n( $start + 1 ), 195 number_format_i18n( min( $page * $per_page, $theme_total ) ), 196 number_format_i18n( $theme_total ), 197 $page_links 198 ); echo $page_links_text; ?></div> 199 </div> 200 <?php endif; ?> 201 202 <table id="availablethemes" cellspacing="0" cellpadding="0"> 203 <?php 204 $style = ''; 205 206 $theme_names = array_keys($themes); 207 natcasesort($theme_names); 208 209 $table = array(); 210 $rows = ceil(count($theme_names) / 3); 211 for ( $row = 1; $row <= $rows; $row++ ) 212 for ( $col = 1; $col <= 3; $col++ ) 213 $table[$row][$col] = array_shift($theme_names); 214 215 foreach ( $table as $row => $cols ) { 216 ?> 217 <tr> 218 <?php 219 foreach ( $cols as $col => $theme_name ) { 220 $class = array('available-theme'); 221 if ( $row == 1 ) $class[] = 'top'; 222 if ( $col == 1 ) $class[] = 'left'; 223 if ( $row == $rows ) $class[] = 'bottom'; 224 if ( $col == 3 ) $class[] = 'right'; 225 ?> 226 <td class="<?php echo join(' ', $class); ?>"> 227 <?php if ( !empty($theme_name) ) : 228 $template = $themes[$theme_name]['Template']; 229 $stylesheet = $themes[$theme_name]['Stylesheet']; 230 $title = $themes[$theme_name]['Title']; 231 $version = $themes[$theme_name]['Version']; 232 $description = $themes[$theme_name]['Description']; 233 $author = $themes[$theme_name]['Author']; 234 $screenshot = $themes[$theme_name]['Screenshot']; 235 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; 236 $template_dir = $themes[$theme_name]['Template Dir']; 237 $parent_theme = $themes[$theme_name]['Parent Theme']; 238 $theme_root = $themes[$theme_name]['Theme Root']; 239 $theme_root_uri = $themes[$theme_name]['Theme Root URI']; 240 $preview_link = esc_url(get_option('home') . '/'); 241 if ( is_ssl() ) 242 $preview_link = str_replace( 'http://', 'https://', $preview_link ); 243 $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), $preview_link ) ); 244 $preview_text = esc_attr( sprintf( __('Preview of “%s”'), $title ) ); 245 $tags = $themes[$theme_name]['Tags']; 246 $thickbox_class = 'thickbox thickbox-preview'; 247 $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template); 248 $activate_text = esc_attr( sprintf( __('Activate “%s”'), $title ) ); 249 $actions = array(); 250 $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' . $activate_text . '">' . __('Activate') . '</a>'; 251 $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $theme_name)) . '">' . __('Preview') . '</a>'; 252 if ( is_multisite() && is_site_admin() || is_multisite() == false && current_user_can('update_themes') ) 253 $actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url("themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet) . '" onclick="' . "if ( confirm('" . esc_js(sprintf( __("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $theme_name )) . "') ) {return true;}return false;" . '">' . __('Delete') . '</a>'; 254 $actions = apply_filters('theme_action_links', $actions, $themes[$theme_name]); 255 256 $actions = implode ( ' | ', $actions ); 257 ?> 258 <a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot"> 259 <?php if ( $screenshot ) : ?> 260 <img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" /> 261 <?php endif; ?> 262 </a> 263 <h3><?php 264 /* translators: 1: theme title, 2: theme version, 3: theme author */ 265 printf(__('%1$s %2$s by %3$s'), $title, $version, $author) ; ?></h3> 266 <p class="description"><?php echo $description; ?></p> 267 <span class='action-links'><?php echo $actions ?></span> 268 <?php if ( is_multisite() && is_site_admin() || is_multisite() == false ) if ($parent_theme) { 269 /* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?> 270 <p><?php printf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme); ?></p> 271 <?php } else { ?> 272 <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?></p> 273 <?php } ?> 274 <?php if ( $tags ) : ?> 275 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p> 276 <?php endif; ?> 277 <?php theme_update_available( $themes[$theme_name] ); ?> 278 <?php endif; // end if not empty theme_name ?> 279 </td> 280 <?php } // end foreach $cols ?> 281 </tr> 282 <?php } // end foreach $table ?> 283 </table> 284 <?php } else { ?> 285 <p><?php _e('You only have one theme installed at the moment so there is nothing to show you here. Maybe you should download some more to try out.'); ?></p> 286 <?php } // end if $theme_total?> 287 <br class="clear" /> 288 289 <?php if ( $page_links ) : ?> 290 <div class="tablenav"> 291 <?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?> 292 <br class="clear" /> 293 </div> 294 <?php endif; ?> 295 296 <br class="clear" /> 297 298 <?php 299 // List broken themes, if any. 300 $broken_themes = get_broken_themes(); 301 if ( is_multisite() && is_site_admin() || is_multisite() == false ) if ( count($broken_themes) ) { 302 ?> 303 304 <h2><?php _e('Broken Themes'); ?> <?php if ( is_multisite() ) _e( '(Site admin only)' ); ?></h2> 305 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> 306 307 <table id="broken-themes"> 308 <tr> 309 <th><?php _e('Name'); ?></th> 310 <th><?php _e('Description'); ?></th> 311 </tr> 312 <?php 313 $theme = ''; 314 315 $theme_names = array_keys($broken_themes); 316 natcasesort($theme_names); 317 318 foreach ($theme_names as $theme_name) { 319 $title = $broken_themes[$theme_name]['Title']; 320 $description = $broken_themes[$theme_name]['Description']; 321 322 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"'; 323 echo " 324 <tr $theme> 325 <td>$title</td> 326 <td>$description</td> 327 </tr>"; 328 } 329 ?> 330 </table> 331 <?php 332 } 333 ?> 334 </div> 335 336 <?php require ('admin-footer.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon May 3 12:25:32 2010 | Cross-referenced by PHPXref 0.7 |