[ Index ]

MailPress 7.1

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

title

Body

[close]

/mp-content/add-ons/ -> MailPress_tracking.php (source)

   1  <?php
   2  if ( class_exists( 'MailPress' ) && !class_exists( 'MailPress_tracking' ) )
   3  {
   4  /*
   5  Plugin Name: MailPress_tracking
   6  Plugin URI: http://blog.mailpress.org/tutorials/add-ons/tracking/
   7  Description: Tracking : mails &amp; users activity
   8  Version: 7.1
   9  */
  10  
  11  /** for admin plugin pages */
  12  define ( 'MailPress_page_tracking_m', MailPress_page_mails . '&file=tracking' );
  13  define ( 'MailPress_page_tracking_u', MailPress_page_users . '&file=tracking' );
  14  
  15  /** for admin plugin urls */
  16  $mp_file = 'admin.php';
  17  define ( 'MailPress_tracking_m',    add_query_arg( 'page', MailPress_page_tracking_m,     $mp_file ) );
  18  define ( 'MailPress_tracking_u',    add_query_arg( 'page', MailPress_page_tracking_u,     $mp_file ) );
  19  
  20  /** for mysql */ 
  21  global $wpdb;
  22  $wpdb->mp_tracks = $wpdb->prefix . 'mailpress_tracks';
  23  
  24  define ( 'MailPress_tracking_openedmail',     '_MailPress_mail_opened' );
  25  
  26  class MailPress_tracking
  27  {
  28      const option_name = 'MailPress_tracking';
  29  
  30  	function __construct()
  31      {
  32  // for wordpress hooks
  33          add_action( 'init',                      array( __CLASS__, 'init' ), 100 );
  34  // for mails list
  35          add_filter( 'MailPress_mails_actions',     array( __CLASS__, 'mails_actions' ),  8, 3 );
  36  // for users list
  37          add_filter( 'MailPress_users_actions',     array( __CLASS__, 'users_actions' ),  8, 3 );
  38  //        add_filter( 'MailPress_bulk_actions_'   . MailPress_page_users,    array( __CLASS__, 'bulk_actions_mailpress_users' ), 8, 1 );
  39  //        add_action( 'MailPress_do_bulk_action_' . MailPress_page_users,    array( __CLASS__, 'do_bulk_action_mailpress_users' ), 8, 2 );
  40  // for referential integrity
  41          add_action( 'MailPress_delete_mail',      array( __CLASS__, 'delete_mail' ), 1, 1 );
  42  //        add_action( 'MailPress_delete_user',      array( __CLASS__, 'delete_user' ), 1, 1 );
  43          add_action( 'MailPress_unsubscribe_user',    array( __CLASS__, 'unsubscribe_user' ), 1, 1 );
  44  // prepare mail
  45          add_filter( 'MailPress_is_tracking',      array( __CLASS__, 'is_tracking' ), 1, 1 );
  46          add_filter( 'MailPress_header_url',        array( __CLASS__, 'header_url' ), 8, 2 );
  47          add_filter( 'MailPress_mail',            array( __CLASS__, 'mail' ), 8, 2 );
  48  // process link
  49          add_action( 'mp_tracking_process',        array( __CLASS__, 'process' ), 8, 1 );
  50                  
  51          if ( is_admin() )
  52          {
  53          // install
  54              register_activation_hook( plugin_basename( __FILE__ ),     array( __CLASS__, 'install' ) );
  55          // for link on plugin page
  56              add_filter( 'plugin_action_links',         array( __CLASS__, 'plugin_action_links' ), 10, 2 );
  57          // for role & capabilities
  58              add_filter( 'MailPress_capabilities',      array( __CLASS__, 'capabilities' ), 1, 1 );
  59          // for load admin page
  60              add_filter( 'MailPress_load_admin_page',     array( __CLASS__, 'load_admin_page' ), 10, 1 );
  61          // for settings
  62              add_filter( 'MailPress_settings_tab',     array( __CLASS__, 'settings_tab' ), 40, 1 );
  63          // for autorefresh
  64              add_filter( 'MailPress_autorefresh_js',    array( __CLASS__, 'autorefresh_js' ), 8, 1 );
  65          }
  66      }
  67  
  68  	public static function init()
  69      {
  70      // for mails list
  71          if ( current_user_can( 'MailPress_tracking_mails' ) )
  72          {
  73              add_filter( 'MailPress_mails_columns',         array( __CLASS__, 'mails_columns' ), 8, 1 );
  74              add_filter( 'MailPress_mails_get_row',          array( __CLASS__, 'mails_get_row' ), 1, 4 );
  75          }
  76      }
  77  
  78  // for mails list
  79  	public static function mails_actions( $actions, $mail, $url_parms )
  80      {
  81          if ( !current_user_can( 'MailPress_tracking_mails' ) )    return $actions;
  82          if ( 'draft' == $mail->status )                    return $actions;
  83  
  84      // url
  85          $args = array();
  86          $args['id']     = $mail->id;
  87  
  88          $tracking_url     = esc_url( MP_::url( MailPress_tracking_m, array_merge( $args, $url_parms ) ) );
  89  
  90      // actions
  91          $actions['tracking'] = '<a href="' . $tracking_url . '" title="' . esc_attr( __( 'See tracking results', 'MailPress' ) ) . '">' . __( 'Tracking', 'MailPress' ) . '</a>';
  92  
  93          return $actions;
  94      }
  95  
  96  // for users list
  97  	public static function users_actions( $actions, $user, $url_parms )
  98      {
  99          if ( !current_user_can( 'MailPress_tracking_users' ) )    return $actions;
 100  
 101      // url
 102          $args = array();
 103          $args['id']     = $user->id;
 104  
 105          $tracking_url     = esc_url( MP_::url( MailPress_tracking_u, array_merge( $args, $url_parms ) ) );
 106  
 107      // actions
 108          $actions['tracking'] = '<a href="' . $tracking_url . '" title="' . esc_attr( __( 'See tracking results', 'MailPress' ) ) . '">' . __( 'Tracking', 'MailPress' ) . '</a>';
 109  
 110          return $actions;
 111      }
 112  
 113  	public static function bulk_actions_mailpress_users( $bulk_actions )
 114      {
 115          $bulk_actions['geolocate'] = __( 're-Geolocate', 'MailPress' );
 116          return $bulk_actions;
 117      }
 118  
 119  	public static function do_bulk_action_mailpress_users( $action, $checked )
 120      {
 121          if ( 'bulk-geolocate' != $action ) return false;
 122          $count = 0;
 123          foreach( $checked as $id ) if ( self::set_ip( $id ) ) $count++;
 124          return $count;
 125      }
 126  
 127  	public static function set_ip( $id )
 128      {
 129          global $wpdb;
 130  
 131          $ip = $wpdb->get_var( $wpdb->prepare( "SELECT ip FROM $wpdb->mp_tracks WHERE user_id = %d AND ip <> '' ORDER BY tmstp DESC LIMIT 1;", $id ) );
 132          if ( !$ip ) return false;
 133  
 134          return MP_User::set_ip( $id, $ip );
 135      }
 136  
 137  // for referential integrity
 138  	public static function delete_mail( $mail_id )
 139      {
 140          global $wpdb;
 141          $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->mp_usermeta WHERE meta_key = '_MailPress_mail_sent' AND meta_value = %d ; ", $mail_id ) );
 142          $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->mp_tracks   WHERE mail_id = %d ; ", $mail_id ) );
 143      }
 144  
 145  	public static function delete_by_mail_id( $mail_id )
 146      {
 147          global $wpdb;
 148          $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->mp_tracks   WHERE mail_id = %d ; ", $mail_id ) );
 149      }
 150  
 151  	public static function delete_user( $mp_user_id )
 152      {
 153          //self::delete_by_user_id( $mp_user_id );
 154      }
 155  
 156  	public static function delete_by_user_id( $mp_user_id )
 157      {
 158          global $wpdb;
 159          $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->mp_tracks WHERE user_id = %d ; ", $mp_user_id ) );
 160      }
 161  
 162  	public static function unsubscribe_user( $mp_user_id )
 163      {
 164          if ( !$mp_user_id ) return;
 165  
 166          $data = $format         = array();
 167  
 168          $REMOTE_ADDR         = filter_input( INPUT_SERVER, 'REMOTE_ADDR' );
 169          $HTTP_USER_AGENT     = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' );
 170          $HTTP_REFERER         = filter_input( INPUT_SERVER, 'HTTP_REFERER' );
 171  
 172          $data['user_id']     = $mp_user_id;                                            $format[] = '%d';
 173          $data['mail_id']     = 0;                                                    $format[] = '%d';
 174          $data['mmeta_id']     = 0;                                                    $format[] = '%d';
 175          $data['track']         = '!!unsubscribed!!';                                        $format[] = '%s';
 176          $data['context']     = '?';                                                $format[] = '%s';
 177          $data['ip']         = trim( $REMOTE_ADDR  );                                    $format[] = '%s';
 178          $data['agent']         = trim( $HTTP_USER_AGENT  );                                $format[] = '%s';
 179          $data['referrer']    = ( isset( $HTTP_REFERER ) ) ? trim( $HTTP_REFERER ) : '';            $format[] = '%s';
 180          $data['tmstp']        = current_time( 'mysql' );                                    $format[] = '%s';
 181  
 182          global $wpdb;
 183          $wpdb->insert( $wpdb->mp_tracks, $data, $format );
 184      }
 185  
 186  // prepare mail
 187  	public static function is_tracking( $x )
 188      {
 189          return true;
 190      }
 191  
 192  	public static function header_url( $url, $mail )
 193      {
 194          $MP_Tracking_url = admin_url( 'admin-ajax.php' );
 195          $MP_Tracking_url_args = '?action=mp_tracking&tg=%1$s&mm=%2$s&co=%3$s&us={{_confkey}}';
 196  
 197          $meta_id = self::get_mmid( $mail->id, '_MailPress_mail_link', str_replace( '&amp;', '&', $url ) );
 198          $t_url = $MP_Tracking_url . sprintf( $MP_Tracking_url_args, 'l', $meta_id, 'h' );
 199          $t_url = apply_filters( 'MailPress_tracking_url', $t_url, $mail );
 200          return $t_url;
 201      }
 202  
 203  	public static function mail( $mail )
 204      {
 205          $MP_Tracking_url = admin_url( 'admin-ajax.php' );
 206          $MP_Tracking_url_args = '?action=mp_tracking&tg=%1$s&mm=%2$s&co=%3$s&us={{_confkey}}';
 207  
 208          foreach( $mail->recipients as $k => $v )
 209          {
 210              $toemail = ( MailPress::is_email( $k ) ) ? $k : $v;
 211              if ( isset( $mail->replacements[$toemail]['{{_confkey}}'] ) )
 212              {
 213                  MP_User_meta::add( MP_User::get_id_by_email( $toemail ), '_MailPress_mail_sent', $mail->id );
 214              }
 215          }
 216  
 217          $out = preg_match_all( '/<a [^>]*href=[\'"](.*?)[\'"]([^>]*)>/si', $mail->html, $matches, PREG_SET_ORDER );     /* was '/<a [^>]*href=[\'"]([^\'"]+)[\'"][^>]*>(.*?)<\/a>/is' */
 218  
 219          $hrefs_txt = array();
 220          if ( $matches )
 221          {
 222              foreach ( $matches as $match )
 223              {
 224                  if ( strpos( $match[1], 'mailto:' ) !== false ) continue;
 225                  if ( '#' == $match[1][1] ) continue;
 226                  if ( ( strpos( $match[1], get_home_url() ) === false ) && ( strpos( $match[1], '#' ) !== false ) ) continue;
 227  
 228                  $meta_id = self::get_mmid( $mail->id, '_MailPress_mail_link', str_replace( '&amp;', '&', $match[1] ) );
 229  
 230                  $t_url = $MP_Tracking_url . sprintf( $MP_Tracking_url_args, 'l', $meta_id, 'h' );
 231                  $t_url = apply_filters( 'MailPress_tracking_url', $t_url, $mail );
 232  
 233                  $link = self::str_replace_count( $match[1], $t_url, $match[0], 1 );
 234                  $mail->html = str_replace( $match[0], $link, $mail->html );
 235  
 236                  $t_url = 'ttrraacck_uurrll' . sprintf( $MP_Tracking_url_args, 'l', $meta_id, 'p' );
 237                  $t_url = apply_filters( 'MailPress_tracking_url', $t_url, $mail );
 238                  $hrefs_txt[$match[1]] = $t_url;
 239              }
 240          }
 241          $meta_id = self::get_mmid( $mail->id, MailPress_tracking_openedmail, MailPress_tracking_openedmail );
 242          $t_url = $MP_Tracking_url . sprintf( $MP_Tracking_url_args, 'o', $meta_id, 'h' );
 243          $t_url = apply_filters( 'MailPress_tracking_url', $t_url, $mail );
 244          $mail->html = str_ireplace( '</body>', "\n" . '<img src="' . $t_url . '" alt="" style="margin:0;padding:0;border:none;" /></body>', $mail->html );
 245  
 246          if ( !empty( $hrefs_txt ) )
 247          {
 248              uksort( $hrefs_txt, array( 'self', 'sort_hrefs_txt' ) );
 249              $hrefs_txt = array_reverse( $hrefs_txt );
 250              $t_url = apply_filters( 'MailPress_tracking_url', $MP_Tracking_url, $mail );
 251              $hrefs_txt['ttrraacck_uurrll'] = $t_url;
 252              $mail->plaintext = str_replace( array_keys( $hrefs_txt ), $hrefs_txt, $mail->plaintext );
 253          }
 254          return $mail;
 255      }
 256  
 257  	public static function sort_hrefs_txt( $a, $b ) 
 258      {
 259          return strcmp( strlen( $a ), strlen( $b ) );
 260      }
 261  
 262  	public static function str_replace_count( $search, $replace, $subject, $times=1 ) 
 263      {
 264          $subject_original=$subject;
 265  
 266          $len=strlen( $search );
 267          $pos=0;
 268          for ( $i=1;$i<=$times;$i++ ) 
 269          {
 270              $pos=strpos( $subject, $search, $pos );
 271              if( $pos!==false ) 
 272              {
 273                  $subject=substr( $subject_original, 0, $pos );
 274                  $subject.=$replace;
 275                  $subject.=substr( $subject_original, $pos+$len );
 276                  $subject_original=$subject;
 277              }
 278              else
 279              {
 280                  break;
 281              }
 282          }
 283          return( $subject );
 284      }
 285  
 286  	public static function get_mmid( $mail_id, $meta_key, $meta_value )
 287      {
 288          global $wpdb;
 289          $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->mp_mailmeta WHERE mp_mail_id = %d AND meta_key = %s AND meta_value = %s ;", $mail_id, $meta_key, $meta_value ) );
 290          if ( $meta_id ) return $meta_id;
 291          return MP_Mail_meta::add( $mail_id, $meta_key, $meta_value );
 292      }
 293  
 294  // process link
 295  
 296  	public static function process( $meta )
 297      {
 298          switch ( filter_input( INPUT_GET, 'tg' ) )
 299          {
 300              case ( 'l' ) :
 301                  self::save( $meta );
 302              break;
 303              case ( 'o' ) :
 304                  self::save( $meta );
 305              break;
 306              default :
 307                  $meta->meta_value = '404';
 308                  self::save( $meta );
 309              break;
 310          }
 311      }
 312  
 313  	public static function save( $meta )
 314      {
 315           if ( MailPress::is_bot() ) return;
 316  
 317          global $wpdb;
 318  
 319          $mp_user_id = MP_User::get_id( filter_input( INPUT_GET, 'us' ) );
 320  
 321          if ( !$mp_user_id ) return;
 322          if ( 0 == $mp_user_id ) return;
 323  
 324          $open_meta_id     = ( MailPress_tracking_openedmail == $meta->meta_value ) ? $meta->meta_id : self::get_mmid( $meta->mp_mail_id, MailPress_tracking_openedmail, MailPress_tracking_openedmail );
 325          $opened_mail    = $wpdb->get_var( $wpdb->prepare( "SELECT count( * ) FROM $wpdb->mp_tracks WHERE user_id = %d AND mail_id = %d AND mmeta_id = %d ;", $mp_user_id, $meta->mp_mail_id, $open_meta_id ) );
 326          if ( ( MailPress_tracking_openedmail == $meta->meta_value ) && ( $opened_mail ) ) return;
 327  
 328          $data = $format     = array();
 329  
 330          $REMOTE_ADDR         = filter_input( INPUT_SERVER, 'REMOTE_ADDR' );
 331          $HTTP_USER_AGENT     = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' );
 332          $HTTP_REFERER         = filter_input( INPUT_SERVER, 'HTTP_REFERER' );
 333  
 334          $data['user_id']     = $mp_user_id;                                                        $format[] = '%d';
 335          $data['mail_id']     = $meta->mp_mail_id;                                                    $format[] = '%d';
 336          $data['mmeta_id']     = $meta->meta_id;                                                    $format[] = '%d';
 337          $data['track']         = $wpdb->_real_escape( $meta->meta_value );                                $format[] = '%s';
 338          $data['context']     = ( 'h' == filter_input( INPUT_GET, 'co' ) ) ? 'html' : 'plaintext';                $format[] = '%s';
 339          $data['ip']         = $wpdb->_real_escape( trim( $REMOTE_ADDR ) );                                $format[] = '%s';
 340          $data['agent']         = $wpdb->_real_escape( trim( $HTTP_USER_AGENT ) );                            $format[] = '%s';
 341          $data['referrer']    = ( isset( $HTTP_REFERER ) ) ? $wpdb->_real_escape( trim( $HTTP_REFERER ) ) : '';    $format[] = '%s';
 342          $data['tmstp']        = current_time( 'mysql' );                                                $format[] = '%s';
 343  
 344          $wpdb->insert( $wpdb->mp_tracks, $data, $format );
 345  
 346          if ( MailPress_tracking_openedmail == $meta->meta_value ) $opened_mail = true;
 347          if ( $opened_mail ) return;
 348  
 349          $data['mmeta_id']     = $open_meta_id;
 350          $data['track']         = MailPress_tracking_openedmail;
 351  
 352          $wpdb->insert( $wpdb->mp_tracks, $data, $format );
 353      }
 354  
 355  ////  ADMIN  ////
 356  ////  ADMIN  ////
 357  ////  ADMIN  ////
 358  ////  ADMIN  ////
 359  
 360  // install
 361  	public static function install() 
 362      {
 363          include  ( MP_ABSPATH . 'mp-admin/includes/install/tracking.php' );
 364      }
 365      
 366  // for link on plugin page
 367  	public static function plugin_action_links( $links, $file )
 368      {
 369          return MailPress::plugin_links( $links, $file, plugin_basename( __FILE__ ), 'tracking' );
 370      }
 371  
 372  // for role & capabilities
 373  	public static function capabilities( $capabilities ) 
 374      {
 375          $capabilities['MailPress_tracking_mails'] = array(     'name'      => __( 'View tracking', 'MailPress' ), 
 376                                                  'group'     => 'mails'
 377                                               );
 378          $capabilities['MailPress_tracking_users'] = array(     'name'      => __( 'View tracking', 'MailPress' ), 
 379                                                  'group'     => 'users'
 380                                               );
 381          return $capabilities;
 382      }
 383  
 384  // for load admin page //
 385  	public static function load_admin_page( $hub )
 386      {
 387          $hub[MailPress_page_tracking_m] = 'tracking_m';
 388          $hub[MailPress_page_tracking_u] = 'tracking_u';
 389          return $hub;
 390      }
 391  
 392  // for settings
 393  	public static function settings_tab( $tabs )
 394      {
 395          $tabs['tracking'] = __( 'Tracking', 'MailPress' );
 396          return $tabs;
 397      }
 398  
 399  // for autorefresh
 400  	public static function autorefresh_js( $scripts )
 401      {
 402          return MP_WP_AutoRefresh_js::getInstance( $scripts );
 403      }
 404  
 405  // for mails list
 406  	public static function mails_columns( $x )
 407      {
 408          $date = array_pop( $x );
 409          $x['tracking_openrate']    =  __( 'Open rate', 'MailPress' );
 410          $x['tracking_clicks']    =  __( 'Clicks', 'MailPress' );
 411          $x['tracking_unsubscribe']    =  __( 'Unsubscribed', 'MailPress' );
 412          $x['date']        = $date;
 413          return $x;
 414      }
 415  
 416  	public static function mails_get_row( $out, $column_name, $mail, $url_parms )
 417      {
 418          global $wpdb;
 419          switch ( $column_name )
 420          {
 421              case 'tracking_openrate' :
 422                  if ( MailPress::is_email( $mail->toemail ) ) $total = 1;
 423                  elseif ( is_serialized( $mail->toemail ) ) $total = count( unserialize( $mail->toemail ) );
 424                  else break;
 425  
 426                  $result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT user_id FROM $wpdb->mp_tracks WHERE mail_id = %d AND track = %s ;", $mail->id, MailPress_tracking_openedmail ) );
 427                  if ( $result ) if ( $total > 0 ) $out .= sprintf( "%01.2f %%", 100 * count( $result )/$total );
 428              break;
 429              case 'tracking_clicks' :
 430                  $exclude = array( MailPress_tracking_openedmail, '!!unsubscribed!!', '{{unsubscribe}}' );
 431  
 432                  $result = $wpdb->get_var( $wpdb->prepare( "SELECT count( * ) FROM $wpdb->mp_tracks WHERE mail_id = %d AND track NOT IN ( '" . join( "','", $exclude ) . "' ) ;", $mail->id ) );
 433                  if ( $result ) $out .= '<div class="num post-com-count-wrapper"><a class="post-com-count"><span class="comment-count">' . $result . '</span></a></div>';
 434              break;
 435              case 'tracking_unsubscribe' :
 436                  $exclude = array( '{{unsubscribe}}' );
 437  
 438                  $r  = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS DISTINCT user_id FROM $wpdb->mp_tracks WHERE mail_id = %d AND track = %s ;", $mail->id, '!!unsubscribed!!' ) );
 439                  $ud = $wpdb->get_var( "SELECT FOUND_ROWS()" );
 440  
 441                  $u  = $wpdb->get_var( $wpdb->prepare( "SELECT count( * ) FROM $wpdb->mp_tracks WHERE mail_id = %d AND track IN ( '" . join( "','", $exclude ) .  "' ) ;", $mail->id ) );
 442                  $title = ( !$u ) ? '' : esc_attr( sprintf( _n( __( '%d click on unsubscribe link',  'MailPress' ), __( '%d clicks on unsubscribe link',  'MailPress' ), $u ), $u ) );
 443  
 444                  $r = $ud;
 445                  if ( !$r ) break;
 446                  $out .= '<a class="post-com-count"><span class="comment-count"><abbr title="' . $title . '">' . $r . '</abbr></span></a>';
 447              break;
 448          }
 449          return $out;
 450      }
 451  
 452  // for reports
 453  
 454  	public static function translate_track( $track, $mail_id, $strlen = 20 )
 455      {
 456          switch ( $track )
 457          {
 458              case '{{subscribe}}' :
 459                  return __( 'subscribe', 'MailPress' );
 460              break;
 461              case '{{unsubscribe}}' :
 462                  return __( 'manage subscriptions', 'MailPress' );
 463              break;
 464              case '{{viewhtml}}' :
 465                  return __( 'view html', 'MailPress' );
 466              break;
 467              case MailPress_tracking_openedmail :
 468                  return __( 'mail opened', 'MailPress' );
 469              break;
 470              case '!!unsubscribed!!' :
 471                  return __( '<b>unsubscribed</b>', 'MailPress' );
 472              break;
 473              default :
 474                  $confkey = '#$&$#';
 475                  $url = MP_User::get_subscribe_url( $confkey );
 476                  $url = str_replace( $confkey, '', $url );
 477                  if ( stripos( $track, $url ) !== false ) {return __( 'subscribe', 'MailPress' );}
 478                  $url = MP_User::get_unsubscribe_url( $confkey );
 479                  $url = str_replace( $confkey, '', $url );
 480                  if ( stripos( $track, $url ) !== false ) {return __( 'unsubscribe', 'MailPress' );}
 481                  $url = MP_User::get_view_url( $confkey, $mail_id );
 482                  $url = str_replace( "{$confkey}&id={$mail_id}", '', $url );
 483                  if ( stripos( $track, $url ) !== false ) {return __( 'view html', 'MailPress' );}
 484              break;
 485          }
 486          global $wpdb;
 487          $title = $wpdb->get_var( "SELECT post_title FROM $wpdb->posts WHERE guid = '$track';" );
 488          $title = $display_title = ( $title ) ? $title : $track;
 489          $display_title = ( substr( $display_title, 0, 7 ) == 'http://' ) ? substr( $display_title, 7 ) : $display_title;
 490          $display_title = ( substr( $display_title, 0, 8 ) == 'https://' ) ? substr( $display_title, 8 ) : $display_title;
 491          $display_title = ( strlen( $display_title ) > $strlen ) ? substr( $display_title, 0, $strlen - 2 ) . '...' : $display_title;
 492          return '<a href="' . $track . '" title="' . esc_attr( $title ) . '" target="_blank">' . $display_title . '</a>';
 493      }
 494  }
 495  new MailPress_tracking();
 496  }


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