[ Index ]

MailPress 7.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  
  35              $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 ) );
  36  
  37              if ( $opened )
  38              {
  39                  if ( isset( $x[$key]['opened'] ) )     $x[$key]['opened']++;
  40                  else                         $x[$key]['opened'] = 1;
  41              }
  42          }
  43  
  44          if ( isset( $x[''] ) ) { $w = $x['']; unset( $x[''] ); } else unset( $w );
  45          uasort( $x, array( 'self', 'sort_domains' ) );
  46          if ( isset( $w ) ) $x[''] = $w;
  47  
  48          $out  = '<table id ="tracking_mp_011">';
  49          $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>';
  50          foreach( $x as $k => $v )
  51          {
  52              $k = ( empty( $k ) ) ? __( 'others', 'MailPress' ) : $k;
  53              $out .= '<tr>';
  54  //            $out .= ( isset( $v['img'] ) ) ? '<td><img class="' . $v['class']  . '" src="' . $v['img'] . '" alt="" /> ' . $k . ' </td>' : "<td> $k </td>";
  55              $out .= ( isset( $v['img'] ) ) ? '<td><div class="' . $v['class']  . '"></div> ' . $k . ' </td>' : "<td> $k </td>";
  56              $out .= '<td class="num">' . $v['count'] . '</td>';
  57              $out .= '<td class="num">' . sprintf( "%01.2f %%",100 * $v['count']/$total ) . '</td>';
  58              $out .= ( isset( $v['opened'] ) ) ? '<td class="num">' . sprintf( "%01.2f %%",100 * $v['opened']/$v['count'] ) . '</td>' : '<td></td>';
  59              $out .= '</tr>';
  60          }
  61          $out .= '</table>';
  62  
  63          echo $out;
  64      }
  65  
  66  	public static function sort_domains( $a, $b ) 
  67      {
  68          return $b['count'] - $a['count'];
  69      }
  70  }
  71  new MP_Tracking_metabox_m011( __( 'Domain recipients', 'MailPress' ) );


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