| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
require_once('admin.php'); |
|---|
| 6 |
|
|---|
| 7 |
$themes = get_themes(); |
|---|
| 8 |
$ct = current_theme_info(); |
|---|
| 9 |
$allowed_themes = get_site_allowed_themes(); |
|---|
| 10 |
if( $allowed_themes == false ) |
|---|
| 11 |
$allowed_themes = array(); |
|---|
| 12 |
|
|---|
| 13 |
$blog_allowed_themes = wpmu_get_blog_allowedthemes(); |
|---|
| 14 |
if( is_array( $blog_allowed_themes ) ) |
|---|
| 15 |
$allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes ); |
|---|
| 16 |
if( $blog_id != 1 ) |
|---|
| 17 |
unset( $allowed_themes[ "h3" ] ); |
|---|
| 18 |
|
|---|
| 19 |
if( isset( $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] ) == false ) |
|---|
| 20 |
$allowed_themes[ wp_specialchars( $ct->stylesheet ) ] = true; |
|---|
| 21 |
|
|---|
| 22 |
reset( $themes ); |
|---|
| 23 |
foreach( $themes as $key => $theme ) { |
|---|
| 24 |
if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) { |
|---|
| 25 |
unset( $themes[ $key ] ); |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|
| 28 |
reset( $themes ); |
|---|
| 29 |
|
|---|
| 30 |
if ( isset($_GET['action']) ) { |
|---|
| 31 |
check_admin_referer('switch-theme_' . $_GET['template']); |
|---|
| 32 |
|
|---|
| 33 |
if ('activate' == $_GET['action']) { |
|---|
| 34 |
$found = false; |
|---|
| 35 |
while( list( $key, $details ) = each( $themes ) ) { |
|---|
| 36 |
if( $details[ 'Template' ] == $_GET['template'] && $details[ 'Stylesheet' ] == $_GET['stylesheet'] ) { |
|---|
| 37 |
$found = true; |
|---|
| 38 |
break; |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
if( $found == true ) { |
|---|
| 42 |
if ( isset($_GET['template']) ) |
|---|
| 43 |
update_option('template', $_GET['template']); |
|---|
| 44 |
|
|---|
| 45 |
if ( isset($_GET['stylesheet']) ) |
|---|
| 46 |
update_option('stylesheet', $_GET['stylesheet']); |
|---|
| 47 |
|
|---|
| 48 |
do_action('switch_theme', get_current_theme()); |
|---|
| 49 |
|
|---|
| 50 |
wp_redirect('themes.php?activated=true'); |
|---|
| 51 |
} else { |
|---|
| 52 |
wp_redirect('themes.php'); |
|---|
| 53 |
} |
|---|
| 54 |
exit; |
|---|
| 55 |
} |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
$title = __('Manage Themes'); |
|---|
| 59 |
$parent_file = 'themes.php'; |
|---|
| 60 |
require_once('admin-header.php'); |
|---|
| 61 |
if( is_site_admin() ) { |
|---|
| 62 |
?><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 |
|---|
| 63 |
} |
|---|
| 64 |
?> |
|---|
| 65 |
|
|---|
| 66 |
<?php if ( ! validate_current_theme() ) : ?> |
|---|
| 67 |
<div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> |
|---|
| 68 |
|
|---|
| 69 |
<?php elseif ( isset($_GET['activated']) ) : ?> |
|---|
| 70 |
<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo('url') . '/'); ?></p></div> |
|---|
| 71 |
<?php endif; ?> |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
<div class="wrap"> |
|---|
| 75 |
<h2><?php _e('Current Theme'); ?></h2> |
|---|
| 76 |
<div id="currenttheme"> |
|---|
| 77 |
<?php if ( $ct->screenshot ) : ?> |
|---|
| 78 |
<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" /> |
|---|
| 79 |
|
|---|
| 80 |
<?php endif; ?> |
|---|
| 81 |
<h3><?php printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h3> |
|---|
| 82 |
<p><?php echo $ct->description; ?></p> |
|---|
| 83 |
</div> |
|---|
| 84 |
|
|---|
| 85 |
<br style="clear: both" /> |
|---|
| 86 |
<h2><?php _e('Available Themes'); ?></h2> |
|---|
| 87 |
<?php |
|---|
| 88 |
|
|---|
| 89 |
$totalthemes = count($themes); |
|---|
| 90 |
if ( 1 < $totalthemes ) { |
|---|
| 91 |
|
|---|
| 92 |
?> |
|---|
| 93 |
|
|---|
| 94 |
<?php |
|---|
| 95 |
$style = ''; |
|---|
| 96 |
|
|---|
| 97 |
$theme_names = array_keys($themes); |
|---|
| 98 |
natcasesort($theme_names); |
|---|
| 99 |
|
|---|
| 100 |
$theme_names = array_keys($themes); |
|---|
| 101 |
natcasesort($theme_names); |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
if($_GET['fromtheme']){ |
|---|
| 105 |
$startshowing=$_GET['fromtheme']; |
|---|
| 106 |
$stopshowing=$startshowing+16; |
|---|
| 107 |
}else{ |
|---|
| 108 |
$startshowing=0; $stopshowing=16; |
|---|
| 109 |
} |
|---|
| 110 |
$i=0; |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
foreach ($theme_names as $theme_name) { |
|---|
| 114 |
if ( $theme_name == $ct->name ) |
|---|
| 115 |
continue; |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
$i++; |
|---|
| 119 |
if ( $i < $stopshowing && $i > $startshowing ) { |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
$template = $themes[$theme_name]['Template']; |
|---|
| 123 |
$stylesheet = $themes[$theme_name]['Stylesheet']; |
|---|
| 124 |
$title = $themes[$theme_name]['Title']; |
|---|
| 125 |
$version = $themes[$theme_name]['Version']; |
|---|
| 126 |
$description = $themes[$theme_name]['Description']; |
|---|
| 127 |
$author = $themes[$theme_name]['Author']; |
|---|
| 128 |
$screenshot = $themes[$theme_name]['Screenshot']; |
|---|
| 129 |
$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; |
|---|
| 130 |
$activate_link = wp_nonce_url("themes.php?action=activate&template=$template&stylesheet=$stylesheet", 'switch-theme_' . $template); |
|---|
| 131 |
?> |
|---|
| 132 |
|
|---|
| 133 |
<div class="available-theme"> |
|---|
| 134 |
<h3><a href="<?php echo $activate_link; ?>"><?php echo "$title"; ?></a></h3> |
|---|
| 135 |
|
|---|
| 136 |
<a href="<?php echo $activate_link; ?>" class="screenshot"> |
|---|
| 137 |
<?php if ( $screenshot ) : ?> |
|---|
| 138 |
<img src="<?php echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" /> |
|---|
| 139 |
<?php endif; ?> |
|---|
| 140 |
</a> |
|---|
| 141 |
|
|---|
| 142 |
<p><?php echo $description; ?></p> |
|---|
| 143 |
|
|---|
| 144 |
</div> |
|---|
| 145 |
<?php |
|---|
| 146 |
|
|---|
| 147 |
$thispageend=$i; } |
|---|
| 148 |
// end xiando(tm) theme modification |
|---|
| 149 |
?> |
|---|
| 150 |
<?php } ?> |
|---|
| 151 |
|
|---|
| 152 |
<?php |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
$pages=round($totalthemes/15); |
|---|
| 156 |
$viewedpage = round(($thispageend+1)/15); |
|---|
| 157 |
|
|---|
| 158 |
$wTmp = '<br style="clear:both;" /><p style="text-align:center;font-size:20px;">'; |
|---|
| 159 |
$wTmp .= 'Page ' . $viewedpage . ' of ' . $pages . '<br />'; |
|---|
| 160 |
if ( $thispageend-16 > 0 ) { |
|---|
| 161 |
$wTmp .= '<a href="themes.php?fromtheme=' . ($thispageend-30) . '"><<< Previous Page</a> '; |
|---|
| 162 |
} |
|---|
| 163 |
if ( $thispageend+1 < ($totalthemes) ){ |
|---|
| 164 |
$wTmp .= '<a href="themes.php?fromtheme=' . ($thispageend) . '">Next Page >>></a>'; |
|---|
| 165 |
} |
|---|
| 166 |
$wTmp .= '<br />'; |
|---|
| 167 |
$i=0; while (( $i < $pages )) { |
|---|
| 168 |
$wTmp .= '<a href="themes.php?fromtheme=' . ($i*15) . '"> '. ($i+1) . ' </a> '; |
|---|
| 169 |
$i++; |
|---|
| 170 |
} |
|---|
| 171 |
$wTmp .= '</p>'; |
|---|
| 172 |
echo $wTmp; |
|---|
| 173 |
|
|---|
| 174 |
?> |
|---|
| 175 |
|
|---|
| 176 |
<?php } ?> |
|---|
| 177 |
|
|---|
| 178 |
<?php |
|---|
| 179 |
|
|---|
| 180 |
$broken_themes = get_broken_themes(); |
|---|
| 181 |
if ( is_site_admin() && count($broken_themes) ) { |
|---|
| 182 |
?> |
|---|
| 183 |
|
|---|
| 184 |
<h2><?php _e('Broken Themes'); ?> (Site admin only)</h2> |
|---|
| 185 |
<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> |
|---|
| 186 |
|
|---|
| 187 |
<table width="100%" cellpadding="3" cellspacing="3"> |
|---|
| 188 |
<tr> |
|---|
| 189 |
<th><?php _e('Name'); ?></th> |
|---|
| 190 |
<th><?php _e('Description'); ?></th> |
|---|
| 191 |
</tr> |
|---|
| 192 |
|
|---|
| 193 |
<?php |
|---|
| 194 |
$theme = ''; |
|---|
| 195 |
|
|---|
| 196 |
$theme_names = array_keys($broken_themes); |
|---|
| 197 |
natcasesort($theme_names); |
|---|
| 198 |
|
|---|
| 199 |
foreach ($theme_names as $theme_name) { |
|---|
| 200 |
$title = $broken_themes[$theme_name]['Title']; |
|---|
| 201 |
$description = $broken_themes[$theme_name]['Description']; |
|---|
| 202 |
|
|---|
| 203 |
$theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"'; |
|---|
| 204 |
echo " |
|---|
| 205 |
<tr $theme> |
|---|
| 206 |
<td>$title</td> |
|---|
| 207 |
<td>$description</td> |
|---|
| 208 |
</tr>"; |
|---|
| 209 |
} |
|---|
| 210 |
?> |
|---|
| 211 |
</table> |
|---|
| 212 |
<?php |
|---|
| 213 |
} |
|---|
| 214 |
?> |
|---|
| 215 |
<br clear="all" /> |
|---|
| 216 |
</div> |
|---|
| 217 |
|
|---|
| 218 |
<?php require('admin-footer.php'); ?> |
|---|