[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_WP_Admin_page_
   3  {
   4      const screen        = MailPress_page_settings;
   5      const capability    = 'MailPress_manage_options';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/';
   7      const file            = __FILE__;
   8  
   9      public static $first = true;
  10  
  11      public static $err_mess = array();
  12  
  13  //// Help ////
  14  
  15  	public static function add_help_tab() 
  16      {
  17          global $current_screen;
  18  
  19          $_tabs = self::get_tabs();
  20  
  21          foreach( $_tabs as $_tab => $desc )
  22          {
  23              $content = '';
  24  
  25              $file = 'includes/settings/' . $_tab . '/help.php';
  26              include( $file );
  27  
  28              $current_screen->add_help_tab( array( 'id' => $_tab, 'title' => $desc, 'content' => $content ) );
  29          }
  30      }
  31  
  32  ////  Styles  ////
  33  
  34  	public static function print_styles( $s ) 
  35      {
  36          $styles = ( is_array( $s ) ) ? $s : array();
  37  
  38          wp_register_style( self::screen, '/' . MP_PATH . 'mp-admin/css/settings.css' );
  39          $styles[] = self::screen;
  40  
  41          parent::print_styles( $styles );
  42      }
  43  
  44  ////  Scripts  ////
  45  
  46  	public static function print_scripts( $scripts = array() ) 
  47      {
  48          wp_register_script( 'mp-smtp',    '/' . MP_PATH . 'mp-admin/js/settings_smtp.js', array(), false, 1 );
  49  
  50          wp_register_script( self::screen,     '/' . MP_PATH . 'mp-admin/js/settings.js', array( 'jquery-ui-tabs', 'mp-smtp' ), false, 1 );
  51          wp_localize_script( self::screen, 'MP_AdminPageL10n', array( 'requestFile' => admin_url( 'admin-ajax.php' ) ) );
  52          $scripts[] = self::screen;
  53  
  54          wp_register_style( 'mp_icons',         '/' . MP_PATH . 'mp-admin/css/_icons.css' );
  55          $styles[] = 'mp_icons';
  56  
  57          parent::print_scripts( $scripts );
  58      }
  59  
  60  	public static function print_styles_icons( $i = array( 'icon', ) ) 
  61      {
  62          return parent::print_styles_icons( $i );
  63      }
  64  
  65  ////  Misc  ////
  66  
  67  	public static function get_tabs()
  68      {
  69          global $mp_general;
  70  
  71          $_tabs['general'] = __( 'General', 'MailPress' );
  72  
  73          if ( $mp_general || isset( MP_AdminPage::$pst_['general'] ) )
  74          {
  75              if ( has_filter( 'MailPress_Swift_Signer_type' ) )
  76              {
  77                  $t = apply_filters( 'MailPress_Swift_Signer_type', false );
  78                  if ( $t ) $_tabs['signer_' . strtolower( $t )] = $t;
  79              }
  80  
  81              $t = apply_filters( 'MailPress_Swift_Connection_type', 'SMTP' );
  82              $_tabs['connection_' . strtolower( $t )] = $t;
  83              $_tabs = apply_filters( 'MailPress_settings_tab_connection', $_tabs );
  84  
  85              $_tabs['test'] = __( 'Test', 'MailPress' );
  86  
  87              $_tabs = apply_filters( 'MailPress_settings_tab', $_tabs );
  88  
  89              $_tabs['logs'] = __( 'Logs', 'MailPress' );
  90          }
  91  
  92          return $_tabs;
  93      }
  94  
  95  	public static function save_button()
  96      {
  97          $out  = '<p class="submit"><input type="submit" name="Submit" class="button-primary" value="' . esc_attr( __( 'Save Changes' ) ) . '" /></p>' . "\r\n";
  98  
  99          echo $out;
 100      }
 101  
 102  	public static function logs_sub_form ( $name, $data, $headertext )
 103      {
 104          if ( !isset( $data[$name] ) )
 105          {
 106              $data[$name] = MailPress::$default_option_logs;
 107          }
 108  
 109          $xlevel = MP_Log::get_defined_constants();
 110  
 111          $out = '';
 112  
 113          if ( self::$first )
 114          {
 115              self::$first = false;
 116  
 117              $out .= '<tr>' . "\r\n";
 118              foreach( array( __( 'Logs', 'MailPress' ), __( 'Level', 'MailPress' ), __( 'Days', 'MailPress' ), __( 'Last purge', 'MailPress' ), ) as $th )
 119              {
 120                  $out .= '    <th><strong>' . $th . '</strong></th>' . "\r\n";
 121              }
 122              $out .= '</tr>' . "\r\n";
 123          }
 124  
 125          if ( !isset( $xlevel[$data[$name]['level']] ) ) $data[$name]['level'] = key( array_slice( $xlevel, -1, 1, true) );
 126  
 127          $datepurge = ( empty( $data[$name]['lastpurge'] ) ) ? '' : substr( $data[$name]['lastpurge'],0 , 4 ) . '/' . substr( $data[$name]['lastpurge'],4, 2 ) . '/' . substr( $data[$name]['lastpurge'],6, 2 ); 
 128  
 129          $out .= '<tr class="mp_sep">' . "\r\n";
 130          $out .= '    <th><strong>' . $headertext . '</strong></th>' . "\r\n";
 131          $out .= '    <td><select name="logs[' . $name . '][level]">'  . self::select_option( $xlevel, $data[$name]['level'],     false ) . '</select></td>' . "\r\n";
 132          $out .= '    <td><select name="logs[' . $name . '][lognbr]">' . self::select_number( 1, 10,   $data[$name]['lognbr'], 1, false ) . '</select></td>' . "\r\n";
 133          $out .= '    <td>' . $datepurge . '<input type="hidden" name="logs[' . $name . '][lastpurge]" value="' . esc_attr( $data[$name]['lastpurge'] ) . '" /></td>' . "\r\n";
 134          $out .= '</tr>' . "\r\n";
 135  
 136          echo $out;
 137      }
 138  }


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