[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/bb-admin/ -> themes.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  $themes = bb_get_themes();
   5  
   6  $activetheme = bb_get_option('bb_active_theme');
   7  if (!$activetheme) {
   8      $activetheme = BB_DEFAULT_THEME;
   9  }
  10  
  11  if ( isset($_GET['theme']) ) {
  12      if ( !bb_current_user_can( 'manage_themes' ) ) {
  13          wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
  14          exit;
  15      }
  16      
  17      bb_check_admin_referer( 'switch-theme' );
  18      do_action( 'bb_deactivate_theme_' . $activetheme );
  19      
  20      $theme = stripslashes($_GET['theme']);
  21      $theme_data = bb_get_theme_data( $theme );
  22      if ($theme_data['Name']) {
  23          $name = $theme_data['Name'];
  24      } else {
  25          $name = preg_replace( '/^([a-z0-9_-]+#)/i', '', $theme);
  26      }
  27      if ($theme == BB_DEFAULT_THEME) {
  28          bb_delete_option( 'bb_active_theme' );
  29      } else {
  30          bb_update_option( 'bb_active_theme', $theme );
  31      }
  32      do_action( 'bb_activate_theme_' . $theme );
  33      wp_redirect( bb_get_uri('bb-admin/themes.php', array('activated' => 1, 'name' => urlencode( $name ) ), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN ) );
  34      exit;
  35  }
  36  
  37  if ( isset($_GET['activated']) )
  38      $theme_notice = bb_admin_notice( sprintf( __( '<strong>Theme "%s" activated</strong>' ), esc_attr($_GET['name'])) );
  39  
  40  if ( !in_array($activetheme, $themes) ) {
  41      if ($activetheme == BB_DEFAULT_THEME) {
  42          remove_action( 'bb_admin_notices', $theme_notice );
  43          bb_admin_notice( __( '<strong>Default theme is missing.</strong>' ), 'error' );
  44      } else {
  45          bb_delete_option( 'bb_active_theme' );
  46          remove_action( 'bb_admin_notices', $theme_notice );
  47          bb_admin_notice( __( '<strong>Theme not found.  Default theme applied.</strong>' ), 'error' );
  48      }
  49  }
  50  
  51  function bb_admin_theme_row( $theme, $position ) {
  52      $theme_directory = bb_get_theme_directory( $theme );
  53      $theme_data = file_exists( $theme_directory . 'style.css' ) ? bb_get_theme_data( $theme ) : false;
  54      $screen_shot = file_exists( $theme_directory . 'screenshot.png' ) ? esc_url( bb_get_theme_uri( $theme ) . 'screenshot.png' ) : false;
  55      $activation_url = bb_get_uri('bb-admin/themes.php', array('theme' => urlencode($theme)), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
  56      $activation_url = esc_url( bb_nonce_url( $activation_url, 'switch-theme' ) );
  57  
  58      if ( 1 === $position || 0 === $position ) {
  59          echo '<tr>';
  60      }
  61  ?>
  62      <td class="position-<?php echo( (int) $position ); ?>">
  63          <div class="screen-shot"><?php if ( $screen_shot ) : ?><a href="<?php echo $activation_url; ?>" title="<?php echo esc_attr( sprintf( __( 'Activate "%s"' ), $theme_data['Title'] ) ); ?>"><img alt="<?php echo esc_attr( $theme_data['Title'] ); ?>" src="<?php echo $screen_shot; ?>" /></a><?php endif; ?></div>
  64          <div class="description">
  65              <h3 class="themes">
  66  <?php
  67      printf(
  68          __( '%1$s %2$s by <cite>%3$s</cite>' ),
  69          $theme_data['Title'],
  70          $theme_data['Version'],
  71          $theme_data['Author']
  72      );
  73  ?>
  74              </h3>
  75              
  76  <?php
  77      if ( $theme_data['Porter'] ) {
  78  ?>
  79              <p>
  80  <?php
  81      printf(
  82          __( 'Ported by <cite>%s</cite>' ),
  83          $theme_data['Porter']
  84      );
  85  ?>
  86              </p>
  87  <?php
  88      }
  89  ?>
  90              
  91              <?php echo $theme_data['Description']; // Description is autop'ed ?>
  92  <?php
  93      if ( 0 !== $position ) {
  94  ?>
  95              <div class="actions">
  96                  <a href="<?php echo $activation_url; ?>" title="<?php echo esc_attr( sprintf( __( 'Activate "%s"' ), $theme_data['Title'] ) ); ?>"><?php _e( 'Activate' ); ?></a>
  97              </div>
  98  <?php
  99      }
 100  ?>
 101              <p class="location"><?php printf(__('All of this theme\'s files are located in the "%s" themes directory.'), $theme_data['Location']); ?></p>
 102          </div>
 103      </td>
 104  <?php
 105  
 106      if ( 3 === $position || 0 === $position ) {
 107          echo '</tr>';
 108      }
 109  }
 110  
 111  if ( isset( $bb->safemode ) && $bb->safemode === true ) {
 112      bb_admin_notice( __( '<strong>"Safe mode" is on, the default theme will be used instead of the active theme indicated below.</strong>' ), 'error' );
 113  }
 114  
 115  $bb_admin_body_class = ' bb-admin-appearance';
 116  
 117  bb_get_admin_header();
 118  ?>
 119  
 120  <h2><?php _e('Manage Themes'); ?></h2>
 121  <?php do_action( 'bb_admin_notices' ); ?>
 122  
 123  <h3 class="themes"><?php _e('Current Theme'); ?></h3>
 124  <div>
 125  <table class="theme-list-active">
 126  <?php bb_admin_theme_row( $themes[$activetheme], 0 ); unset($themes[$activetheme] ); ?>
 127  </table>
 128  </div>
 129  
 130  <?php if ( !empty($themes) ) : ?>
 131  
 132  <h3 class="themes"><?php _e('Available Themes'); ?></h3>
 133  <div>
 134  <table class="theme-list">
 135  <?php
 136  $i = 0;
 137  foreach ( $themes as $theme ) {
 138      $position = 1 + ( $i % 3 );
 139  
 140      bb_admin_theme_row( $theme, $position );
 141  
 142      $i++;
 143  }
 144  
 145  switch ( $position ) {
 146      case 1:
 147          echo '<td class="position-2"></td><td class="position-3"></td></tr>';
 148          break;
 149      case 2:
 150          echo '<td class="position-3"></td></tr>';
 151          break;
 152      case 3:
 153          break;
 154  }
 155  ?>
 156  </table>
 157  </div>
 158  
 159  <?php endif; bb_get_admin_footer(); ?>


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1