[ Index ]

MailPress 544

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

title

Body

[close]

/mp-includes/class/ -> MP_.class.php (source)

   1  <?php
   2  abstract class MP_
   3  {
   4  
   5  ////    no limit ////
   6  
   7  	public static function no_abort_limit()
   8      {
   9          if (function_exists('ignore_user_abort'))     ignore_user_abort(1);
  10          if (function_exists('set_time_limit'))         if( !in_array(ini_get('safe_mode'),array('1', 'On')) ) set_time_limit(0);
  11      }
  12  
  13  //// image ////
  14  
  15  	public static function is_image($file)
  16      {
  17          return (in_array(substr(strtolower(strrchr(strtolower($file), '.')), 1), self::ext_image()));
  18      }
  19  
  20  	public static function ext_image()
  21      {
  22          return array('jpg', 'jpeg', 'png', 'gif', 'tif', 'bmp');
  23      }
  24  
  25  //// url ////
  26  
  27  	public static function url($url, $url_parms = array(), $wpnonce = false)
  28      {
  29          $url = add_query_arg(array_map ( 'urlencode', $url_parms), $url);
  30          return ($wpnonce) ? wp_nonce_url( $url, $wpnonce ) : $url;
  31      }
  32  
  33  //// plugin/add-on ////
  34  
  35  	public static function plugin_links($links, $file, $basename, $tab)
  36      {
  37          if ($basename != $file) return $links;
  38  
  39          $settings_link = "<a href='" . MailPress_settings . "&amp;tab=$tab'>" . __('Settings') . '</a>';
  40          array_unshift ($links, $settings_link);
  41          return $links;
  42      }
  43  
  44  //// form ////
  45  
  46  	public static function select_option($list, $selected, $echo = true)
  47      {
  48          $x = '';
  49          foreach( $list as $value => $label )
  50          {
  51              $_selected = (!is_array($selected)) ? $selected : ( (in_array($value, $selected)) ? $value : null );
  52              $x .= "<option " . self::selected( (string) $value, (string) $_selected, false, false ) . " value=\"$value\">$label</option>";
  53          }
  54          if (!$echo) return "\n$x\n";
  55          echo "\n$x\n";
  56      }
  57  
  58  	public static function select_number($start, $max, $selected, $tick = 1, $echo = true)
  59      {
  60          $x = '';
  61          while ($start <= $max)
  62          {
  63              if (intval ($start/$tick) == $start/$tick ) 
  64                  $x .= "<option " . self::selected( (string) $start, (string) $selected, false, false ) . " value='$start'>$start</option>";
  65              $start++;
  66          }
  67          if (!$echo) return "\n$x\n";
  68          echo "\n$x\n";
  69      }
  70  
  71  	public static function selected( $selected, $current = true, $echo = true) 
  72      {
  73          return self::__checked_selected_helper( $selected, $current, $echo, 'selected' );
  74      }
  75  
  76  	public static function __checked_selected_helper( $helper, $current, $echo, $type) 
  77      {
  78          $result = ( $helper == $current) ? " $type='$type'" : '';
  79          if ($echo) echo $result;
  80          return $result;
  81      }
  82  
  83  //// functions ////
  84  
  85  	public static function mp_redirect($r)
  86      {
  87          if (defined('MP_DEBUG_LOG') && !defined('MP_DEBUG_LOG_STOP')) { global $mp_debug_log; if (isset($mp_debug_log)) $mp_debug_log->log(" mp_redirect : >> $r << "); $mp_debug_log->end(true); define ('MP_DEBUG_LOG_STOP', true);}
  88          wp_redirect($r);
  89          self::mp_die();
  90      }
  91  
  92  	public static function mp_die($r = true)
  93      {
  94          if (defined('MP_DEBUG_LOG') && !defined('MP_DEBUG_LOG_STOP')) { global $mp_debug_log; if (isset($mp_debug_log)) $mp_debug_log->log(" mp_die : >> $r << "); $mp_debug_log->end(true); define ('MP_DEBUG_LOG_STOP', true);}
  95          die($r);
  96      }
  97  
  98  	public static function print_scripts_l10n_val($val0, $before = "")
  99      {
 100          if (is_array($val0))
 101          {
 102              $eol = "\t\t";
 103              $text =  "{\n\t$before";
 104              foreach($val0 as $var => $val)
 105              {
 106                  $text .=  "$eol$var: " . self::print_scripts_l10n_val($val, "\t" . $before );
 107                  $eol = ", \n$before\t\t\t";
 108              }
 109              $text .= "\n\t\t$before}";
 110          }
 111          else
 112          {
 113              $quot = (stripos($val0, '"') === false) ? '"' : "'";
 114              $text = "$quot$val0$quot";
 115          }
 116          return $text;
 117      }
 118  }


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