WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

PHPMailer\PHPMailer

PHPMailer::wrapText() public WP 1.0

Word-wrap message. For use with mailers that do not automatically perform wrapping and for quoted-printable encoded messages. Original written by philippe.

Это метод класса: PHPMailer{}

Хуков нет.

Возвращает

Строку.

Использование

$PHPMailer = new PHPMailer();
$PHPMailer->wrapText( $message, $length, $qp_mode );
$message(строка) (обязательный)
The message to wrap
$length(число) (обязательный)
The line length to wrap to
$qp_mode(true/false)
Whether to run in Quoted-Printable mode
По умолчанию: false

Код PHPMailer::wrapText() WP 5.5.1

<?php
public function wrapText($message, $length, $qp_mode = false)
{
    if ($qp_mode) {
        $soft_break = sprintf(' =%s', static::$LE);
    } else {
        $soft_break = static::$LE;
    }
    // If utf-8 encoding is used, we will need to make sure we don't
    // split multibyte characters when we wrap
    $is_utf8 = static::CHARSET_UTF8 === strtolower($this->CharSet);
    $lelen = strlen(static::$LE);
    $crlflen = strlen(static::$LE);

    $message = static::normalizeBreaks($message);
    //Remove a trailing line break
    if (substr($message, -$lelen) === static::$LE) {
        $message = substr($message, 0, -$lelen);
    }

    //Split message into lines
    $lines = explode(static::$LE, $message);
    //Message will be rebuilt in here
    $message = '';
    foreach ($lines as $line) {
        $words = explode(' ', $line);
        $buf = '';
        $firstword = true;
        foreach ($words as $word) {
            if ($qp_mode && (strlen($word) > $length)) {
                $space_left = $length - strlen($buf) - $crlflen;
                if (!$firstword) {
                    if ($space_left > 20) {
                        $len = $space_left;
                        if ($is_utf8) {
                            $len = $this->utf8CharBoundary($word, $len);
                        } elseif ('=' === substr($word, $len - 1, 1)) {
                            --$len;
                        } elseif ('=' === substr($word, $len - 2, 1)) {
                            $len -= 2;
                        }
                        $part = substr($word, 0, $len);
                        $word = substr($word, $len);
                        $buf .= ' ' . $part;
                        $message .= $buf . sprintf('=%s', static::$LE);
                    } else {
                        $message .= $buf . $soft_break;
                    }
                    $buf = '';
                }
                while ($word !== '') {
                    if ($length <= 0) {
                        break;
                    }
                    $len = $length;
                    if ($is_utf8) {
                        $len = $this->utf8CharBoundary($word, $len);
                    } elseif ('=' === substr($word, $len - 1, 1)) {
                        --$len;
                    } elseif ('=' === substr($word, $len - 2, 1)) {
                        $len -= 2;
                    }
                    $part = substr($word, 0, $len);
                    $word = (string) substr($word, $len);

                    if ($word !== '') {
                        $message .= $part . sprintf('=%s', static::$LE);
                    } else {
                        $buf = $part;
                    }
                }
            } else {
                $buf_o = $buf;
                if (!$firstword) {
                    $buf .= ' ';
                }
                $buf .= $word;

                if ('' !== $buf_o && strlen($buf) > $length) {
                    $message .= $buf_o . $soft_break;
                    $buf = $word;
                }
            }
            $firstword = false;
        }
        $message .= $buf . static::$LE;
    }

    return $message;
}