BP_Reply_By_Email_Parser::get_body PHP Метод

get_body() публичный статический Метод

Parses and returns the email body content.
public static get_body ( string $body = '', boolean $html = false, boolean $reply = true, integer $i = 1 ) : string | boolean
$body string The email body content.
$html boolean Whether the email body is HTML or not. Defaults to false.
$reply boolean Whether the current item is a reply. Defaults to true.
$i integer The current email message number.
Результат string | boolean
    public static function get_body($body = '', $html = false, $reply = true, $i = 1)
    {
        if ($html) {
            $body = apply_filters('bp_rbe_parse_html_email', $body);
        }
        // Check to see if we're parsing a reply
        if ($reply) {
            // Find our pointer
            $pointer = strpos($body, bp_rbe_get_marker());
            // If our pointer isn't found, return false
            if ($pointer === false) {
                return false;
            }
            // Return email body up to our pointer only
            $body = apply_filters('bp_rbe_parse_email_body_reply', trim(substr($body, 0, $pointer)), $body);
            // this means we're posting something new (eg. new forum topic)
            // do something special for this case
        } else {
            $body = apply_filters('bp_rbe_parse_email_body_new', $body);
        }
        if (empty($body)) {
            bp_rbe_log('Message #' . $i . ': empty body');
            return false;
        }
        return apply_filters('bp_rbe_parse_email_body', trim($body));
    }

Usage Example

    /**
     * Setup our extension's failure message to send back to the sender.
     *
     * @param mixed $message
     * @param string $type Type of error message
     * @param array $data {
     *     An array of arguments.
     *
     *     @type array $headers Email headers.
     *     @type string $content The email body content.
     *     @type string $subject The email subject line.
     *     @type int $user_id The user ID who sent the email.
     *     @type bool $is_html Whether the email content is HTML or not.
     *     @type int $i The email message number.
     * }
     * @param int $i The message number from the inbox loop
     * @param resource $connection The current IMAP connection. Chances are you probably don't have to do anything with this!
     * @return string|bool Could be a string or boolean false.
     */
    public function failure_message_to_sender($message, $type, $data, $i, $imap)
    {
        switch ($type) {
            case 'bp_doc_parent_comment_deleted':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because the parent comment you were replying to no longer exists.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_parent_comment_spam':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because the parent comment you were replying to was marked as spam.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_parent_comment_unapproved':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because the parent comment you were replying was unapproved.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_comment_change_to_noone':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because the comment setting for this group document recently changed to "No One".
This means that no other comments can be posted for the group document in question.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_user_not_admin_mod':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because the comment setting for this group document recently changed to "Admin and moderators only".
Since you are not a group administrator or a group moderator, this means your comment could be posted.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_user_not_member':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted because you are no longer a member of this group.  To comment on this group document, please rejoin the group.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
            case 'bp_doc_new_comment_fail':
                $message = sprintf(__('Hi there,

Your comment to the group document:

"%s"

Could not be posted due to an error.

We apologize for any inconvenience this may have caused.', 'bp-rbe'), BP_Reply_By_Email_Parser::get_body($data['content'], $data['is_html'], true, $i));
                break;
        }
        return $message;
    }
All Usage Examples Of BP_Reply_By_Email_Parser::get_body