[ Index ]

MailPress 7.1

[ 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' ) )        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 = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', add_query_arg( 'tab', $tab, MailPress_settings ), __( 'Settings' ) );
  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 .= sprintf( '<option%1$s value="%2$s">%3$s</option>', self::selected( ( string ) $value, ( string ) $_selected, false, false ), $value, $label );
  53  
  54          }
  55          if ( !$echo ) return "\n$x\n";
  56          echo "\n$x\n";
  57      }
  58  
  59  	public static function select_number( $start, $max, $selected, $tick = 1, $echo = true )
  60      {
  61          $x = '';
  62          while ( $start <= $max )
  63          {
  64              if ( intval ( $start/$tick ) == $start/$tick )
  65              {
  66                  $x .= sprintf( '<option%1$s value="%2$s">%3$s</option>', self::selected( ( string ) $start, ( string ) $selected, false, false ), $start, $start );
  67              }
  68              $start++;
  69          }
  70          if ( !$echo ) return "\n$x\n";
  71          echo "\n$x\n";
  72      }
  73  
  74  	public static function selected( $selected, $current = true, $echo = true ) 
  75      {
  76          return self::__checked_selected_helper( $selected, $current, $echo, 'selected' );
  77      }
  78  
  79  	public static function __checked_selected_helper( $helper, $current, $echo, $type ) 
  80      {
  81          $result = ( $helper == $current ) ? sprintf( ' %1$s="%1$s"', $type ) : '';
  82          if ( $echo ) echo $result;
  83          return $result;
  84      }
  85  
  86  //// functions ////
  87  
  88  	public static function mp_redirect( $r )
  89      {
  90          if ( defined( 'MP_DEBUG_LOG' ) && !defined( 'MP_DEBUG_LOG_STOP' ) )
  91          {
  92              global $mp_debug_log;
  93              if ( isset( $mp_debug_log ) )
  94              {
  95                  $mp_debug_log->log( " mp_redirect : >> $r << " );
  96              }
  97              $mp_debug_log->end( true );
  98              define ( 'MP_DEBUG_LOG_STOP', true );
  99          }
 100          wp_redirect( $r );
 101          self::mp_die();
 102      }
 103  
 104  	public static function mp_die( $r = true )
 105      {
 106          if ( defined( 'MP_DEBUG_LOG' ) && !defined( 'MP_DEBUG_LOG_STOP' ) )
 107          {
 108              global $mp_debug_log;
 109              if ( isset( $mp_debug_log ) )
 110              {
 111                  $mp_debug_log->log( " mp_die : >> $r << " );
 112              }
 113              $mp_debug_log->end( true );
 114              define ( 'MP_DEBUG_LOG_STOP', true );
 115          }
 116          die( $r );
 117      }
 118  
 119  	public static function print_scripts_l10n_val( $val0, $is_num = false, $before = "" )
 120      {
 121          if ( is_array( $val0 ) )
 122          {
 123              $eol = "\t\t";
 124              $text =  "{\n\t$before";
 125              foreach( $val0 as $var => $val )
 126              {
 127                  $text .=  "$eol$var: " . self::print_scripts_l10n_val( $val, $is_num, "\t" . $before );
 128                  $eol = ", \n$before\t\t\t";
 129              }
 130              $text .= "\n\t\t$before}";
 131          }
 132          else
 133          {
 134              $quot = ( stripos( $val0, '"' ) === false ) ? '"' : "'";
 135              $quot = ( $is_num && is_numeric( $val0 ) ) ? '' : $quot;
 136              $text = "$quot$val0$quot";
 137          }
 138          return $text;
 139      }
 140  }


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