[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_WP_AutoRefresh_js
   3  {
   4      /** Singleton instance */
   5      private static $instance = null;
   6  
   7  	function __construct()
   8      {
   9      }
  10  
  11  	public static function getInstance( $scripts, $file = false )
  12      {
  13          if ( isset( self::$instance ) ) return $scripts;
  14  
  15          self::$instance = new self();
  16          return self::register_scripts( $scripts, $file );
  17      }
  18  
  19  	public static function register_scripts( $scripts, $file = false )
  20      {
  21          $every   = apply_filters( 'MailPress_autorefresh_every', 30 );
  22  
  23          $checked = checked( isset( MP_AdminPage::$get_['autorefresh'] ), true, false );
  24          $time    = ( isset( MP_AdminPage::$get_['autorefresh'] ) ) ?  MP_AdminPage::$get_['autorefresh'] : $every;
  25          $time    = ( is_numeric( $time ) && ( $time > $every ) ) ? $time : $every;
  26          $time    = '<input type="text" id="MP_Refresh_every" class="screen-per-page" maxlength="5" style="width:5em;" value="' . $time . '" />';
  27          $option  = '<h5>' . __( 'Auto refresh', 'MailPress' ) . '</h5>';
  28          $option .= '<div><input type="checkbox" id="MP_Refresh" style="margin:0 5px 0 2px;"' . $checked . ' /><span class="MP_Refresh">' . sprintf( __( '%1$s Autorefresh %2$s every %3$s sec', 'MailPress' ), '<label for="MP_Refresh" style="vertical-align:inherit;">', '</label>', $time ) . '</span></div>';
  29  
  30          $_script = 'mp_refresh';
  31          $localize = array( 'screen' => MP_AdminPage::screen, 'every' => $every, 'message' => __( 'Autorefresh in %i% sec', 'MailPress' ), 'option'    => $option );
  32          if ( $file )
  33          {
  34              $_script = 'mp_refresh_i';
  35              $localize['iframe']    = 'mp';
  36              $localize['src']    = MP_AdminPage::get_url() . '/' . MP_AdminPage::$get_['id'];
  37              $localize['url']    = admin_url( 'admin-ajax.php' );
  38          }
  39          $localize['l10n_print_after'] = 'try{convertEntities( adminMpRefreshL10n );}catch( e ){};';
  40  
  41          wp_register_script( $_script,     '/' . MP_PATH . "mp-includes/js/$_script.js", array( 'schedule' ), false, 1 );
  42          wp_localize_script( $_script,     'adminMpRefreshL10n', $localize );
  43          $scripts[] = $_script;
  44  
  45          return $scripts;
  46      }
  47  }


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