[ Index ]

MailPress 7.0.1

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

title

Body

[close]

/mp-includes/class/options/tracking/metaboxes/mail/ -> m011.php (source)

   1  <?php
   2  class MP_Tracking_metabox_m011 extends MP_tracking_metabox_
   3  {
   4      var $id    = 'm011';
   5      var $context= 'normal';
   6      var $file     = __FILE__;
   7  
   8  	function __construct( $title )
   9      {
  10          if ( !class_exists( 'MP_Tracking_recipients', false ) ) new MP_Tracking_recipients();
  11          parent::__construct( $title );
  12      }
  13  
  14  	function meta_box( $mail )
  15      {
  16          global $wpdb;
  17  
  18          if ( MailPress::is_email( $mail->toemail ) ) $m[$mail->toemail] = array( '{{_user_id}}' => MP_User::get_id_by_email( $mail->toemail ) );
  19          else $m = unserialize( $mail->toemail );
  20          unset( $m['MP_Mail'] );
  21          $total = count( $m );
  22  
  23          foreach( $m as $email => $v )
  24          {
  25              $ug = apply_filters( 'MailPress_tracking_recipients_domain_get', $email );
  26              $key = $ug->name;
  27              if ( isset( $x[$key]['count'] ) )     $x[$key]['count']++;
  28              else                         $x[$key]['count'] = 1;
  29              if ( isset( $ug->icon_path ) && !isset( $x[$key]['img'] ) )
  30              {
  31                  $x[$key]['img'] = $ug->icon_path;
  32                  $x[$key]['class'] = $ug->classes;
  33              }
  34              $opened = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->mp_tracks WHERE mail_id = %d AND user_id = %d AND track = %s ;", $mail->id, $v['{{_user_id}}'], MailPress_tracking_openedmail ) );
  35              if ( $opened )
  36              {
  37                  if ( isset( $x[$key]['opened'] ) )     $x[$key]['opened']++;
  38                  else                         $x[$key]['opened'] = 1;
  39              }
  40          }
  41  
  42          if ( isset( $x[''] ) ) { $w = $x['']; unset( $x[''] ); } else unset( $w );
  43          uasort( $x, array( 'self', 'sort_domains' ) );
  44          if ( isset( $w ) ) $x[''] = $w;
  45  
  46          $out  = '<table id ="tracking_mp_011">';
  47          $out .= '<tr><th>' . __( 'domain', 'MailPress' ) . '</th><th class="num">' . __( 'count', 'MailPress' ) . '</th><th class="num">' . __( '%', 'MailPress' ) . '</th><th class="num">' . __( 'open rate', 'MailPress' ) . '</th></tr>';
  48          foreach( $x as $k => $v )
  49          {
  50              $k = ( empty( $k ) ) ? __( 'others', 'MailPress' ) : $k;
  51              $out .= '<tr>';
  52  //            $out .= ( isset( $v['img'] ) ) ? '<td><img class="' . $v['class']  . '" src="' . $v['img'] . '" alt="" /> ' . $k . ' </td>' : "<td> $k </td>";
  53              $out .= ( isset( $v['img'] ) ) ? '<td><div class="' . $v['class']  . '"></div> ' . $k . ' </td>' : "<td> $k </td>";
  54              $out .= '<td class="num">' . $v['count'] . '</td>';
  55              $out .= '<td class="num">' . sprintf( "%01.2f %%",100 * $v['count']/$total ) . '</td>';
  56              $out .= ( isset( $v['opened'] ) ) ? '<td class="num">' . sprintf( "%01.2f %%",100 * $v['opened']/$v['count'] ) . '</td>' : '<td></td>';
  57              $out .= '</tr>';
  58          }
  59          $out .= '</table>';
  60  
  61          echo $out;
  62      }
  63  
  64  	public static function sort_domains( $a, $b ) 
  65      {
  66          return $b['count'] - $a['count'];
  67      }
  68  }
  69  new MP_Tracking_metabox_m011( __( 'Domain recipients', 'MailPress' ) );


Generated: Mon Jan 28 00:07:10 2019 Cross-referenced by PHPXref 0.7.1