[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  abstract class MP_WP_Admin_page_ extends MP_ 
   3  {
   4      public static $is_footer = false;
   5  
   6      public static $get_;
   7      public static $pst_;
   8      public static $req_;
   9  
  10  	function __construct()
  11      {
  12          if ( !current_user_can( MP_AdminPage::capability ) ) 
  13              wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
  14  
  15          add_action( 'admin_init',              array( 'MP_AdminPage', 'redirect' ) );
  16          add_action( 'admin_init',              array( 'MP_AdminPage', 'title' ) );
  17  
  18          add_action( 'admin_head',              array( 'MP_AdminPage', 'admin_head' ) );
  19          add_filter( 'screen_meta_screen',     array( 'MP_AdminPage', 'screen_meta_screen' ) );
  20          add_filter( 'current_screen',         array( 'MP_AdminPage', 'current_screen' ), 8, 1 );
  21  
  22          add_action( 'admin_print_styles',     array( 'MP_AdminPage', 'print_styles' ) );
  23          add_action( 'admin_print_scripts' ,     array( 'MP_AdminPage', 'print_header_scripts' ) );
  24          add_action( 'admin_print_footer_scripts' , array( 'MP_AdminPage', 'print_footer_scripts' ) );
  25  
  26          add_action( 'wp_print_scripts',         array( 'MP_AdminPage', 'deregister_scripts' ), 100 );
  27          add_action( 'wp_print_footer_scripts',    array( 'MP_AdminPage', 'deregister_scripts' ), 100 );
  28  
  29          self::get_request();
  30      }
  31  
  32  	public static function get_request()
  33      {
  34          foreach( array( 'get_' =>     INPUT_GET, 'pst_' => INPUT_POST ) as $k => $v )
  35          {
  36              self::$$k = filter_input_array( $v );
  37              if ( is_null( self::$$k ) ) self::$$k = array();
  38          }
  39          self::$req_ = array_merge( self::$get_, self::$pst_ );
  40      }
  41  
  42  ////  Redirect  ////
  43  
  44  	public static function redirect()
  45      {
  46          $action = false;
  47  
  48          foreach( array( 'action', 'action2' ) as $v )
  49          {
  50              if ( !empty( self::$req_[$v] )  && ( self::$req_[$v] != -1 ) ) $action = self::$req_[$v];
  51              if ( $action ) break;
  52          }
  53          return $action;
  54      }
  55  
  56  ////  Title  ////
  57  
  58  	public static function title() {}
  59  
  60  //// Screen Options ////
  61  
  62  	public static function admin_head() 
  63      {
  64          MP_AdminPage::add_help_tab();
  65          MP_AdminPage::set_help_sidebar();
  66      }
  67  
  68  	public static function add_help_tab() 
  69      {
  70          global $current_screen;
  71  
  72          $content = '';
  73          $content .= '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
  74          $content .= '<p>' . sprintf( __( '<a href="%1$s" target="_blank">Support Forum</a>', 'MailPress' ), 'http://groups.google.com/group/mailpress' ) . '</p>';
  75  
  76          $current_screen->add_help_tab( array( 
  77              'id'        => 'overview',
  78              'title'    => __( 'Overview' ),
  79              'content'    => $content )
  80          );
  81      }
  82  
  83  	public static function set_help_sidebar() 
  84      {
  85          global $current_screen;
  86  
  87  //        $badge = ( rand( 0, 1 ) ) ? 'mailpress_badge.gif' : 'logo_lmailpress_admin.png" style="width:125px;';
  88          $badge = 'mailpress_badge.gif';
  89  
  90          $current_screen->set_help_sidebar( 
  91                '<div style="text-align:center;">'
  92              . '<p><a href="http://www.amazon.fr/gp/registry/wishlist/142J4X7XM6N6Q/ref=cm_wl_rlist_go_o?sort=priority&amp;view=null" target="_blank"><img title="' . esc_attr( __( 'Thank you :-) !', 'MailPress' ) ) . '" alt="' . esc_attr( __( 'Thank you :-) !', 'MailPress' ) ) . '" src="' . site_url() . '/' . MP_PATH . 'mp-includes/images/wishlist.png" alt="" /></a></p>'
  93              . '<p><a href="https://paypal.me/arenaut" target="_blank"><img title="' . esc_attr( __( 'Thank you :-) !', 'MailPress' ) ) . '" alt="' . esc_attr( __( 'Thank you :-) !', 'MailPress' ) ) . '" src="' . site_url() . '/' . MP_PATH . 'mp-includes/images/PP_M.png" /></a></p>'
  94              . '<p><a href="http://groups.google.com/group/mailpress" target="_blank"><img title="' . esc_attr( __( 'Support Forum', 'MailPress' ) ) . '" alt="' . esc_attr( __( 'Support Forum', 'MailPress' ) ) . '" src="' . site_url() . '/' . MP_PATH . 'mp-includes/images/' . $badge . '" alt="" /></a></p>'
  95              . '</div>'
  96           );
  97      }
  98  
  99  	public static function screen_meta_screen()
 100      {
 101          return MP_AdminPage::screen;
 102      }
 103  
 104  	public static function current_screen( $current_screen )
 105      {
 106          $current_screen->id = MP_AdminPage::screen;
 107          $current_screen->post_type = '';
 108          return $current_screen;
 109      }
 110  
 111  //// Styles ////
 112  
 113  	public static function print_styles( $styles ) 
 114      {
 115          wp_register_style( 'mp_common',    '/' . MP_PATH . 'mp-admin/css/common.css' );
 116  
 117          $styles = ( is_array( $styles ) ) ?  $styles : array();
 118          $styles = apply_filters( 'MailPress_styles', $styles, MP_AdminPage::screen );
 119          $styles = ( is_array( $styles ) ) ?  $styles : array();
 120  
 121          $styles = array_merge( $styles, MP_AdminPage::print_styles_icons() );
 122          array_unshift( $styles, 'mp_common' );
 123          $styles = array_unique( $styles );
 124  
 125          if ( is_array( $styles ) ) foreach ( $styles as $style ) wp_enqueue_style( $style );
 126      }
 127  
 128  	public static function print_styles_icons( $i = array() ) 
 129      {
 130          if ( empty( $i ) ) return $i;
 131  
 132          $s = array();
 133          foreach( $i as $css )
 134          {
 135              if ( !in_array( $css, array( 'browser', 'device', 'domain', 'ext', 'flag', 'icon', 'os', ) ) ) continue;
 136              wp_register_style( 'mp_' . $css . 's', '/' . MP_PATH . 'mp-admin/css/_' . $css . 's.css' );
 137              $s[] = 'mp_' . $css . 's';
 138          }
 139          return $s;
 140      }
 141  
 142  //// Scripts ////
 143  
 144  	public static function print_header_scripts() { MP_AdminPage::print_scripts( array() ); }
 145  	public static function print_footer_scripts() { self::$is_footer = true; MP_AdminPage::print_scripts( array() ); }
 146  
 147  	public static function print_scripts( $scripts = array() ) 
 148      {
 149          $scripts = apply_filters( 'MailPress_scripts', $scripts, MP_AdminPage::screen );
 150          if ( is_array( $scripts ) ) foreach ( $scripts as $script )    wp_enqueue_script( $script );
 151      }
 152  
 153  	public static function deregister_scripts()
 154      {
 155          $advanced_path = 'advanced/' . get_current_blog_id() . '/scripts';
 156          $root = MP_UPL_ABSPATH . $advanced_path;
 157          $root = apply_filters( 'MailPress_advanced_scripts_root', $root );
 158          $file    = "$root/deregister.xml";
 159  
 160          $y = '';
 161  
 162          if ( is_file( $file ) )
 163          {
 164              $x = file_get_contents( $file );
 165              if ( $xml = simplexml_load_string( $x ) )
 166              {
 167                  foreach ( $xml->script as $script )
 168                  {
 169                      wp_deregister_script( ( string ) $script );
 170                      $y .= ( !empty( $y ) ) ? ", $script" : $script;
 171                  }
 172              }
 173              echo "\n<!-- MailPress_deregister_scripts : $y -->\n";
 174          }
 175      }
 176  
 177  ////  Body  ////
 178  
 179  	public static function body() { include( MP_ABSPATH . 'mp-admin/includes/' . basename( MP_AdminPage::file ) ); }
 180  
 181  //// Html ////
 182  
 183  	public static function get_url_parms( $parms = array( 'mode', 'status', 's', 'paged', 'author', 'startwith' ) )
 184      {
 185          $url_parms = array();
 186          foreach ( $parms as $parm ) if ( isset( self::$req_[$parm] ) )
 187          {
 188              if ( isset( self::$req_[$parm] ) )
 189              {
 190                  $url_parms[$parm] = trim( stripslashes( self::$req_[$parm] ) );
 191                  switch ( $parm )
 192                  {
 193                      case 'startwith' :
 194                          if ( -1 == $url_parms[$parm] )     unset( $url_parms[$parm] );
 195                      break;
 196                      case 'paged' :
 197                          if ( 1 >= $url_parms[$parm] )     unset( $url_parms[$parm] );
 198                      case 's' :
 199                      case 'author' :
 200                      case 'mailinglist' :
 201                      case 'newsletter' :
 202                          if ( empty( $url_parms[$parm] ) ) unset( $url_parms[$parm] );
 203                      break;
 204                  }
 205              }
 206          }
 207          return $url_parms;
 208      }
 209  
 210  	public static function post_url_parms( $url_parms, $parms = array( 'mode', 'status', 's', 'paged', 'author' ), $echo = true )
 211      {
 212          $out = '';
 213  
 214          foreach ( $parms as $key )
 215              if ( isset( $url_parms[$key] ) )
 216                  $out .= '<input type="hidden" name="' . $key . '" value="' . esc_attr( $url_parms[$key] ) . '" />';
 217  
 218          if ( $echo ) echo $out;
 219  
 220          return $out;
 221      }
 222  
 223  	public static function message( $s, $b = true )
 224      {
 225          if ( $b )     echo '<div id="message" class="updated fade"><p>' . $s . '</p></div>';
 226           else         echo '<div id="message" class="error"><p>'       . $s . '</p></div>';
 227      }
 228  }


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