[ Index ]

MailPress 544

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

title

Body

[close]

/mp-admin/includes/settings/ -> test.php (source)

   1  <?php
   2  $mp_general['tab'] = 'test';
   3      
   4  $test     = stripslashes_deep($_POST['test']);
   5  
   6  $test['template'] = $test['th'][$test['theme']]['tm'];
   7  unset($test['th']);
   8  
   9  switch (true)
  10  {
  11      case ( !is_email($test['toemail']) ) :
  12          $toemailclass = true;
  13          $message = __('field should be an email', MP_TXTDOM); $no_error = false;
  14      break;
  15      case ( empty($test['toname']) ) :
  16          $tonameclass = true;
  17          $message = __('field should be a name', MP_TXTDOM); $no_error = false;
  18      break;
  19      default :
  20          update_option(MailPress::option_name_test, $test);
  21          update_option(MailPress::option_name_general, $mp_general);
  22          if (isset($_POST['Submit']))
  23          {
  24              $message = __('Test settings saved', MP_TXTDOM);
  25          }
  26          else
  27          {
  28              $url   = home_url();
  29              $title = get_bloginfo('name');
  30  
  31              $mail = new stdClass();
  32              $mail->Theme = $test['theme'];
  33              if ('0' != $test['template']) $mail->Template = $test['template'];
  34  
  35              $mail->id        = MP_Mail::get_id('settings test');
  36  
  37          // Set the from name and email
  38              $mail->fromemail     = $mp_general['fromemail'];
  39              $mail->fromname    = $mp_general['fromname'];
  40  
  41          // Set destination address
  42              $mail->toemail     = $test['toemail'];
  43              $mail->toname    = MP_Mail::display_name($test['toname']);
  44              $key = MP_User::get_key_by_email($mail->toemail);
  45              if ($key)
  46              {
  47                  $mail->viewhtml     = MP_User::get_view_url($key, $mail->id);
  48                  $mail->unsubscribe = MP_User::get_unsubscribe_url($key);
  49                  $mail->subscribe      = MP_User::get_subscribe_url($key);
  50              }
  51  
  52          // Set mail's subject and body
  53              $mail->subject    = sprintf( __('Connection test : %1$s - Template : %2$s', MP_TXTDOM), get_bloginfo('name'), isset($mail->Template) ? $mail->Template : __('none', MP_TXTDOM));
  54  
  55              $mail->plaintext   =  "\n\n" . __('This is a test message of MailPress from', MP_TXTDOM) . ' ' . $url . "\n\n";
  56  
  57              $message  = "<div style='font-family: verdana, geneva;'><br /><br />";
  58              $message .=  sprintf(__('This is a <blink>test</blink> message of %1$s from %2$s. <br /><br />', MP_TXTDOM), ' <b>MailPress</b> ', "<a href='" .  $url . "'>$title</a>");
  59              $message .= "<br /><br /></div>";
  60              $mail->html       = $message;
  61  
  62              if (class_exists('MailPress_newsletter'))
  63              {
  64                  if (isset($mail->Template) && in_array($mail->Template, MP_Newsletter::get_templates()))
  65                  {
  66                      $posts = $wpdb->get_results( "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 1;" );
  67                      if ($posts)
  68                      {
  69                          $mail->the_title = apply_filters('the_title', $posts[0]->post_title );
  70                          $mail->newsletter= true;
  71                          query_posts('p='. $posts[0]->ID);
  72                      }
  73                  }
  74              }
  75  
  76              if (isset($test['forcelog']))     $mail->forcelog = '';
  77              if (!isset($test['fakeit']))         $mail->nomail = '';
  78              if (!isset($test['archive']))     $mail->noarchive = '';
  79              if (!isset($test['stats']))         $mail->nostats = '';
  80  
  81              if (MailPress::mail($mail))
  82                  if (!isset($test['fakeit']))     $message = __('Test settings saved, Mail not send as required', MP_TXTDOM);
  83                  else                    $message = __('Test successful, CONGRATULATIONS !', MP_TXTDOM);
  84              else
  85              {
  86                  $message = __('FAILED. Check your logs & settings !', MP_TXTDOM); $no_error = false;
  87              }
  88          }
  89      break;
  90  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1