[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_adminpage_
   3  {
   4      const screen         = MailPress_page_themes;
   5      const capability     = 'MailPress_switch_themes';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/';
   7      const file            = __FILE__;
   8  
   9  ////  Redirect  ////
  10  
  11  	public static function redirect() 
  12      {
  13          $th = new MP_Themes();
  14  
  15          if ( isset($_GET['action']) ) 
  16          {
  17              check_admin_referer('switch-theme_' . $_GET['stylesheet']);
  18              if ('activate' == $_GET['action']) 
  19              {
  20                  $th->switch_theme($_GET['template'], $_GET['stylesheet']);
  21                  self::mp_redirect(MailPress_themes . '&activated=true');
  22              }
  23          }
  24      }
  25  
  26  ////  Styles  ////
  27  
  28  	public static function print_styles($styles = array()) 
  29      {
  30          $styles[] = 'thickbox';
  31          parent::print_styles($styles);
  32      }
  33  
  34  ////  Scripts  ////
  35  
  36  	public static function print_scripts($scripts = array()) 
  37      {
  38          wp_register_script( self::screen,     '/' . MP_PATH . 'mp-admin/js/themes.js', array( 'thickbox', 'jquery' ), false, 1);
  39  
  40          $scripts[] = self::screen;
  41          parent::print_scripts($scripts);
  42      }
  43  
  44  //// List ////
  45  
  46  	public static function get_list($args) 
  47      {
  48          extract($args);
  49  
  50          $th = new MP_Themes();
  51  
  52          $themes = $th->themes;
  53  
  54          foreach($themes as $key => $theme)
  55          {
  56              if ( 'plaintext' == $theme['Stylesheet']) unset($themes[$key]);
  57              if ( '_' == $theme['Stylesheet'][0] )     unset($themes[$key]);
  58          }
  59  
  60          ksort( $themes );
  61  
  62          return array(array_slice( $themes, $start, $_per_page ), count( $themes ), $th);
  63      }
  64  
  65  ////  Row  ////
  66  
  67  	public static function get_row($theme, $row, $col, $rows)
  68      {
  69          $class = array('available-theme');
  70          if ( $row == 1 ) $class[] = 'top';
  71          if ( $col == 1 ) $class[] = 'left';
  72          if ( $row == $rows ) $class[] = 'bottom';
  73          if ( $col == 3 ) $class[] = 'right';
  74  
  75  // url's
  76          $args = array();
  77          $args['action']         = 'activate';
  78          $args['template']     = $theme['Template'];
  79          $args['stylesheet']     = $theme['Stylesheet'];
  80          $activate_url = esc_url(self::url( MailPress_themes, $args, 'switch-theme_' . $theme['Stylesheet'] ));
  81  
  82          $args['action']         = 'theme-preview';
  83          $args['preview_iframe']    = 1;
  84          $args['TB_iframe']     = 'true';
  85          $preview_url =  esc_url(self::url( MP_Action_url, $args));
  86  
  87  // titles's
  88          $activate_title    = esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $theme['Title'] ) );
  89          $preview_title    = esc_attr( sprintf( __('Preview of &#8220;%s&#8221;'), $theme['Title'] ) );
  90  // actions
  91          $actions = array();
  92  
  93          $preview['link1']    = "<a class='thickbox thickbox-preview screenshot' href='$preview_url'>";
  94          if ( $theme['Screenshot'] ) $preview['link1'] .= "<img src='" . $theme['Theme Root URI'] . '/' . $theme['Stylesheet'] . '/' . $theme['Screenshot'] . "' alt='" . esc_attr($theme['Title']) . "' />";
  95          $preview['link1']     .= '</a>';
  96  
  97          $activate['link2']    = "<a class='activatelink' href='$activate_url' title='$activate_title'>" . __('Activate') . '</a>';
  98          $preview['link2']        = "<a class='thickbox thickbox-preview'  href='$preview_url' title='$preview_title'>"  . __('Preview')  . '</a>';
  99  ?>
 100              <td class="<?php echo join(' ', $class); ?>">
 101                  <?php echo $preview['link1']; ?>
 102                  <h3><?php echo esc_attr($theme['Title']); ?></h3>
 103  <?php if ( $theme['Description'] ) : ?>
 104                  <p class='description'><?php echo $theme['Description']; ?></p>
 105  <?php endif; ?>
 106                  <span class='action-links'>
 107                      <?php echo $activate['link2']; ?> | 
 108                      <?php echo $preview['link2']; ?>
 109                  </span>
 110  <?php if ( $theme['Tags'] ) : ?>
 111                  <p><?php _e('Tags:'); ?> <?php echo join(', ', $theme['Tags']); ?></p>
 112  <?php endif; ?>
 113              </td>
 114  <?php
 115      }
 116  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1