Exemplo n.º 1
0
 /**
  * Main Welcome Buddy Instance
  *
  * Ensures only one instance of Welcome Buddy is loaded or can be loaded.
  *
  * @since  1.0.0
  * @access public static
  * @see    Welcome_Buddy()
  * @return Welcome Buddy instance
  */
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new Welcome_Buddy();
         self::$_instance->setup_constants();
         self::$_instance->includes();
         self::$_instance->load_plugin_textdomain();
         self::$_instance->init_hooks();
     }
     return self::$_instance;
 }
/**
 * Sends a test email
 *
 * @since 1.0.0
 */
function bp_send_test_email()
{
    if (isset($_GET['send_bp_test_email'])) {
        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'send-test-email')) {
            wp_die('Security check');
        }
        // Get current user
        $current_user = wp_get_current_user();
        // Send test email to current user
        $send_to = $current_user->user_email;
        // Load the mailer class
        $mailer = Welcome_Buddy::mailer();
        $email_heading = __('Email Preview', 'welcome-buddy');
        ob_start();
        include_once 'views/html-email-template-preview.php';
        $message = ob_get_clean();
        $email = new BP_Email();
        // Wrap the content with the email template and then add styles
        $message = $email->style_inline($mailer->wrap_message($email_heading, $message));
        $subject = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES) . ' ' . __('Test Email', 'welcome-buddy');
        if ($email->send($send_to, $subject, $message)) {
            _e('Test email was sent', 'welcome-buddy');
        } else {
            _e('Test email was not sent', 'welcome-buddy');
        }
        exit;
    }
}