[ Index ]

MailPress 7.1

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

title

Body

[close]

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

   1  <?php
   2  class MP_Mail extends MP_mail_
   3  {
   4      private $_debug = null;
   5  
   6      const object_type = 'mail';
   7  
   8      const status_deleted = 'deleted';
   9  
  10      const name_required = true;
  11      const get8BitEncoding = true; // setting this to false can have an impact on perf see http://forums.devnetwork.net/viewtopic.php?f=52&t=96933
  12  
  13  	function __construct( $plug = MP_FOLDER )
  14      {
  15          if ( !isset( $this->_debug ) ) $this->_debug = ( defined( 'MP_DEBUG_LOG' ) );
  16  
  17          $this->plug = $plug;
  18  
  19          $this->theme = new MP_Themes();
  20  
  21          $this->message     = null;
  22  
  23          $this->args = new stdClass();
  24      }
  25  
  26  ////    MP_Mail send functions    ////
  27  
  28  	function send( $args )
  29      {
  30          if ( is_numeric( $args ) )
  31          {
  32              $this->args = MP_Mail::get( $args );
  33          }
  34          else
  35          {
  36              $this->args = $args ;
  37          }
  38          return $this->end( $this->start() );
  39      }
  40  
  41  	function start()
  42      {
  43          MP_::no_abort_limit();
  44  
  45          $this->row  = new stdClass();
  46          $this->mail = new stdClass();
  47  
  48          global $mp_general;
  49          $mp_general = get_option( MailPress::option_name_general );
  50  
  51  ////  Log it  ////
  52  
  53          $this->trace = new MP_Log( 'mp_mail', array( 'force' => ( isset( $this->args->forcelog ) ) ) );
  54  
  55          if ( !$this->args )    
  56          {
  57              $this->trace->log( 'MAILPRESS [ERROR] - Sorry invalid arguments in MP_Mail::send' );
  58              return false;
  59          }
  60  
  61  ////  Build it  ////
  62  
  63          if ( !isset( $this->args->id ) )
  64          {
  65              $this->row->id = $this->args->id = MP_Mail::get_id( 'MP_Mail::start' );
  66          }
  67          else
  68          {
  69              $this->row->id = $this->args->id;
  70          }
  71  
  72      // charset //
  73          $this->row->charset = ( isset( $this->args->charset ) ) ? $this->args->charset : get_option( 'blog_charset' );
  74  
  75      // fromemail & fromname //
  76          $this->row->fromemail    = ( empty( $this->args->fromemail ) ) ? $mp_general['fromemail'] : $this->args->fromemail;
  77          $this->row->fromname     = ( empty( $this->args->fromname ) )  ? $mp_general['fromname']  : $this->args->fromname;
  78          $this->row->fromname     = ( empty( $this->row->fromname ) )   ? self::display_name( $mp_general['fromemail'] ) : $this->row->fromname;
  79  
  80      // recipients & replacements //
  81          self::get_mail_replacements();
  82  
  83          $this->mail->recipients_count = $this->manage_recipients();
  84          if ( !$this->mail->recipients_count )
  85          {
  86              $this->trace->log( ( 0 === $this->mail->recipients_count ) ? 'MAILPRESS [ERROR] - No recipient' : 'MAILPRESS [ERROR] - problems with recipients & replacements' );
  87              return $this->mail->recipients_count;
  88          }
  89  
  90      // subject //
  91          $this->row->subject     = ( isset( $this->args->subject ) ) ? $this->args->subject : false;
  92          if ( isset( $this->args->Template ) ) 
  93          {
  94              $theme = ( isset( $this->args->Theme ) ) ? $this->args->Theme : $this->theme->themes[$this->theme->current_theme]['Stylesheet'];
  95              if ( !$pt = $this->theme->get_page_templates( $theme ) ) $pt = $this->theme->get_page_templates( $theme, true );
  96              if ( isset( $pt[$this->args->Template]['subject'] ) ) $this->row->subject = $pt[$this->args->Template]['subject'];
  97          }
  98          $this->row->subject     = ( $this->row->subject ) ? trim( $this->html_entity_decode( $this->do_eval( $this->row->subject ) ) ) : '';
  99  
 100      // html //
 101          $this->row->html        = $this->build_mail_content( 'html', 'the_content' );
 102  
 103      // plaintext //
 104          $this->row->plaintext     = $this->build_mail_content( 'plaintext' );
 105  
 106      // attachments //
 107          $this->mail->attachments = false;
 108          if ( isset( $this->args->main_id ) )
 109          {
 110              $metas = MP_Mail_meta::has( $this->args->main_id, '_MailPress_attached_file' );
 111              if ( $metas )
 112              {
 113                  foreach( $metas as $meta )
 114                  {
 115                      $meta_value = unserialize( $meta['meta_value'] );
 116                      if ( !is_file( $meta_value['file_fullpath'] ) ) continue;
 117                      $this->mail->attachments = true;
 118                      MP_Mail_meta::add( $this->row->id, '_MailPress_attached_file', $meta_value );
 119                  }
 120              }
 121          }
 122  
 123          unset( $this->theme );
 124  
 125      // mail empty ? //
 126          if ( !$this->row->subject && !$this->row->plaintext && !$this->row->html && !$this->mail->attachments )
 127          {
 128              $this->trace->log( __( 'MAILPRESS [WARNING] - Mail is empty', 'MailPress' ) );
 129              return false;
 130          }
 131  
 132          $this->row->theme    = $this->mail->theme;
 133          $this->row->themedir    = $this->mail->themedir;
 134          $this->row->template     = $this->mail->template;
 135  
 136      // no tracking on unknown recipient ! //
 137          if ( !isset( $this->mail->external_recipient ) )
 138          {
 139              $this->row = apply_filters( 'MailPress_mail', $this->row );
 140              $this->replace_mail_urls();
 141          }
 142  
 143      // only one recipient //
 144          if ( 1 == $this->mail->recipients_count )
 145          {
 146              $toname = '';
 147              if ( isset( $this->row->recipients[0] ) ) $toemail = $this->row->recipients[0]; else foreach( $this->row->recipients as $toemail => $toname ) {};
 148              $this->row->toemail = $toemail;
 149              $this->row->toname  = $toname;
 150  
 151              $this->row->replacements[$toemail] = array_merge( $this->row->replacements[$toemail] ?? array(), $this->mail->replacements );
 152  
 153              foreach( $this->row->replacements[$toemail] as $k => $v ) 
 154              {
 155                  $this->row->subject     = str_replace( $k, $v, $this->row->subject, $cs );
 156                  $this->row->plaintext    = str_replace( $k, $v, $this->row->plaintext, $cp );
 157                  $this->row->html     = str_replace( $k, $v, $this->row->html, $ch );
 158              }
 159  
 160              if ( isset( $this->row->replacements[$toemail]['{{_user_id}}'] ) ) $this->row->mp_user_id = $this->row->replacements[$toemail]['{{_user_id}}'];
 161              MP_Mail_meta::delete_by_id( $this->mail->mmid );
 162              unset( $this->row->replacements, $this->row->recipients, $this->mail->replacements, $this->mail->mmid );
 163          }
 164  
 165  /*trace*/    $x  = " \n\n ------------------- start of mail -------------------  ";
 166  /*trace*/    $x .= " \n From : " . $this->row->fromname  . " <" . $this->row->fromemail . "> ";
 167  /*trace*/    if ( isset( $this->row->toemail ) )
 168  /*trace*/        if ( !empty( $this->row->toname ) )
 169  /*trace*/    $x .= " \n To   : " . $this->row->toname . " <" . $this->row->toemail . "> ";
 170  /*trace*/        else
 171  /*trace*/    $x .= " \n To   : " . $this->row->toemail;
 172  /*trace*/    $x .= " \n Subject : " . $this->row->subject;
 173  /*trace*/    if ( $this->row->plaintext )     $x .= " \n   ------------------- plaintext -------------------  \n " . $this->row->plaintext;
 174  /*trace*/    if ( $this->row->html )         $x .= " \n\n ------------------- text/html -------------------  \n " . $this->row->html;
 175  /*trace*/    $x .= " \n\n ------------------ end of mail ------------------  \n\n";
 176  /*trace*/    $this->trace->log( $x, $this->trace->levels[512] );
 177  
 178          $this->mail->swift_batchSend         = ( 1 < $this->mail->recipients_count );
 179          $this->mail->mailpress_batch_send    = ( $this->mail->swift_batchSend ) ? class_exists( 'MailPress_batch_send' ) : false;
 180          $this->mail->mailpress_batch_spool_send = ( $this->mail->swift_batchSend ) ? class_exists( 'MailPress_batch_spool_send' ) : false;
 181  
 182  ////  Send it  ////
 183  
 184      // no mail ? //
 185          if ( isset( $this->args->nomail ) )
 186          {
 187              $this->trace->log( 'MAILPRESS [NOTICE] - :::: Mail not sent as required ::::' );
 188          }
 189          elseif ( $this->mail->mailpress_batch_send )
 190          {
 191              $this->trace->log( 'MAILPRESS [NOTICE] - :::: Mail batch processing as required ::::' );
 192              do_action( 'MailPress_schedule_batch_send' );
 193          }
 194          else
 195          {
 196              if ( !$this->swift_processing() )
 197              {
 198                  $this->trace->log( '' );
 199                  $this->trace->log( 'MAILPRESS [ERROR] - *** Mail could not be sent ***' );
 200                  $this->trace->log( '' );
 201                  unset( $this->message, $this->swift ); 
 202                  return false;
 203              }
 204          }
 205  
 206          unset( $this->message, $this->swift ); 
 207  
 208  ////  Archive it  ////
 209  
 210          if ( isset( $this->args->noarchive ) )
 211          {
 212              $this->trace->log( 'MAILPRESS [NOTICE] - :::: Mail not saved as required ::::' );
 213              MP_Mail::delete( $this->row->id );
 214          }
 215          else
 216          { 
 217              global $wpdb;
 218  
 219              if ( !isset( $this->args->nostats ) ) new MP_Stat( 't', isset( $this->args->Template ) ? $this->args->Template : '', $this->mail->recipients_count );
 220  
 221              $now        = current_time( 'mysql' );
 222              $user_id     = ( empty( $this->args->wp_user_id ) ) ?  MP_WP_User::get_id() : $this->args->wp_user_id;
 223  
 224              if ( $this->mail->swift_batchSend ) 
 225              {
 226                  foreach ( $this->row->replacements as $email => $r )
 227                  {
 228                      if ( isset( $this->row->recipients[$email] ) )
 229                          $this->row->toemail[$email] = $this->row->replacements[$email];
 230                      unset( $this->row->recipients[$email], $this->row->replacements[$email] );
 231                  }
 232                  foreach ( $this->row->recipients as $k => $email )
 233                  {
 234                      $this->row->toemail[$email] = $this->row->replacements[$email];
 235                      unset( $this->row->recipients[$k], $this->row->replacements[$email] );
 236                  }
 237                  unset( $this->row->recipients, $this->row->replacements );
 238                  $this->row->toemail = serialize( $this->row->toemail );
 239              }
 240  
 241      // status //
 242              $this->row->status = ( $this->mail->swift_batchSend ) ? ( apply_filters( 'MailPress_status_mail', 'sent' ) ) : 'sent';
 243              if ( !isset( $this->row->toname ) ) $this->row->toname = '';
 244  
 245              wp_cache_delete( $this->row->id, 'mp_mail' );
 246  
 247              $data = $format = $where = $where_format = array();
 248  
 249              $data['status']         = $this->row->status;     $format[] = '%s';
 250              $data['theme']         = $this->row->theme;     $format[] = '%s';
 251              $data['themedir']     = $this->row->themedir; $format[] = '%s';
 252              $data['template']     = $this->row->template; $format[] = '%s';
 253              $data['fromemail']     = $this->row->fromemail;$format[] = '%s';
 254              $data['fromname']     = $this->row->fromname;    $format[] = '%s';
 255              $data['toemail']         = $this->row->toemail;     $format[] = '%s';
 256              $data['toname']         = $this->row->toname;     $format[] = '%s';
 257              $data['charset']         = $this->row->charset;     $format[] = '%s';
 258              $data['subject']         = $this->row->subject;    $format[] = '%s';
 259              $data['html']         = $this->row->html;     $format[] = '%s';
 260              $data['plaintext']     = $this->row->plaintext;$format[] = '%s';
 261              $data['created']         = $now;             $format[] = '%s';
 262              $data['created_user_id']= $user_id;         $format[] = '%d';
 263              $data['sent']         = $now;             $format[] = '%s';
 264              $data['sent_user_id']     = $user_id;         $format[] = '%d';
 265  
 266              $where['id']         = ( int ) $this->row->id;        $where_format[] = '%d';
 267  
 268              if ( !$wpdb->update( $wpdb->mp_mails, $data, $where, $format, $where_format ) )
 269              {
 270                  $this->trace->log( sprintf( 'MAILPRESS [ERROR] - *** Database error, Mail not saved : %1$s '."\n".'%2$s', $wpdb->last_error, $wpdb->last_query ) );
 271                  return false;
 272              }
 273              $this->trace->log( 'MAILPRESS [NOTICE] - :::: MAIL SAVED ::::' );
 274          }
 275  
 276          return $this->mail->recipients_count;
 277      }
 278  
 279  	function end( $rc )
 280      {
 281          $this->trace->end( $rc );
 282          return $rc;
 283      }
 284  
 285  
 286  ////  Build it  ////
 287  
 288  
 289   // mail replacements //
 290  
 291  	function get_mail_replacements()
 292      {
 293          $mail_replacements = $this->convert_all( $this->args );
 294          $unsets = array( '{{subject}}', '{{content}}', '{{html}}', '{{plaintext}}', '{{id}}', '{{main_id}}', '{{recipients_query}}', '{{draft}}', '{{advanced}}' );
 295          foreach ( $unsets as $unset ) unset( $mail_replacements[$unset] );
 296  
 297          $mail_main_id = ( !isset( $this->args->main_id ) ) ? 0 : $this->args->main_id;
 298          $_mail_id = ( $mail_main_id ) ? $mail_main_id : $this->row->id;
 299          $m = MP_Mail_meta::get_replacements( $_mail_id );
 300          if ( !is_array( $m ) ) $m = array();
 301  
 302          $this->mail->replacements = array_merge( $m, $mail_replacements );
 303  
 304          $this->mail->mmid = MP_Mail_meta::add( $this->row->id, '_MailPress_replacements', $this->mail->replacements );
 305      }
 306  
 307  	function convert_all( $x = '', $sepb = '{{', $sepa = '}}', $before = '', $first = 0, $array = array() )
 308      {
 309          if ( is_object( $x ) ) $x = get_object_vars( $x );
 310          if ( empty( $x ) ) return array();
 311          foreach( $x as $key => $value )
 312          {
 313              if ( !( is_object( $value ) || is_array( $value ) ) )
 314              {
 315                  $x = ( 0 == $first ) ? $key : $before . '[' . $key . ']'; 
 316                  $array[$sepb . $x . $sepa] = $this->html_entity_decode( $value );
 317              }
 318              else 
 319              {
 320                  $abefore= ( !$first ) ? $key : $before . '[' . $key . ']'; 
 321                  $array = array_merge( $array, $this->convert_all( $value , $sepb , $sepa , $abefore , $first + 1 ) );
 322              }
 323          }
 324          return $array;
 325      }
 326  
 327   // recipients & replacements //
 328  
 329  	function manage_recipients()
 330      {
 331          if ( isset( $this->args->replacements ) )
 332          {
 333              if ( isset( $this->args->recipients ) )
 334              {
 335                  $this->row->replacements = $this->args->replacements;
 336                  $this->row->recipients   = $this->args->recipients;
 337                  return count( $this->row->recipients );
 338              }
 339              else
 340              {
 341                  $this->get_old_recipients();
 342                  return count( $this->row->recipients );
 343              }
 344          }
 345  
 346          $is_email = MailPress::is_email( $this->args->toemail );
 347  
 348          if ( !isset( $this->args->recipients_query ) )
 349          {
 350              if ( $is_email )
 351              {
 352                  $mp_user_id = MP_User::get_id_by_email( $this->args->toemail );
 353                  if ( $mp_user_id )
 354                  {
 355                      global $wpdb;
 356                      $this->args->recipients_query = "SELECT DISTINCT id, email, name, status, confkey FROM $wpdb->mp_users WHERE id = $mp_user_id ;";
 357                  }
 358              }
 359          }
 360  
 361          if ( isset( $this->args->recipients_query ) )
 362          {
 363              $this->get_recipients( $this->args->recipients_query );
 364  
 365              $this->args->viewhtml = MP_User::get_view_url( '{{_confkey}}', $this->row->id );
 366              if ( isset( $this->args->subscribe ) )     $this->args->subscribe   = MP_User::get_subscribe_url( '{{_confkey}}' );
 367              else                        $this->args->unsubscribe = MP_User::get_unsubscribe_url( '{{_confkey}}' );
 368  
 369              return count( $this->row->recipients );
 370          }
 371  
 372          if ( $is_email )
 373          {
 374              $this->mail->external_recipient = true;
 375              $this->get_external_recipient();
 376              return 1;
 377          }
 378  
 379          return false;
 380      }
 381  
 382  	function get_recipients( $query )
 383      {
 384          global $wpdb;
 385          $mp_users = $wpdb->get_results( $query );
 386  
 387          $this->row->recipients = array();
 388          if ( $mp_users )
 389          {
 390              foreach ( $mp_users as $mp_user )
 391              {
 392                  if ( !MailPress::is_email( $mp_user->email ) )
 393                  {
 394                      $this->trace->log( 'MAILPRESS [WARNING] - :::: this recipient ' . $mp_user->email . ' discarded due to applicable RFC ::::'  );
 395                      continue;
 396                  }
 397                  $this->row->replacements[$mp_user->email] = $this->get_user_replacements( $mp_user );
 398  
 399                  if ( isset( $this->args->toname ) ) if ( count( $mp_users ) == 1 ) $mp_user->name = $this->args->toname;
 400                  if ( empty( $mp_user->name ) )
 401                      if ( self::name_required )
 402                          $this->row->recipients[$mp_user->email]     = trim( str_replace( '.', ' ', substr( $mp_user->email, 0, strpos( $mp_user->email, '@' ) ) ) );
 403                      else
 404                          $this->row->recipients[] = $mp_user->email;
 405                  else
 406                      $this->row->recipients[$mp_user->email] = $mp_user->name;
 407              }
 408          }
 409      }
 410  
 411  	function get_external_recipient()
 412      {
 413          $this->trace->log( 'MAILPRESS [NOTICE] - :::: external recipient ::::' );
 414          $this->row->replacements[$this->args->toemail] = array();
 415  
 416          if ( isset( $this->args->toname ) )
 417              if ( !empty( $this->args->toname ) )
 418                  $this->row->recipients[$this->args->toemail] = $this->args->toname;
 419              else
 420                  if ( self::name_required )
 421                      $this->row->recipients[$this->args->toemail]     = trim( str_replace( '.', ' ', substr( $this->args->toemail, 0, strpos( $this->args->toemail, '@' ) ) ) );
 422                  else
 423                      $this->row->recipients[] = $this->args->toemail;
 424          else
 425              $this->row->recipients[] = $this->args->toemail;
 426      }
 427  
 428  	function get_old_recipients()
 429      {
 430          $this->row->replacements = $this->args->replacements;
 431  
 432          foreach( $this->row->replacements as $email => $v )
 433          {
 434              if ( isset( $v['{{toname}}'] ) && !empty( $v['{{toname}}'] ) )
 435                  $this->row->recipients[$email] = $v['{{toname}}'];
 436              else
 437              {
 438                  if ( !self::name_required )
 439                      $this->row->recipients[] = $email;
 440                  else
 441                  {
 442                      $name = trim( str_replace( '.', ' ', substr( $email, 0, strpos( $email, '@' ) ) ) );
 443                      $this->row->recipients[$email] = $this->row->replacements[$email]['{{toname}}'] =  $name;
 444                  }
 445              }
 446          }
 447      }
 448  
 449  	function get_user_replacements( $mp_user )
 450      {
 451          if ( !$mp_user ) return array();
 452  
 453          if ( is_numeric( $mp_user ) )
 454          {
 455              $mp_user = MP_User::get( $mp_user );
 456              if ( !$mp_user ) return array();
 457          }
 458  
 459          $replacements = MP_User_meta::get_replacements( $mp_user->id );
 460  
 461          $replacements ['{{toemail}}']    = $mp_user->email;
 462          $replacements ['{{toname}}']    = $mp_user->name;
 463          $replacements ['{{_user_id}}']= $mp_user->id;
 464  
 465      // always last //
 466          $replacements ['{{_confkey}}']= $mp_user->confkey;
 467          return $replacements;
 468      }
 469  
 470  	function replace_mail_urls()
 471      {
 472          $r = array();
 473          if ( isset( $this->args->viewhtml ) )     $r['{{viewhtml}}']     = $this->args->viewhtml;
 474          if ( isset( $this->args->subscribe ) )    $r['{{subscribe}}']     = $this->args->subscribe;
 475          if ( isset( $this->args->unsubscribe ) )$r['{{unsubscribe}}']     = $this->args->unsubscribe;
 476  
 477          foreach( $r as $k => $v )
 478          {
 479              $this->row->subject     = str_replace( $k, $v, $this->row->subject, $cs );
 480              $this->row->plaintext     = str_replace( $k, $v, $this->row->plaintext, $cp );
 481              $this->row->html         = str_replace( $k, $v, $this->row->html, $ch );
 482          }
 483      }
 484  
 485   // plaintext, html //
 486  
 487  	function build_mail_content( $type, $filter=false )
 488      {
 489          $this->build = new stdClass();
 490          $this->build->plaintext = ( 'plaintext' == $type );
 491          $this->build->filter = $filter;
 492  
 493          if ( !isset( $this->mail ) ) $this->mail = new stdClass();
 494          $this->mail->theme = $this->mail->themedir = $this->mail->template = null;
 495  
 496      // find the theme and themedir //
 497  
 498          $this->mail->theme     = $this->theme->themes[$this->theme->current_theme]['Stylesheet'];
 499          $this->mail->themedir    = $this->theme->themes[$this->theme->current_theme]['Stylesheet Dir'];
 500          if ( isset( $this->args->Theme ) && !empty( $this->args->Theme ) )
 501          {
 502              $x = $this->theme->get_theme_by_stylesheet( $this->args->Theme );
 503              if ( !empty( $x ) )
 504              {
 505                  $this->theme->current_theme     = $x['Name'];
 506                  $this->mail->theme        = $this->args->Theme;
 507                  $this->mail->themedir        = $x['Stylesheet Dir'];
 508              }
 509              elseif ( isset( $this->trace ) ) $this->trace->log( sprintf( 'MAILPRESS [WARNING] - Missing theme : >> %1$s << Type : %2$s ', $this->args->Theme, $type ), $this->trace->levels[512] );
 510          }
 511  
 512      // find the template //
 513  
 514          $template_name = '';
 515          $pt = $this->theme->get_page_templates( $this->mail->theme, $this->build->plaintext );
 516  
 517          $this->build->stylesheetpath  = ABSPATH . $this->theme->themes[$this->theme->current_theme] [ ( ( $this->build->plaintext ) ? 'Plaintext Stylesheet Dir' : 'Stylesheet Dir' ) ] . '/' ;
 518          $this->build->templatepath    = ABSPATH . $this->theme->themes[$this->theme->current_theme] [ ( ( $this->build->plaintext ) ? 'Plaintext Template Dir'   : 'Template Dir' ) ]   . '/' ;
 519          if ( $this->build->plaintext )
 520                      if ( $t = $this->theme->get_theme_by_stylesheet( 'plaintext' ) ) $this->build->plaintextpath = ABSPATH . $t['Stylesheet Dir'] . '/';
 521                      elseif ( isset( $this->trace ) ) $this->trace->log( 'MAILPRESS [ERROR] - Missing theme : plaintext theme has been deleted.', $this->trace->levels[512] );
 522          $this->build->dir         = $this->build->stylesheetpath;
 523  
 524          if ( isset( $this->args->Template ) && isset( $pt[$this->args->Template] ) ) $template_name = $this->locate_template( $pt[$this->args->Template]['file'] );
 525          if ( empty( $template_name ) ) $template_name = $this->locate_template(); // call default.php //
 526          else $this->mail->template = $this->args->Template;
 527  
 528      // build the content //
 529  
 530          $content = '';
 531      // call functions.php //
 532          foreach( $this->get_template_paths( 'functions.php', true ) as $file )
 533              if ( is_file( $file ) ) $content .= "<?php require_once ( '{$file}' ); ?>";
 534      // call any start action after functions.php //
 535          $content .= "<?php do_action( 'MailPress_build_mail_content_start', '$type' );?>";
 536      // call template or default //
 537          $content .= ( is_file( $template_name ) ) ? '<?php $this->load_template( \'' . $template_name . '\' ); ?>' : '<?php $this->get_header(); $this->the_content(); $this->get_footer(); ?>';
 538          $content .= "<?php do_action( 'MailPress_build_mail_content_end', '$type' );?>";
 539  
 540      // build the mail //
 541          $x = $this->do_eval( $content );
 542  
 543          unset( $this->build );
 544          return ( '<br />' == trim( $x ) ) ? '' : trim( $x );
 545      }
 546  
 547  	function do_eval( $x )
 548      {
 549          $x = 'global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; ?>' . "\n $x";
 550          ob_start();
 551              echo( eval( $x ) );
 552              $r = ob_get_contents();
 553          ob_end_clean();
 554          return $r;
 555      }
 556  
 557  
 558  ////  Send it  ////
 559  
 560  
 561  	function swift_processing()
 562      {
 563          new MP_Swift();
 564  
 565      // Swift message //
 566          try 
 567          {
 568              $this->build_swift_message();
 569  
 570  if ( $this->_debug ) $eml = $this->message->toString(); file_put_contents( MP_UPL_ABSPATH . $this->row->id . '.eml', $eml );
 571          }
 572          catch ( Exception $e ) 
 573          {
 574              if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 575  
 576              $this->trace->log( 'SWIFTMAILER [ERROR] - ' . "There was an unexpected problem building the mail:\n\n" . $e->getMessage() . "\n\n" );    
 577  
 578  if ( $this->_debug ) $eml = $this->message->toString(); file_put_contents( MP_UPL_ABSPATH . $this->row->id . '.eml', $eml );
 579  
 580              return false;
 581          }
 582  
 583      // Swift connection //
 584  
 585          if ( isset( $this->mail->mailpress_batch_spool_send ) && $this->mail->mailpress_batch_spool_send )
 586                                                              new MP_Swift_Connection_spool();
 587          if ( !has_filter( 'MailPress_Swift_Connection_type' ) )            new MP_Swift_Connection_smtp();
 588  
 589          try 
 590          {
 591              $Swift_Connection_type = apply_filters( 'MailPress_Swift_Connection_type', null );
 592  
 593              $conn = apply_filters( "MailPress_Swift_Connection_{$Swift_Connection_type}" , $this->row->id, $this->trace );
 594  
 595              // 5.x _ $this->swift = Swift_Mailer::newInstance( $conn );
 596              $this->swift = new Swift_Mailer( $conn );
 597          }
 598          catch ( Exception $e ) 
 599          {
 600              if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 601  
 602              $this->trace->log( 'SWIFTMAILER [ERROR] - ' . "There was a problem connecting with $Swift_Connection_type :\n\n" . $e->getMessage() . "\n\n" );    
 603              $this->mysql_connect( __CLASS__ . ' connect error :  ' . $Swift_Connection_type );
 604              return false;
 605          } 
 606  
 607      // Swift sending ... //
 608          try 
 609          {
 610              $this->swift = apply_filters( 'MailPress_swift_registerPlugin', $this->swift );
 611  
 612  // Swiftmailer logging //
 613  if ( $this->_debug )
 614  {
 615      $logger = new Swift_Plugins_Loggers_ArrayLogger();
 616      $this->swift->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
 617  }
 618  
 619              if ( $this->mail->mailpress_batch_send )
 620                  return apply_filters( 'MailPress_swift_send', $this );
 621  
 622              $this->mysql_disconnect( __CLASS__ );
 623  
 624          // swift batchSend //
 625              if ( $this->mail->swift_batchSend )
 626              {
 627                  $this->swift->registerPlugin( new Swift_Plugins_DecoratorPlugin( $this->row->replacements ) );
 628                  if ( !$this->swift_batchSend() )
 629                  {
 630                      $this->mysql_connect( __CLASS__ . ' batchSend' );
 631  
 632  // Swiftmailer logging //
 633  if ( $this->_debug ) $this->trace->log( 'SWIFTMAILER [LOGGING] - ' . $logger->dump() . "\n\n" );
 634  
 635                      return false;
 636                  }
 637              }
 638  
 639          // swift send //
 640              else
 641              {
 642                  if ( !$this->swift->send( $this->message ) ) 
 643                  {
 644                      $this->mysql_connect( __CLASS__ . ' send' );
 645  
 646  // Swiftmailer logging //
 647  if ( $this->_debug ) $this->trace->log( 'SWIFTMAILER [LOGGING] - ' . $logger->dump() . "\n\n" );
 648  
 649                      return false;
 650                  }
 651              }
 652  
 653  
 654  
 655          }
 656          catch ( Exception $e ) 
 657          {
 658              if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 659  
 660              $this->trace->log( 'SWIFTMAILER [ERROR] - ' . "There was a problem sending with $Swift_Connection_type :\n\n" . $e->getMessage() . "\n\n" );    
 661              $this->mysql_connect( __CLASS__ . ' sending error : ' . $Swift_Connection_type );
 662              return false;
 663          }
 664  
 665          $this->mysql_connect( __CLASS__ );
 666                          
 667          if ( $this->mail->mailpress_batch_spool_send ) do_action( 'MailPress_schedule_batch_spool_send' );
 668  
 669          return true;
 670      }
 671  
 672  	function swift_batchSend( &$failedRecipients = null )
 673      {
 674          $this->message->setCc( array() );
 675          $this->message->setBcc( array() );
 676  
 677          $sent = 0;
 678  
 679          foreach ( $this->message->getTo() as $address => $name )
 680          {
 681              $this->message->setTo( array( $address => $name ) );
 682              $sent += $this->swift->send( $this->message, $failedRecipients );
 683          }
 684  
 685          return $sent;
 686      }
 687  
 688  	function build_swift_message()
 689      {
 690  
 691      // charset //
 692          Swift_Preferences::getInstance()->setCharset( $this->row->charset );
 693  
 694      // message //
 695          // 5.x _ $this->message      = Swift_Message::newInstance();
 696          $this->message   = new Swift_Message();
 697  
 698          //if ( self::get8BitEncoding ) $this->message->setEncoder( Swift_Encoding::get8BitEncoding() );
 699          // 5.x _ $this->message->setEncoder( Swift_Encoding::getQpEncoding() );
 700          $this->message->setEncoder( Swift_DependencyContainer::getInstance()->lookup('mime.qpcontentencoder') );
 701  
 702      // from //
 703          $this->message->setFrom( array( $this->row->fromemail => $this->row->fromname ) );
 704  
 705      // to & replacements //
 706          if ( !$this->mail->swift_batchSend ) 
 707          {
 708              try
 709              {
 710                  $this->message->addTo( $this->row->toemail, $this->row->toname );
 711              }
 712              catch ( Exception $e ) 
 713              {
 714                  if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 715  
 716                  $this->trace->log( 'SWIFTMAILER [ERROR] - ' . "Recipient do not comply RFC rules ( discarded ) :\n\n" . $e->getMessage() . "\n\n" );
 717                  return false;
 718              }
 719          }
 720          else
 721          {
 722              foreach( $this->row->recipients as $toemail => $toname )
 723              {
 724                  try
 725                  {
 726                      $this->message->addTo( $toemail, $toname );
 727                  }
 728                  catch ( Exception $e ) 
 729                  {
 730                      if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 731  
 732                      $this->trace->log( 'SWIFTMAILER [WARNING] - ' . "Recipient do not comply RFC rules ( discarded ) :\n\n" . $e->getMessage() . "\n\n" );    
 733                      unset( $this->row->replacements[$toemail] );
 734                  }
 735              }
 736              foreach( $this->row->replacements as $k => $v ) $this->row->replacements[$k] = array_merge( $this->mail->replacements, $this->row->replacements[$k] );
 737          }
 738  
 739      // subject //
 740          $this->message->setSubject( $this->row->subject );
 741  
 742      // filter headers //
 743          $this->message    = apply_filters( 'MailPress_swift_message_headers', $this->message, $this->row );
 744  
 745      // html //
 746          if ( $this->row->html )
 747          {
 748              $this->message->setBody( $this->process_img( $this->row->html, $this->row->themedir ), 'text/html' );
 749          }
 750  
 751      // plaintext //
 752          if ( $this->row->plaintext )
 753          {
 754              if ( $this->row->html )
 755                  $this->message->addPart( $this->row->plaintext );
 756              else
 757                  $this->message->setBody( $this->row->plaintext );
 758          }
 759  
 760      // attachments //
 761          $metas = MP_Mail_meta::has( $this->row->id, '_MailPress_attached_file' );
 762          if ( $metas )
 763          {
 764              foreach( $metas as $meta )
 765              {
 766                  $meta_value = unserialize( $meta['meta_value'] );
 767                  if ( !is_file( $meta_value['file_fullpath'] ) ) continue;
 768                  $this->message->attach( Swift_Attachment::fromPath( $meta_value['file_fullpath'], $meta_value['mime_type'] )->setFilename( $meta_value['name'] ) );
 769              }
 770          }
 771  
 772      // signer //
 773          if ( has_filter( 'MailPress_Swift_Signer_type' ) )
 774          {
 775              $Swift_Signer_type = apply_filters( 'MailPress_Swift_Signer_type', false );
 776  
 777              if ( $Swift_Signer_type )
 778              {
 779                  $signer = apply_filters( "MailPress_Swift_Signer_{$Swift_Signer_type}", false );
 780                  if ( $signer )
 781                  {
 782                      $this->message->attachSigner( $signer );
 783                      $this->trace->log( 'MAILPRESS [NOTICE] - Signer found : ' . $Swift_Signer_type, $this->trace->levels[512] );
 784                  }
 785              }
 786          }
 787      }
 788  
 789  	function process_img( $html, $path, $dest = 'mail' )
 790      {
 791          $x        = $matches = $imgtags = array();
 792          $masks     = array ( '', $path . '/images/', $path . '/' );
 793  
 794          $keepurl    = apply_filters( 'MailPress_img_mail_keepurl', false );
 795  
 796          $siteurl     = site_url() . '/';
 797          $fprefix     = ( 'mail' == $dest ) ? ABSPATH : $siteurl;
 798  
 799          $out = preg_match_all( '/<img[^>]*>/Ui', $html, $imgtags, PREG_SET_ORDER ); // all img tag
 800  
 801          if ( empty( $imgtags ) ) return $html;
 802  
 803          foreach ( $imgtags as $imgtag )
 804          {
 805              $out = preg_match_all( '/src=[\'"]([^\'"]+)[\'"]/Ui', $imgtag[0], $src, PREG_SET_ORDER ); // for src attribute
 806              $matches[] = array( 0 => $imgtag[0], 1 => $src[0][1] );
 807          }
 808  
 809          $imgs = array();
 810          foreach ( $matches as $match )
 811          {
 812              $f = $u = false;
 813  
 814              if ( !MP_::is_image( $match[1] ) ) continue;
 815  
 816              if ( $keepurl && stristr( $match[1], $siteurl ) )
 817              {
 818                  $imgs[$match[1]] = $match[1];
 819                  continue;
 820              }
 821              elseif ( stristr( $match[1], $siteurl ) ) $u = true;
 822              elseif ( ( stristr( $match[1], 'http://' ) ) || ( stristr( $match[1], 'https://' ) ) )
 823              {
 824                  $imgs[$match[1]] = $match[1];
 825                  continue;
 826              }
 827  
 828              foreach ( $masks as $mask )
 829              {
 830                  if ( $u )     $file = str_ireplace( $siteurl, '', $match[1] );
 831                  else        $file = $mask . $match[1];
 832  
 833                  if ( is_file( ABSPATH . $file ) ) 
 834                  {
 835                      $f = true;
 836                      $x[$match[1]] = $fprefix . $file;        // we can have the src/url image in different img tags ... so we embed it one time only
 837                      if ( isset( $this->trace ) ) if ( 'mail' == $dest ) $this->trace->log( 'MAILPRESS [NOTICE] - Image found : ' . $file, $this->trace->levels[512] );
 838                  }
 839                  if ( $f ) break;
 840                  
 841              }
 842          }
 843  
 844          if ( 'mail' == $dest )
 845          {
 846              foreach ( $x as $key => $file )
 847              {
 848                  try 
 849                  {
 850                      $imgs[$key] = $this->message->embed( Swift_Image::fromPath( $file ) );
 851                  }
 852                  catch ( Exception $e ) 
 853                  {
 854                      if ( !( $e instanceof Swift_SwiftException ) ) throw $e;
 855  
 856                      if ( isset( $this->trace ) ) $this->trace->log( 'SWIFTMAILER [ERROR] - ' . "There was a problem with this image: $file \n\n" . $e->getMessage() . "\n\n" );
 857                  } 
 858              }
 859          }
 860          else
 861          {
 862              foreach ( $x as $key => $file )
 863              {
 864                  $imgs[$key] = $file;
 865              }
 866          }
 867          foreach ( $matches as $match )
 868          {
 869              $match[3]    = ( isset( $imgs[$match[1]] ) ) ? str_replace( $match[1], $imgs[$match[1]], $match[0] ) : $match[0]; // and we retrieve it now with the proper <img ... />
 870              if ( 'html' != $dest ) $match[3] = apply_filters( 'MailPress_img_mail', $match[3] ); // apply_filters for 'mail', 'draft'
 871              $html        = str_replace( $match[0], $match[3], $html );
 872          }
 873          return $html;
 874      }
 875  
 876  /// DISPLAYING MAILS ///
 877  
 878  
 879  	function get_replacements( $id, $main_id = false, $mp_user_id = false )
 880      {
 881          $mail_r = MP_Mail_meta::get( $id, '_MailPress_replacements' );
 882          if ( !$mail_r && $main_id ) $mail_r = MP_Mail_meta::get( $main_id, '_MailPress_replacements' );
 883          if ( !$mail_r ) $mail_r = array();
 884  
 885          if ( !$mp_user_id ) return $mail_r;
 886  
 887          $mail = MP_Mail::get( $id );
 888  
 889          if ( !$mail ) return $mail_r;
 890          if ( MailPress::is_email( $mail->toemail ) ) return $mail_r;
 891  
 892          $mail->toemail = unserialize( $mail->toemail );
 893  
 894          $mp_user = MP_User::get( $mp_user_id );
 895  
 896          if ( !$mp_user ) return $mail_r;
 897          if ( !isset( $mail->toemail[$mp_user->email] ) ) return $mail_r;
 898  
 899          return array_merge( $mail_r, $mail->toemail[$mp_user->email] );
 900      }
 901  
 902  	function viewsubject( $subject, $id, $main_id, $mp_user_id = false )
 903      {
 904          $replacements = $this->get_replacements( $id, $main_id, $mp_user_id );
 905          foreach( $replacements as $k => $v ) 
 906              $subject = str_replace( $k, $v, $subject, $ch );
 907          return $subject;
 908      }
 909  
 910  	function view( $args )
 911      {
 912          $defaults = array( 'type' => 'html', 'id' => 0, 'main_id' => 0, 'theme' => 0, 'template' => 0, 'mp_user_id' => 0 );
 913          $r = wp_parse_args( $args, $defaults );
 914          extract( $r );
 915  
 916          $x = MP_Mail::get( $id );
 917          $y = array( 'sent', 'unsent', 'archived' );
 918          if ( !in_array( $x->status, $y ) )
 919          {
 920              $this->args         = new stdClass();
 921              $this->args->id        = $id;
 922              $this->args->main_id    = $main_id;
 923  
 924              if ( $theme )         $this->args->Theme = $theme;
 925              if ( $template )         $this->args->Template = $template;
 926  
 927              if ( !isset( $this->row ) ) $this->row = new stdClass();
 928              $this->row->subject     = $x->subject;
 929  
 930              $this->args->{$type}     = $x->{$type};
 931              $x->{$type}         = $this->build_mail_content( $type, ( 'html' == $type ) ? 'the_content' : false );
 932              $x->themedir         = $this->mail->themedir;
 933          }
 934          $$type = ( 'html' == $type )? $this->process_img( $x->html, $x->themedir, 'draft' ) : $x->plaintext;
 935  
 936          $replacements = $this->get_replacements( $id, $main_id, $mp_user_id );
 937          foreach( $replacements as $k => $v ) $$type = str_replace( $k, $v, $$type, $ch );
 938  
 939          include MP_ABSPATH . "mp-includes/html/{$type}.php";
 940      }
 941  
 942  /// Get & Status ///
 943  
 944  	public static function get( $mail, $output = OBJECT ) 
 945      {
 946          switch ( true )
 947          {
 948              case ( empty( $mail ) ) :
 949                  if ( isset( $GLOBALS['mp_mail'] ) )     $_mail = & $GLOBALS['mp_mail'];
 950                  else                        return null;
 951              break;
 952              case ( is_object( $mail ) ) :
 953                  wp_cache_add( $mail->id, $mail, 'mp_mail' );
 954                  $_mail = $mail;
 955              break;
 956              default :
 957                  if ( isset( $GLOBALS['mp_mail'] ) && ( $GLOBALS['mp_mail']->id == $mail ) ) 
 958                  {
 959                      $_mail = & $GLOBALS['mp_mail'];
 960                  } 
 961                  elseif ( ! $_mail = wp_cache_get( $mail, 'mp_mail' ) ) 
 962                  {
 963                      global $wpdb;
 964                      $_mail = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->mp_mails WHERE id = %d LIMIT 1", $mail ) );
 965                      if ( $_mail ) wp_cache_add( $_mail->id, $_mail, 'mp_mail' );
 966                  }
 967              break;
 968          }
 969  
 970          if ( $output == OBJECT ) {
 971              return $_mail;
 972          } elseif ( $output == ARRAY_A ) {
 973              return get_object_vars( $_mail );
 974          } elseif ( $output == ARRAY_N ) {
 975              return array_values( get_object_vars( $_mail ) );
 976          } else {
 977              return $_mail;
 978          }
 979      }
 980  
 981  	public static function get_id( $from = 'inconnu' )
 982      {
 983          $data = $format = array();
 984  
 985          $data['status']         = '';                     $format[] = '%s';
 986          $data['created']         = current_time( 'mysql' );        $format[] = '%s';
 987          $data['created_user_id']= MP_WP_User::get_id();            $format[] = '%d';
 988          // longtext
 989          $data['toemail']         = '';                     $format[] = '%s';
 990          $data['html']         = '';                     $format[] = '%s';
 991          $data['plaintext']     = '';                     $format[] = '%s';
 992  
 993          global $wpdb;
 994          $wpdb->insert( $wpdb->mp_mails, $data, $format );
 995  
 996          return $wpdb->insert_id;
 997      }
 998  
 999  	public static function get_var( $var, $key_col, $key, $format = '%s' ) 
1000      {
1001          global $wpdb;
1002          return $wpdb->get_var( $wpdb->prepare( "SELECT $var FROM $wpdb->mp_mails WHERE $key_col = $format LIMIT 1;", $key ) );
1003      }
1004  
1005  	public static function get_status( $id ) 
1006      {
1007          $result = self::get_var( 'status', 'id', $id );
1008          return ( $result == NULL ) ? self::status_deleted : $result;
1009      }
1010  
1011  	public static function update_status( $id, $status )
1012      {
1013          wp_cache_delete( $id, 'mp_mail' );
1014  
1015          $data = $format = $where = $where_format = array();
1016  
1017          $data['status']             = $status;                             $format[] = '%s';
1018  
1019          $where['id']             = ( int ) $id;                        $where_format[] = '%d';
1020  
1021          global $wpdb;
1022          return $wpdb->update( $wpdb->mp_mails, $data, $where, $format, $where_format );
1023      }
1024  
1025  	public static function set_status( $id, $status ) 
1026      {
1027          switch( $status ) 
1028          {
1029              case 'sent':
1030                  if ( 'archived' == self::get_status( $id ) ) return self::update_status( $id, 'sent' );
1031                  return false;
1032              break;
1033              case 'archived':
1034                  if ( 'sent' == self::get_status( $id ) ) return self::update_status( $id, 'archived' );
1035                  return false;
1036              break;
1037              case 'paused':
1038                  if ( 'unsent' == self::get_status( $id ) ) return self::update_status( $id, 'paused' );
1039                  return false;
1040              break;
1041              case 'unsent':
1042                  if ( 'paused' == self::get_status( $id ) ) return self::update_status( $id, 'unsent' );
1043                  return false;
1044              break;
1045              case 'delete':
1046                  return self::delete( $id );
1047              break;
1048          }
1049          wp_cache_delete( $id, 'mp_mail' );
1050          return true;
1051      }
1052  
1053  	public static function delete( $id )
1054      {
1055          global $wpdb;
1056          do_action( 'MailPress_delete_mail', $id );
1057          wp_clear_scheduled_hook( 'mp_process_send_draft', array( $id ) );
1058  
1059          MP_Mail_revision::delete( $id );
1060  
1061          MP_Mail_meta::delete( $id );
1062  
1063          wp_cache_delete( $id, 'mp_mail' );
1064  
1065          return $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->mp_mails WHERE id = %d ; ", $id ) );
1066      }
1067  
1068  
1069  /// DISPLAYING E-MAILS & NAMES ///
1070  
1071  	public static function display_toemail( $toemail, $toname, $tolist = '', $selected=false )
1072      {
1073          $return = '';
1074          $draft_dest = MP_User::get_mailinglists();
1075  
1076          if         ( !empty( $tolist )  && isset( $draft_dest[$tolist] ) )    return "<b>" . $draft_dest[$tolist] . "</b>"; 
1077          elseif     ( !empty( $toemail ) && isset( $draft_dest[$toemail] ) )    return "<b>" . $draft_dest[$toemail] . "</b>"; 
1078          elseif     ( MailPress::is_email( $toemail ) )
1079          {
1080                  return self::display_name_email( $toname, $toemail );
1081          }
1082          else
1083          {
1084              $y = unserialize( $toemail );
1085              unset( $y['MP_Mail'] );
1086              if ( is_array( $y ) )
1087              {
1088                  $return = $s = '';
1089                  foreach ( $y as $k => $v )
1090                  {
1091                      if ( ( int ) $selected == ( int ) $v['{{_user_id}}'] ) $s = ' selected="selected"';
1092                      $opt = ( is_numeric( $k ) ) ? __( 'anonymized', 'MailPress' ) : $k;
1093                      $return .= "<option$s>$opt</option>";
1094                      if ( !empty( $s ) ) $selected = -1;
1095                      $s = '';
1096                  }
1097                  $selected = ( $selected == -1 ) ? ' disabled="disabled"' : '';
1098                  $return = "<select{$selected}>{$return}</select>";
1099                  return $return;
1100              }
1101          }
1102          return false;
1103      }
1104  
1105  	public static function display_name_email( $name, $email )
1106      {
1107          if ( empty( $name ) ) return $email;
1108          return self::display_name( esc_attr( $name ), false ) . " &lt;$email&gt;";
1109      }
1110  
1111  	public static function display_name( $name, $for_mail = true )
1112      {
1113          $default = '_';
1114          if ( MailPress::is_email( $name ) )    $name = trim( str_replace( '.', ' ', substr( $name, 0, strpos( $name, '@' ) ) ) );
1115          if ( $for_mail ) 
1116          { if ( empty( $name ) )     $name = $default; }
1117          else
1118          { if ( $default == $name )$name = '';}
1119          return $name;                                    
1120      }
1121  
1122  //// attachments
1123  
1124  	public static function get_attachment_link( $meta, $mail_status )
1125      {
1126          $meta_value = unserialize( $meta['meta_value'] );
1127          $href = esc_url( add_query_arg( array( 'action' => 'mp_ajax', 'mp_action' => 'attach_download', 'id' => $meta['meta_id'] ), admin_url( 'admin-ajax.php' ) ) );
1128  
1129          if ( in_array( $mail_status, array( 'sent', 'archived' ) ) )
1130          {
1131              if ( is_file( $meta_value['file_fullpath'] ) )
1132              {
1133                  return '<a href="' . $href . '" style="text-decoration:none;">' . $meta_value['name'] . '</a>';
1134              }
1135              else
1136              {
1137                  return '<span>' . $meta_value['name'] . '</span>';
1138              }
1139          }
1140          else
1141          {
1142              if ( is_file( $meta_value['file_fullpath'] ) )
1143              {
1144                  return '<a href="' . $href . '" style="text-decoration:none;">' . $meta_value['name'] . '</a>';
1145              }
1146          }
1147      }
1148  
1149  /* ajax */
1150  	public static function add_object()
1151      {
1152          MP_WP_List::add_object( self::object_type );
1153      }
1154  
1155  	public static function dim_object() 
1156      {
1157          MP_WP_List::dim_object( self::object_type );
1158      }
1159  
1160  	public static function delete_object() 
1161      {
1162          MP_WP_List::delete_object( self::object_type );
1163      }
1164  }


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