[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_AdminPage extends MP_WP_Admin_page_list_
   3  {
   4      const screen        = MailPress_page_mails;
   5      const capability    = 'MailPress_edit_mails';
   6      const help_url        = 'http://blog.mailpress.org/tutorials/';
   7      const file            = __FILE__;
   8  
   9  ////  Redirect  ////
  10  
  11  	public static function redirect() 
  12      {
  13          $action = parent::redirect();
  14          if ( !$action ) return;
  15  
  16          $url_parms    = self::get_url_parms();
  17          $checked    = ( isset( self::$get_['checked'] ) ) ? self::$get_['checked'] : array();
  18  
  19          $count    = str_replace( 'bulk-', '', $action );
  20          $count    .= 'd';
  21          $$count    = 0;
  22  
  23          switch( $action )
  24          {
  25              case 'bulk-pause' :
  26                  foreach( $checked as $id )
  27                  {
  28                      if ( MP_Mail::set_status( $id, 'paused' ) )
  29                      {
  30                          $$count++;
  31                      }
  32                  }
  33              break;
  34              case 'bulk-restart' :
  35                  foreach( $checked as $id )
  36                  {
  37                      if ( MP_Mail::set_status( $id, 'unsent' ) )
  38                      {
  39                          $$count++;
  40                      }
  41                  }
  42              break;
  43              case 'bulk-archive' :
  44                  foreach( $checked as $id )
  45                  {
  46                      if ( MP_Mail::set_status( $id, 'archived' ) )
  47                      {
  48                          $$count++;
  49                      }
  50                  }
  51              break;
  52              case 'bulk-unarchive' :
  53                  foreach( $checked as $id )
  54                  {
  55                      if ( MP_Mail::set_status( $id, 'sent' ) )
  56                      {
  57                          $$count++;
  58                      }
  59                  }
  60              break;
  61              case 'bulk-send' :
  62                  $sent = $notsent = 0;
  63                  foreach( $checked as $id )
  64                  {
  65                      if ( 'draft' != MP_Mail::get_status( $id ) )
  66                      {
  67                          continue;
  68                      }
  69                      $x = MP_Mail_draft::send( $id );
  70                      $url = ( is_numeric( $x ) ) ? $sent += $x : $notsent++ ;
  71                  }
  72                  if ( $sent )
  73                  {
  74                      $url_parms['sent']    = $sent;
  75                  }
  76                  if ( $notsent )
  77                  {
  78                      $url_parms['notsent'] = $notsent;
  79                  }
  80              break;
  81              case 'bulk-delete' :
  82                  foreach( $checked as $id )
  83                  {
  84                      if ( MP_Mail::set_status( $id, 'delete' ) )
  85                      {
  86                          $$count++;
  87                      }
  88                  }
  89              break;
  90          }
  91  
  92          if ( $$count )
  93          {
  94              $url_parms[$count] = $$count;
  95          }
  96          self::mp_redirect( self::url( MailPress_mails, $url_parms ) );
  97      }
  98  
  99  //// Help ////
 100  
 101  	public static function add_help_tab() 
 102      {
 103          global $current_screen;
 104  
 105          $content = '';
 106          $content .= '<p><strong>' . __( 'Mails :', 'MailPress' ) . '</strong></p>';
 107          $content .= '<p>' . __( 'This screen provides access to all of your mails. You can customize the display of this screen to suit your needs.', 'MailPress' ) . '</p>';
 108  
 109          $current_screen->add_help_tab( array(     'id'        => 'overview',
 110                                          'title'    => __( 'Overview' ),
 111                                          'content'    => $content )
 112          );
 113  
 114          $content = '';
 115          $content .= '<p>' . __( 'You can customize the display of this screen&#8217;s contents in a number of ways:', 'MailPress' ) . '</p>';
 116          $content .= '<ul>';
 117          $content .= '<li>' . __( 'You can hide/display columns based on your needs and decide how many mails to list per screen using the Screen Options tab.', 'MailPress' ) . '</li>';
 118          $content .= '<li>' . __( 'You can filter the list of mails by status using the text links above the mails list to only show mails with that status. The default view is to show all mails.', 'MailPress' ) . '</li>';
 119          $content .= '<li>' . __( 'Depending on which add on you have activated, you may find an autorefresh option in the Screen Options tab.', 'MailPress' ) . '</li>';
 120          $content .= '</ul>';
 121  
 122          $current_screen->add_help_tab( array(     'id'        => 'screen-display',
 123                                          'title'    => __( 'Screen Display' ),
 124                                          'content'    => $content )
 125          );
 126  
 127          $content = '';
 128          $content .= '<p>' . __( 'Hovering over a row in the mails list will display action links that allow you to manage your mail. You can perform the following actions depending on mail status and when available:', 'MailPress' ) . '</p>';
 129          $content .= '<ul>';
 130          $content .= '<li>' . __( '<strong>Edit</strong> &mdash; takes you to the editing screen for that draft mail. You can also reach that screen by clicking on the mail title.', 'MailPress' ) . '</li>';
 131          $content .= '<li>' . __( '<strong>Send</strong> &mdash; sends the draft mail.', 'MailPress' ) . '</li>';
 132          $content .= '<li>' . __( '<strong>Archive</strong> &mdash; archives any sent mail. This status allows to select some mails such as newsletters to be displayed on your site using a specific WordPress theme page template (see <code>mailpress/mp-content/xtras</code>).', 'MailPress' ) . '</li>';
 133          $content .= '<li>' . __( '<strong>Delete</strong> &mdash; removes your mail from this list and delete it permanently.', 'MailPress' ) . '</li>';
 134          $content .= '<li>' . __( '<strong>Tracking</strong> &mdash; displays collected informations during the tracking. Available for any new sent mail after tracking add on activation.', 'MailPress' ) . '</li>';
 135          $content .= '</ul>';
 136  
 137          $current_screen->add_help_tab( array(     'id'        => 'action-links',
 138                                          'title'    => __( 'Available Actions' ),
 139                                          'content'    => $content )
 140          );
 141  
 142          $content = '';
 143          $content .= '<p>' . __( 'You can also permanently delete multiple mails at once. Select the mails you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.', 'MailPress' ) . '</p>';
 144  
 145          $current_screen->add_help_tab( array(     'id'        => 'bulk-actions',
 146                                          'title'    => __( 'Bulk Actions' ),
 147                                          'content'    => $content )
 148          );
 149      }
 150  
 151  ////  Styles  ////
 152  
 153  	public static function print_styles( $s ) 
 154      {
 155          $styles = ( is_array( $s ) ) ? $s : array();
 156  
 157          wp_register_style( self::screen,         '/' . MP_PATH . 'mp-admin/css/mails.css',       array( 'thickbox' ) );
 158          $styles[] = self::screen;
 159  
 160          parent::print_styles( $styles );
 161      }
 162  
 163  	public static function print_styles_icons( $i = array( 'icon', ) ) 
 164      {
 165          return parent::print_styles_icons( $i );
 166      }
 167  
 168  //// Scripts ////
 169  
 170  	public static function print_scripts( $scripts = array() ) 
 171      {
 172          $scripts = apply_filters( 'MailPress_autorefresh_js', $scripts );
 173  
 174          wp_register_script( 'mp-ajax-response',     '/' . MP_PATH . 'mp-includes/js/mp_ajax_response.js', array( 'jquery' ), false, 1 );
 175          wp_localize_script( 'mp-ajax-response',         'wpAjax', array( 
 176              'noPerm' => __( 'Email was not sent AND/OR Update database failed', 'MailPress' ), 
 177              'broken' => __( 'An unidentified error has occurred.' ), 
 178              'l10n_print_after' => 'try{convertEntities( wpAjax );}catch( e ){};' 
 179           ) );
 180  
 181          wp_register_script( 'mp-lists',         '/' . MP_PATH . 'mp-includes/js/mp_lists.js', array( 'mp-ajax-response' ), false, 1 );
 182  
 183          wp_register_script( 'mp-thickbox',         '/' . MP_PATH . 'mp-includes/js/mp_thickbox.js', array( 'thickbox' ), false, 1 );
 184  
 185          wp_register_script( self::screen,         '/' . MP_PATH . 'mp-admin/js/mails.js', array( 'mp-thickbox', 'mp-lists' ), false, 1 );
 186          wp_localize_script( self::screen,     'MP_AdminPageL10n', array(     
 187              'pending' => __( '%i% pending' ), 
 188              'screen' => self::screen, 
 189              'l10n_print_after' => 'try{convertEntities( MP_AdminPageL10n );}catch( e ){};' 
 190           ) );
 191  
 192          $scripts[] = self::screen;
 193          parent::print_scripts( $scripts );
 194      }
 195  
 196  //// Columns ////
 197  
 198  	public static function get_columns() 
 199      {
 200          $disabled = ( !current_user_can( 'MailPress_delete_mails' ) ) ? ' disabled="disabled"' : '';
 201          $columns = array(    'cb'        => '<input type="checkbox"' . $disabled .  '/>', 
 202                          'title'    => __( 'Subject', 'MailPress' ), 
 203                          'author'    => __( 'Author' ), 
 204                          'theme'    => __( 'Theme', 'MailPress' ), 
 205                          'to'        => __( 'To', 'MailPress' ), 
 206                          'date'    => __( 'Date' )
 207          );
 208          $columns = apply_filters( 'MailPress_mails_columns', $columns );
 209          return $columns;
 210      }
 211  
 212  //// List ////
 213  
 214  	public static function get_list( $args ) 
 215      {
 216          extract( $args );
 217  
 218          global $wpdb;
 219  
 220          $where = " AND status <> '' ";
 221  
 222          if ( isset( $url_parms['s'] ) )
 223          {
 224              $sc = array( 'theme', 'themedir', 'template', 'toemail', 'toname', 'subject', 'html', 'plaintext', 'created', 'sent' );
 225  
 226              $where .= self::get_search_clause( $url_parms['s'], $sc );
 227          }
 228  
 229          if ( isset( $url_parms['status'] ) && !empty( $url_parms['status'] ) )
 230          {
 231              $where .= " AND status = '" . $url_parms['status'] . "'";
 232          }
 233          if ( isset( $url_parms['author'] ) && !empty( $url_parms['author'] ) )
 234          {
 235              $where .= " AND ( created_user_id = " . $url_parms['author'] . "  OR sent_user_id = " . $url_parms['author'] . " ) ";
 236          }
 237          if ( !current_user_can( 'MailPress_edit_others_mails' ) )
 238          {
 239              $where .= " AND ( created_user_id = " . MP_WP_User::get_id() . " ) ";
 240          }
 241  
 242          $args['query'] = "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->mp_mails WHERE 1=1 $where ORDER BY created DESC";
 243          $args['cache_name'] = 'mp_mail';
 244  
 245          list( $_mails, $total ) = parent::get_list( $args );
 246  
 247          $counts = array();
 248          $query = "SELECT status, count( * ) as count FROM $wpdb->mp_mails GROUP BY status;";
 249          $statuses = $wpdb->get_results( $query );
 250  
 251          $subsubsub_urls = false;
 252  
 253          $libs = array(    'all'        => __( 'All' ),
 254                      'archived'    => __( 'Archive', 'MailPress' ),
 255                      'sent'    => __( 'Sent', 'MailPress' ),
 256                      'sending'    => __( 'Pending', 'MailPress' ),
 257                      'paused'    => __( 'Paused', 'MailPress' ),
 258                      'unsent'    => __( 'Unsent', 'MailPress' ),
 259                      'draft'    => __( 'Draft', 'MailPress' ),
 260                      'search'    => __( 'Search Results' )
 261          );
 262  
 263          if ( $statuses )
 264          {
 265              foreach( $statuses as $status )
 266              {
 267                  if ( $status->count )
 268                  {
 269                      $counts[$status->status] = $status->count;
 270                  }
 271              }
 272              $counts['all'] = $wpdb->get_var( "SELECT count( * ) FROM $wpdb->mp_mails WHERE status <> '';" );
 273              if ( isset( $url_parms['s'] ) )
 274              {
 275                  $counts['search'] = count( $_mails );
 276              }
 277              $out = array();
 278  
 279              foreach( $libs as $k => $lib )
 280              {
 281                  if ( !isset( $counts[$k] ) || !$counts[$k] )
 282                  {
 283                      continue;
 284                  }
 285  
 286                  $args = array();
 287                  if ( isset( $url_parms['mode'] ) )                 $args['mode'] = $url_parms['mode'];
 288                  if ( ( 'search' == $k ) && ( isset( $url_parms['s'] ) ) )      $args['s'] = $url_parms['s'];
 289                  elseif ( 'all' != $k )                         $args['status'] = $k;
 290                  $url    = esc_url( add_query_arg( $args, MailPress_mails ) );
 291  
 292                  $cls = '';
 293                  if ( isset( $url_parms['s'] ) )
 294                  {
 295                      if ( 'search' == $k )
 296                      {
 297                          $cls = ' class="current"';
 298                      }
 299                  }
 300                  elseif ( isset( $url_parms['status'] ) )
 301                  {
 302                      if ( $url_parms['status'] == $k )
 303                      {
 304                          $cls = ' class="current"';
 305                      }
 306                  }
 307                  elseif ( 'all' == $k )
 308                  {
 309                      $cls = ' class="current"';
 310                  }
 311  
 312                  $out[] = sprintf( '<a%1$s href="%2$s">%3$s <span class="count">( <span class="mail-count-%4$s">%5$s</span> )</span></a>', $cls, $url, $lib, $k, $counts[$k] );
 313              }
 314  
 315              if ( !empty( $out ) )
 316              {
 317                  $subsubsub_urls = '<li>' . join( ' | </li><li>', $out ) . '</li>';
 318              }
 319          }
 320          return array( $_mails, $total, $subsubsub_urls );
 321      }
 322  
 323  ////  Row  ////
 324  
 325  	public static function get_row( $id, $url_parms, $xtra = false ) 
 326      {
 327          global $mp_mail;
 328          
 329          $mp_mail = $mail = MP_Mail::get( $id );
 330          $the_mail_status = $mail->status;
 331  
 332          $url_parms['mode'] = $url_parms['mode'] ?? 'list';
 333  // url's
 334          $args = array();
 335          $args['id']    = $id;
 336  
 337          $edit_url        = esc_url( self::url( MailPress_edit, array_merge( $args, $url_parms ) ) );
 338  
 339          $args['action']    = 'pause';
 340          $pause_url        = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ) ) );
 341  
 342          $args['action']    = 'restart';
 343          $restart_url    = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ) ) );
 344  
 345          $args['action']    = 'archive';
 346          $archive_url    = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ), "archive-mail_{$mail->id}" ) );
 347  
 348          $args['action']    = 'unarchive';
 349          $unarchive_url    = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ), "unarchive-mail_{$mail->id}" ) );
 350  
 351          $args['action']    = 'send';
 352          $send_url        = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ) ) );
 353  
 354          $args['action']    = 'delete';
 355          $delete_url    = esc_url( self::url( MailPress_write, array_merge( $args, $url_parms ), "delete-mail_$id" ) );
 356  
 357              $args = array(    'id'            => $id,
 358                      'action'        => 'mp_ajax',
 359                      'mp_action'    => 'iview',
 360                      'TB_iframe'    => 'true'
 361          );
 362          if ( 'draft' == $mail->status )
 363          {
 364              if ( !empty( $mail->theme ) ) 
 365              {
 366                  $args['theme'] = $mail->theme;
 367              }
 368          }
 369          $view_url = esc_url( add_query_arg( $args, admin_url( 'admin-ajax.php' ) ) );
 370                
 371  // actions
 372          $actions = array();
 373          $actions['edit']    = '<a href="' . $edit_url         . '">' . __( 'Edit' )             . '</a>';
 374          $actions['send']     = '<a href="' . $send_url         . '">' . __( 'Send', 'MailPress' )     . '</a>';
 375          $actions['pause']    = '<a href="' . $pause_url        . '">' . __( 'Pause', 'MailPress' )     . '</a>';
 376          $actions['restart']     = '<a href="' . $restart_url     . '">' . __( 'Restart', 'MailPress' )    . '</a>';
 377          $actions = apply_filters( 'MailPress_mails_actions', $actions, $mp_mail, $url_parms );
 378  
 379          $actions['approve']    = '<a href="' . $unarchive_url     . '" class="dim:the-mail-list:mail-' . $id . ':unapproved:e7e7d3:e7e7d3:?mode=' . $url_parms['mode'] . '" >' . __( 'Unarchive', 'MailPress' )    . '</a>';
 380          $actions['unapprove']    = '<a href="' . $archive_url     . '" class="dim:the-mail-list:mail-' . $id . ':unapproved:e7e7d3:e7e7d3:?mode=' . $url_parms['mode'] . '" >' . __( 'Archive', 'MailPress' )    . '</a>';
 381  
 382          $actions['delete']    = '<a href="' . $delete_url    . '" class="submitdelete" >'             . __( 'Delete', 'MailPress' )     . '</a>';
 383          $actions['view']    = '<a href="' . $view_url        . '" class="thickbox thickbox-preview" >'    . __( 'View', 'MailPress' )     . '</a>';
 384  
 385          switch( $mail->status )
 386          {
 387              case 'draft' :
 388                  $include = array( 'edit', 'send', 'delete', 'view' );
 389              break;
 390              case 'unsent' :
 391                  $include = array( 'pause', 'tracking', 'view' );
 392              break;
 393              case 'sending' :
 394                  $include = array( 'pause', 'tracking', 'view' );
 395              break;
 396              case 'paused' :
 397                  $include = array( 'restart', 'tracking', 'delete', 'view' );
 398              break;
 399              case 'sent' :
 400                  $include = array( 'tracking', 'approve', 'unapprove', 'delete', 'view' );
 401              break;
 402              case 'archived' :
 403                  $include = array( 'tracking', 'approve', 'unapprove', 'view' );
 404              break;
 405              default :
 406                  $include = array( 'view' );
 407              break;
 408          }
 409          foreach( $actions as $k => $v )
 410          {
 411              if ( !in_array( $k, $include ) )
 412              {
 413                  unset( $actions[$k] );
 414              }
 415          }
 416  
 417          if ( !current_user_can( 'MailPress_send_mails' ) )
 418          {
 419              unset( $actions['send'] );
 420          }
 421          if ( !current_user_can( 'MailPress_delete_mails' ) ) 
 422          {
 423              unset( $actions['delete'] );
 424          }
 425          if ( !current_user_can( 'MailPress_archive_mails' ) )
 426          {
 427              unset( $actions['approve'], $actions['unapprove'] );
 428          }
 429  
 430  
 431  // table row 
 432  //    class
 433          $row_class = 'iedit author-self level-0 format-standard';
 434          switch ( $the_mail_status )
 435          {
 436              case 'archived' :
 437                  $row_class .= ' unapproved';
 438              break;
 439              case 'draft' :
 440                  $row_class .= ' draft';
 441              break;
 442              case 'unsent' :
 443                  $row_class .= ' unsent';
 444              break;
 445          }
 446  //     checkbox
 447          $disabled = ( !current_user_can( 'MailPress_delete_mails' ) && !current_user_can( 'MailPress_send_mails' ) ) ? ' disabled="disabled"' : '';
 448  //    to
 449          $draft_dest = MP_User::get_mailinglists();
 450  
 451          switch ( true )
 452          {
 453              case ( $xtra ) :
 454                  $email_display = '<span class="onerror blinkme">' . $xtra . '</span>';
 455              break;
 456              case ( MailPress::is_email( $mail->toemail ) ) :
 457                  $mail_url = self::url( MailPress_mails, $url_parms );
 458                  $mail_url = remove_query_arg( 's', $mail_url );
 459                  $mail_url = esc_url( add_query_arg( 's', $mail->toemail, $mail_url ) );
 460  
 461                  $email_display = '';
 462                  $mail_url2         = '<a class="row-title" href="' . $mail_url . '"  title="' . esc_attr( sprintf( __( 'Search &#8220;%1$s&#8221;', 'MailPress' ), $mail->toemail ) ) . '">';
 463                  if ( ( 'detail' == $url_parms['mode'] ) && ( get_option( 'show_avatars' ) ) )
 464                  {
 465                      $email_display .= '<div>';
 466                      $email_display .= $mail_url2;
 467                      $email_display .= get_avatar( $mail->toemail, 32 );
 468                      $email_display .= '</a>';
 469                      $email_display .= '</div>';
 470                  }
 471                  $email_display .= '<div>';
 472                  $email_display .= $mail_url2;
 473                  $email_display .= '<strong>';
 474                  $email_display .= ( strlen( $mail->toemail ) > 40 ) ? substr( $mail->toemail, 0, 39 ) . '...' : $mail->toemail;
 475                  $email_display .= '</strong>';
 476                  $email_display .= '</a>';
 477                  if ( !empty( $mail->toname ) )
 478                  {
 479                      $email_display .= '<br />' . $mail->toname;
 480                  }
 481                  $email_display .= '</div>';
 482              break;
 483              case ( isset( $draft_dest[$mail->toemail] ) ) :
 484                  $email_display = '<strong>' . $draft_dest[$mail->toemail] . '</strong>';
 485              break;
 486              case ( is_serialized( $mail->toemail ) ) :
 487                  $email_display = '<div class="num post-com-count-wrapper"><a class="post-com-count"><span class="comment-count">' . count( unserialize( $mail->toemail ) ) . '</span></a></div>';
 488              break;
 489              default  :
 490                  $email_display = '<span class="onerror">' . __( '(unknown)', 'MailPress' ) . '</span>';
 491                  unset( $actions['send'] );
 492              break;
 493          }
 494          $email_display = apply_filters( 'MailPress_to_mails_column', $email_display, $mail );
 495          if ( $mailinglist_desc = MP_Mail_meta::get( $mail->id, '_mailinglist_desc' ) )
 496          {
 497              $email_display = '<div>' . $email_display . '</div>' . $mailinglist_desc;
 498          }
 499  
 500  //    author
 501          $author = ( 0 == $mail->sent_user_id ) ? $mail->created_user_id : $mail->sent_user_id;
 502          if ( $author != 0 && is_numeric( $author ) ) 
 503          {
 504              unset( $url_parms['author'] );
 505              $wp_user         = get_userdata( $author );
 506              $author_url     = esc_url( self::url( add_query_arg( 'author', $author, MailPress_mails ), $url_parms ) );
 507          }
 508  //    subject
 509          $metas = MP_Mail_meta::get( $id, '_MailPress_replacements' );
 510          $subject_display = $mail->subject;
 511          if ( $metas ) foreach( $metas as $k => $v )
 512          {
 513              $subject_display = str_replace( $k, $v, $subject_display );
 514          }
 515  
 516          $title_class    = 'row-title';
 517          $title_class    .=( 'draft' == $mail->status ) ? '' : ' thickbox thickbox-preview';
 518          $title_link    = ( 'draft' == $mail->status ) ? $edit_url : $view_url;
 519          $title_title    = esc_attr( sprintf( ( 'draft' == $mail->status ) ?  __( 'Edit &#8220;%1$s&#8221;', 'MailPress' ) : __( 'View &#8220;%1$s&#8221;', 'MailPress' ) , ( '' == $subject_display ) ? __( '(no subject)', 'MailPress' ) : htmlspecialchars( $subject_display, ENT_QUOTES ) ) );
 520  
 521  //    attachments
 522          $attach = false;
 523          $metas = MP_Mail_meta::has( $id, '_MailPress_attached_file' );
 524          if ( $metas )
 525          {
 526              foreach( $metas as $meta )
 527              {
 528                  $meta_value = unserialize( $meta['meta_value'] );
 529                  if ( $the_mail_status == 'sent' )
 530                  {
 531                      $attach = true;
 532                      break;
 533                  }
 534                  elseif ( is_file( $meta_value['file_fullpath'] ) )
 535                  {
 536                      $attach = true;
 537                      break;
 538                  }
 539              }
 540          }
 541  
 542          $out = '';
 543          $out .= '<tr id="mail-' . $id . '" class="' . $row_class . '">';
 544  
 545          $columns = self::get_columns();
 546          $hidden  = self::get_hidden_columns();
 547  
 548          foreach ( $columns as $column_name => $column_display_name ) 
 549          {
 550              $attributes = sprintf( 'class="%1$s column-%1$s%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( 'unsent' == $mail->status ) ? ' fi' : '' );
 551  
 552              switch ( $column_name ) 
 553              {
 554                  case 'cb':
 555                      $out .= '<th class="check-column">';
 556                      if ( isset( $actions['delete'] ) )
 557                      {
 558                          $out .= ' <input type="checkbox" name="checked[]" value="' . $id . '"' . $disabled . ' />';
 559                      }
 560                      $out .= '</th>';
 561                  break;
 562                  case 'title':
 563                      $attributes = sprintf( 'class="title column-title has-row-actions column-primary page-title%2$s%3$s"', $column_name, ( in_array( $column_name, $hidden ) ) ? ' hidden' : '', ( 'unsent' == $mail->status ) ? ' fi' : '' );
 564  
 565                      $out .= '<td ' . $attributes . '>';
 566                      if ( 'paused' == $mail->status )
 567                      {
 568                          $out .= '<span class="mp_icon mp_icon_paused" title="' . esc_attr( __( 'Paused', 'MailPress' ) ) . '"></span>';
 569                      }
 570                      if ( $attach )
 571                      {
 572                          $out .= '<span class="mp_icon mp_icon_attachment" title="' . esc_attr( __( 'Attachments', 'MailPress' ) ) . '"></span>';
 573                      }
 574                      if ( ( 'draft' == $mail->status ) && ( $mp_mail->sent >= $mp_mail->created ) )
 575                      {
 576                          $out .= '<span class="mp_icon mp_icon_scheduled" title="' . esc_attr( __( 'Scheduled', 'MailPress' ) ) . '"></span>';
 577                      }
 578                      $out .= apply_filters( 'MailPress_get_icon_mails', '', $id );
 579  
 580                      $out .= '<strong>';
 581                      $out .= '<a class="' . $title_class . '" href="' . $title_link . '" title="' . esc_attr( $title_title ) . '">';
 582                      $out .= ( '' == $subject_display ) ? __( '(no subject)', 'MailPress' ) : ( ( strlen( $subject_display ) > 40 ) ? $subject_display = mb_substr( $subject_display, 0, 39, get_option( 'blog_charset' ) ) . '...' : $subject_display );
 583                      $out .= '</a>';
 584  
 585                      switch ( $mail->status ) 
 586                      {
 587                          case 'draft' :
 588                              $out .= ' - ' . __( 'Draft', 'MailPress' );
 589                          break;
 590                          case 'paused' :
 591                              $out .= ' - ' . __( 'Paused', 'MailPress' );
 592                          break;
 593                          case 'archived' :
 594                              $out .= ' - ' . __( 'Archive', 'MailPress' );
 595                          break;
 596                      }
 597                      $out .= '</strong>';
 598                      $out .= self::get_actions( $actions );
 599                      $out .= '</td>';
 600                  break;
 601                  case 'author':
 602                      $out .= '<td ' . $attributes . '>';
 603                      if ( $author != 0 && is_numeric( $author ) )
 604                      {
 605                          $out .= '<a href="' . $author_url . '" title="' . esc_attr( sprintf( __( 'Mails by &#8220;%1$s&#8221;', 'MailPress' ), $wp_user->display_name ) ) . '">' . $wp_user->display_name . '</a>';
 606                      }
 607                      else
 608                      {
 609                          $out .= __( '(unknown)', 'MailPress' );
 610                      }
 611                      $out .= '</td>';
 612                  break;
 613                  case 'theme':
 614                      $out .= '<td ' . $attributes . '>';
 615                      $out .= $mail->theme;
 616                      if ( '' != $mail->template )
 617                      {
 618                          $out .=  '<br />(' . $mail->template . ')';
 619                      }
 620                      $out .= '</td>';
 621                  break;
 622                  case 'to':
 623                      $out .= '<td ' . $attributes . '>';
 624                      $out .= $email_display;
 625                      $out .= '</td>';
 626                  break;
 627                  case 'date':
 628                      $date_status = ( 'draft' == $mail->status ) ? ( ( $mp_mail->sent >= $mp_mail->created ) ? true : __( 'Last Modified', 'MailPress' ) ) : __( 'Sent', 'MailPress' );
 629                      $_scheduled = false;
 630                      if ( true === $date_status )
 631                      {
 632                          $_scheduled = true;
 633                          $date_status= __( 'Scheduled', 'MailPress' );
 634                      }
 635  
 636                      $t_time = self::get_mail_date( __( 'Y/m/d H:i:s' ) );
 637                      $m_time = self::get_mail_date_raw();
 638  
 639                      $time   = strtotime( get_gmt_from_date( $m_time ) );
 640                      $time_diff = current_time( 'timestamp', true ) - $time;
 641  
 642                      if ( $_scheduled )
 643                      {
 644                          $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
 645                      }
 646                      else
 647                      {
 648                           $h_time = self::human_time_diff( self::get_mail_date_raw() );
 649                      }
 650  
 651                      $out .= '<td ' . $attributes . '>';
 652                      $out .= '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
 653                      $out .= '<br />';
 654                      $out .= $date_status;
 655                      $out .= '</td>';
 656                  break;
 657                  default:
 658                      $out .= '<td ' . $attributes . '>';
 659                      $out .= apply_filters( 'MailPress_mails_get_row', '', $column_name, $mail, $url_parms );
 660                      $out .= '</td>';
 661                  break;
 662              }
 663          }
 664          $out .= '</tr>';
 665  
 666          return $out;
 667      }
 668  
 669  	public static function get_mail_date( $d = '' ) {
 670          $x = self::get_mail_date_raw();
 671          return ( '' == $d ) ? mysql2date( get_option( 'date_format' ), $x ) : mysql2date( $d, $x );
 672      }
 673  
 674  	public static function get_mail_date_raw() {
 675          global $mp_mail;
 676          $x = ( $mp_mail->sent >= $mp_mail->created ) ? $mp_mail->sent : $mp_mail->created;
 677          return $x;
 678      }
 679  }


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