[ XREF Home ] [ Index ]

PHP Cross Reference of WordPress Trunk

Provided by Yoast

title

Body

[close]

/wp-admin/ -> themes.php (source)

   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 = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>';
  41  $help .= '<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  if ( current_user_can('install_themes') )
  43      $help .= '<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 licensed under the GNU General Public License, version 2, just like WordPress. Oh, and they&#8217;re free!'), 'http://wordpress.org/extend/themes/') . '</p>';
  44  
  45  $help .= '<p><strong>' . __('For more information:') . '</strong></p>';
  46  $help .= '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>';
  47  $help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
  48  add_contextual_help($current_screen, $help);
  49  
  50  add_thickbox();
  51  wp_enqueue_script( 'theme-preview' );
  52  wp_enqueue_script( 'theme' );
  53  wp_enqueue_style( 'theme-install' );
  54  
  55  endif;
  56  
  57  require_once ('./admin-header.php');
  58  ?>
  59  
  60  <?php if ( ! validate_current_theme() ) : ?>
  61  <div id="message1" class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
  62  <?php elseif ( isset($_GET['activated']) ) :
  63          if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?>
  64  <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
  65          } else { ?>
  66  <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php
  67          }
  68      elseif ( isset($_GET['deleted']) ) : ?>
  69  <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div>
  70  <?php endif; ?>
  71  
  72  <div class="wrap"><?php
  73  screen_icon();
  74  if ( !is_multisite() ) : ?>
  75  <h2 class="nav-tab-wrapper">
  76  <a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a>
  77      <?php if ( current_user_can('install_themes') ) : ?>
  78  <a href="<?php echo admin_url( 'theme-install.php'); ?>" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a>
  79      <?php endif;
  80  else : ?>
  81  <h2>
  82  <?php echo esc_html( $title ); ?>
  83  <?php endif; ?>
  84  </h2>
  85  
  86  <h3><?php _e('Current Theme'); ?></h3>
  87  <div id="current-theme">
  88  <?php if ( $ct->screenshot ) : ?>
  89  <img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
  90  <?php endif; ?>
  91  <h4><?php
  92      /* translators: 1: theme title, 2: theme version, 3: theme author */
  93      printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4>
  94  <p class="theme-description"><?php echo $ct->description; ?></p>
  95  <div class="theme-options">
  96      <span><?php _e( 'Options:' )?></span>
  97      <?php
  98      // Pretend you didn't see this.
  99      $options = array();
 100      if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
 101          foreach ( (array) $submenu['themes.php'] as $item) {
 102              $class = '';
 103              if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] )
 104                  continue;
 105              // 0 = name, 1 = capability, 2 = file
 106              if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) $class = ' class="current"';
 107  
 108              if ( !empty($submenu[$item[2]]) ) {
 109                  $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
 110                  $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
 111                  if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
 112                      $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
 113                  else
 114                      $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
 115              } else if ( current_user_can($item[1]) ) {
 116                  if ( file_exists(ABSPATH . 'wp-admin/' . $item[2]) ) {
 117                      $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
 118                  } else {
 119                      $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
 120                  }
 121              }
 122          }
 123      }
 124      echo implode ( ' | ', $options );
 125  
 126      if ( $ct->tags ) : ?>
 127      <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
 128      <?php endif; ?>
 129  </div>
 130  <?php theme_update_available($ct); ?>
 131  
 132  </div>
 133  
 134  <br class="clear" />
 135  <?php
 136  if ( ! current_user_can( 'switch_themes' ) ) {
 137      echo '</div>';
 138      require ( './admin-footer.php' );
 139      exit;
 140  }
 141  ?>
 142  
 143  <h3><?php _e('Available Themes'); ?></h3>
 144  
 145  <?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['filter'] ) || $wp_list_table->has_items() ) : ?>
 146  
 147  <form class="search-form filter-form" action="" method="get">
 148  
 149  <p class="search-box">
 150      <label class="screen-reader-text" for="theme-search-input"><?php _e('Search Installed Themes'); ?>:</label>
 151      <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
 152      <?php submit_button( __( 'Search Installed Themes' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
 153      <a id="filter-click" href="?filter=1"><?php _e( 'Feature Filter' ); ?></a>
 154  </p>
 155  
 156  <br class="clear"/>
 157  
 158  <div id="filter-box" style="<?php if ( empty($_REQUEST['filter']) ) echo 'display: none;'; ?>">
 159  <?php $feature_list = get_theme_feature_list(); ?>
 160      <div class="feature-filter">
 161          <p class="install-help"><?php _e('Theme filters') ?></p>
 162      <?php if ( !empty( $_REQUEST['filter'] ) ) : ?>
 163          <input type="hidden" name="filter" value="1" />
 164      <?php endif; ?>
 165      <?php foreach ( $feature_list as $feature_name => $features ) :
 166              $feature_name = esc_html( $feature_name ); ?>
 167  
 168          <div class="feature-container">
 169              <div class="feature-name"><?php echo $feature_name ?></div>
 170  
 171              <ol class="feature-group">
 172                  <?php foreach ( $features as $key => $feature ) :
 173                          $feature_name = $feature;
 174                          $feature_name = esc_html( $feature_name );
 175                          $feature = esc_attr( $feature );
 176                          ?>
 177                  <li>
 178                      <input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
 179                      <label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label>
 180                  </li>
 181                  <?php endforeach; ?>
 182              </ol>
 183          </div>
 184      <?php endforeach; ?>
 185  
 186      <div class="feature-container">
 187          <?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', false, false, array( 'style' => 'margin-left: 120px', 'id' => 'filter-submit' ) ); ?>
 188          &nbsp;
 189          <small><a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a></small>
 190      </div>
 191      <br/>
 192      </div>
 193      <br class="clear"/>
 194  </div>
 195  
 196  <br class="clear" />
 197  
 198  <?php endif; ?>
 199  
 200  <?php $wp_list_table->display(); ?>
 201  
 202  </form>
 203  <br class="clear" />
 204  
 205  <?php
 206  // List broken themes, if any.
 207  $broken_themes = get_broken_themes();
 208  if ( current_user_can('edit_themes') && count( $broken_themes ) ) {
 209  ?>
 210  
 211  <h3><?php _e('Broken Themes'); ?></h3>
 212  <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
 213  
 214  <table id="broken-themes">
 215      <tr>
 216          <th><?php _e('Name'); ?></th>
 217          <th><?php _e('Description'); ?></th>
 218      </tr>
 219  <?php
 220      $theme = '';
 221  
 222      $theme_names = array_keys($broken_themes);
 223      natcasesort($theme_names);
 224  
 225      foreach ($theme_names as $theme_name) {
 226          $title = $broken_themes[$theme_name]['Title'];
 227          $description = $broken_themes[$theme_name]['Description'];
 228  
 229          $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
 230          echo "
 231          <tr $theme>
 232               <td>$title</td>
 233               <td>$description</td>
 234          </tr>";
 235      }
 236  ?>
 237  </table>
 238  <?php
 239  }
 240  ?>
 241  </div>
 242  
 243  <?php require ('./admin-footer.php'); ?>


Generated: Wed Jun 1 08:30:02 2011 Cross-referenced by PHPXref 0.7
Provided by Yoast and awesome WordPress Hosting