[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_WP_Admin_page_
   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( self::$get_['action'] ) ) 
  16          {
  17              check_admin_referer( 'switch-theme_' . self::$get_['stylesheet'] );
  18              if ( 'activate' == self::$get_['action'] ) 
  19              {
  20                  $th->switch_theme( self::$get_['template'], self::$get_['stylesheet'] );
  21                  self::mp_redirect( MailPress_themes . '&activated=true' );
  22              }
  23          }
  24      }
  25  
  26  //// Help ////
  27  
  28  	public static function add_help_tab() 
  29      {
  30          global $current_screen;
  31  
  32          $content = '';
  33          $content .= '<p><strong>' . __( 'Themes :', 'MailPress' ) . '</strong></p>';
  34          $content .= '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your MailPress installation.', 'MailPress' ) . '</p>';
  35          $content .= '<p>' . __( 'From this screen you can:', 'MailPress' ) . '</p>';
  36          $content .= '<ul>';
  37          $content .= '<li>' . __( 'Hover or tap to see Activate and Live Preview buttons', 'MailPress' ) . '</li>';
  38          $content .= '<li>' . __( 'Click Live Preview for any theme to see a live preview', 'MailPress' ) . '</li>';
  39          $content .= '</ul>';
  40          $content .= '<p>' . __( 'The current theme is displayed highlighted as the first theme.', 'MailPress' ) . '</p>';
  41  
  42          $current_screen->add_help_tab( array(     'id'        => 'overview',
  43                                          'title'    => __( 'Overview' ),
  44                                          'content'    => $content )
  45          );
  46  
  47          $content = '';
  48          $content .= '<p>' . sprintf( __( 'All MailPress themes are currently stored in %s.', 'MailPress' ), '<code>' . MP_FOLDER . '/' . MP_CONTENT_FOLDER . '/themes</code>') . '</p>';
  49          $content .= '<p><i>' . __( 'For Developers : ', 'MailPress') . '</i>';
  50          $content .= __( ' MailPress theme have some similarities with WordPress theme.', 'MailPress' );
  51          $content .= '<br />' . __( 'If you develop your own mp theme, make sure to have a back up of your files. WordPress automatic plugin upgrade will erase it when upgrading MailPress.', 'MailPress' );
  52          $content .= '</p>';
  53  
  54          $current_screen->add_help_tab( array(     'id'        => 'adding-themes',
  55                                          'title'    => __( 'Adding Themes', 'MailPress' ),
  56                                          'content'    => $content )
  57          );
  58      }
  59  
  60  ////  Styles  ////
  61  
  62  	public static function print_styles( $s ) 
  63      {
  64          $styles = ( is_array( $s ) ) ? $s : array();
  65  
  66          $styles[] = 'thickbox';
  67          parent::print_styles( $styles );
  68      }
  69  
  70  ////  Scripts  ////
  71  
  72  	public static function print_scripts( $scripts = array() ) 
  73      {
  74          wp_register_script( self::screen,     '/' . MP_PATH . 'mp-admin/js/themes.js', array( 'thickbox', 'jquery' ), false, 1 );
  75  
  76          $scripts[] = self::screen;
  77          parent::print_scripts( $scripts );
  78      }
  79  
  80  //// List ////
  81  
  82  	public static function get_list( $args ) 
  83      {
  84          extract( $args );
  85  
  86          $th = new MP_Themes();
  87  
  88          foreach( $th->themes as $key => $theme )
  89          {
  90              if ( 'plaintext' == $theme['Stylesheet'] )
  91              {
  92                  unset( $th->themes[$key] );
  93              }
  94              if ( '_' == $theme['Stylesheet'][0] )
  95              {
  96                  unset( $th->themes[$key] );
  97              }
  98          }
  99  
 100          $active = $th->themes[$th->current_theme];
 101          unset( $th->themes[$th->current_theme] );
 102          ksort( $th->themes );
 103          $th->themes = array_merge( array( $th->current_theme => $active ), $th->themes );
 104  
 105          return $th;
 106      }
 107  
 108  ////  Row  ////
 109  
 110  	public static function get_row( $theme, $active )
 111      {
 112          $class = array( 'available-theme' );
 113  
 114  // table row 
 115  //    class
 116          $row_class = ( $active ) ? 'theme active' : 'theme';
 117  
 118  // url's
 119          $args = array();
 120          $args['action']        = 'activate';
 121          $args['template']    = $theme['Template'];
 122          $args['stylesheet']    = $theme['Stylesheet'];
 123          $activate_url        = esc_url( self::url( MailPress_themes, $args, 'switch-theme_' . $theme['Stylesheet'] ) );
 124  
 125          $args['action']        = 'mp_ajax';
 126               $args['mp_action']    = 'theme_preview';
 127  
 128          $args['TB_iframe']    = 'true';
 129          $preview_url        =  esc_url( self::url( admin_url( 'admin-ajax.php' ), $args ) );
 130  
 131  // titles's
 132          $title        = ($active) ? sprintf( __( '<span>Active : </span>%s', 'MailPress'), $theme['Title'] ) : $theme['Title'];
 133          $activate_title    = sprintf( __( 'Activate &#8220;%s&#8221;' ), $theme['Title'] );
 134          $preview_title    = sprintf( __( 'Preview of &#8220;%s&#8221;' ), $theme['Title'] );
 135  // actions
 136          $actions = array();
 137  
 138          $preview['link1']    = '<a class="thickbox thickbox-preview screenshot" href="' . $preview_url . '">';
 139          if ( $theme['Screenshot'] )
 140          {
 141              $preview['link1'] .= '<img src="' . $theme['Theme Root URI'] . '/' . $theme['Stylesheet'] . '/' . $theme['Screenshot'] . '" alt="" />';
 142          }
 143          $preview['link1']    .= '</a>';
 144  
 145          $activate['link2']    = '<a class="button activate" href="' . $activate_url . '" title="' . esc_attr( $activate_title ) . '">' . __( 'Activate' ) . '</a>';
 146          $preview['link2']    = '<a class="button button-primary load-customize hide-if-no-customizethickbox thickbox-preview"  href="' . $preview_url . '" title="' . esc_attr( $preview_title ) . '">' . __( 'Preview' ) . '</a>';
 147          $links            = ($active) ? $preview['link2'] : $activate['link2'] . $preview['link2']; 
 148  
 149          $out = '';
 150          $out .= '<div class="' . $row_class . '" tabindex="0">';
 151  
 152          $out .= '<div class="theme-screenshot">';
 153          $out .= '<img src="' . $theme['Theme Root URI'] . '/' . $theme['Stylesheet'] . '/' . $theme['Screenshot'] . '" alt="" />';
 154          $out .= '</div>';
 155          $out .= '<div class="theme-author">' . sprintf( __('By %s', 'MailPress'), $theme['Author'] ) . '</div>';
 156          $out .= '<div class="theme-id-container">';
 157          $out .= '<h2 class="theme-name" id="' . $theme['Stylesheet'] . '-name">' . $title . '</h2>';
 158          $out .= '<div class="theme-actions">' . $links . '</div>';
 159          $out .= '</div>';
 160  
 161          $out .= '</div>';
 162  
 163          return $out;
 164      }
 165  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1