PHP Class BP_Reply_By_Email, bp-reply-by-email

Exibir arquivo Open project: r-a-y/bp-reply-by-email Class Usage Examples

Public Properties

Property Type Description
$inbound_provider Inbound provider loader. Defaults to boolean false.

Public Methods

Method Description
activity_listener ( object $item ) Saves pertinent activity variables to our "listener" object, which is used in {@link BP_Reply_By_Email::wp_mail_filter()} Since the activity component is used in other BP components, we can also do checks for forums and blogs as well.
admin_notice ( ) Add an admin notice nag
bbp_listener ( integer $reply_id, integer $topic_id ) bbPress 2 plugin compatibility.
disable_non_rbe_notice ( boolean $retval, array $args ) : boolean For non-RBE emails, we now add a line above each message denoting that the email is not one you can reply to.
get_inbound_providers ( ) : array Get inbound providers.
get_temporary_variables ( array $retval ) : array When posting group forum topics or posts via IMAP, we need to grab some temporary variables to pass to other methods - {@link BP_Reply_By_Email::group_forum_listener()} and {@link BP_Reply_By_Email::set_group_id()}.
group_forum_listener ( integer $post_id ) BP Group Email Subscription (GES) plugin compatibility.
init ( ) Initializes the class when called upon.
load_inbound_provider ( ) Load inbound provider.
localization ( ) Custom textdomain loader.
message_listener ( object $item ) Saves pertinent message variables to our "listener" object, which is used in {@link BP_Reply_By_Email::wp_mail_filter()}
move_nonrbe_notice_in_bp_html ( string $retval, string $property_name, string $transform ) Moves the non-RBE notice in the BP HTML email content to the top of the email.
move_rbe_marker ( str $html ) : str WP Better Emails Support.
move_rbe_marker_in_bp_html ( string $retval, string $property_name, string $transform ) Moves the RBE marker in the BP HTML email content to the top of the email.
phpmailer_set_reply_to_header ( PHPMailer $phpmailer ) Set 'Reply-To' email address for PHPMailer if mailbox is > 64 characters.
post ( boolean $retval, array $data, array $params ) : array | object Post by email routine.
set_bp_email_headers ( boolean | WP_Error $retval, BP_Email $email ) Set various email headers for BP 2.5 emails.
set_bp_post_object ( WP_Post $post ) : WP_Post Modify BP email content to prepend our RBE marker.
set_group_id ( integer $retval ) : integer Overrides the current group ID with our locally-cached one from {@link BP_Reply_By_Email::get_temporary_variables()} if available.
wp_mail_filter ( array $args ) : array Adds "Reply-To" to email headers in {@link wp_mail()}.

Protected Methods

Method Description
get_reply_to_address ( array $headers = [] ) Get the email address used for the 'Reply-To' email header.
prepend_nonrbe_notice_to_content ( string $content = '', $args = [] ) : string Prepend our non-RBE notice to a string.
prepend_rbe_marker_to_content ( string $content = '' ) : string Prepend our RBE marker to a string.

Private Methods

Method Description
constants ( ) Setup our constants.
hooks ( ) Setup RBE's hooks.
includes ( ) Include required files.

Method Details

activity_listener() public method

Saves pertinent activity variables to our "listener" object, which is used in {@link BP_Reply_By_Email::wp_mail_filter()} Since the activity component is used in other BP components, we can also do checks for forums and blogs as well.
Since: 1.0-beta
public activity_listener ( object $item )
$item object The activity object created during {@link BP_Activity_Activity::save()}

admin_notice() public method

Add an admin notice nag
Since: 1.0-beta
public admin_notice ( )

bbp_listener() public method

bbPress has built-in email subscriptions, so let's not reinvent the wheel! Here, we hook into the 'bbp_pre_notify_subscriptions' hook so we can setup our listener. This listener is only for bbPress forums that are not attached to BuddyPress groups. For BuddyPress groups, see the BBP_RBE_Extension::extend_activity_listener() method instead.
public bbp_listener ( integer $reply_id, integer $topic_id )
$reply_id integer The forum reply ID created by bbPress
$topic_id integer The forum topic ID created by bbPress

disable_non_rbe_notice() public method

However, there are instances where we do not want to add this line. This method disables this line when: - An email is sent from the admin area - An activation email is sent
Since: 1.0-RC2
public disable_non_rbe_notice ( boolean $retval, array $args ) : boolean
$retval boolean Should we disable the non-RBE notice?
$args array Email args passed by the 'wp_mail' filter
return boolean

get_inbound_providers() public static method

Get inbound providers.
Since: 1.0-RC3
public static get_inbound_providers ( ) : array
return array Key/value pairs (inbound provider name => class name)

get_reply_to_address() protected method

Get the email address used for the 'Reply-To' email header.
Since: 1.0-RC4
protected get_reply_to_address ( array $headers = [] )
$headers array Email headers.

get_temporary_variables() public method

When posting group forum topics or posts via IMAP, we need to grab some temporary variables to pass to other methods - {@link BP_Reply_By_Email::group_forum_listener()} and {@link BP_Reply_By_Email::set_group_id()}.
Since: 1.0-beta
public get_temporary_variables ( array $retval ) : array
$retval array Array of arguments
return array Array of arguments

group_forum_listener() public method

GES hooks into the 'bb_new_post' action to send emails in groups, so let's not reinvent the wheel. Here, we test to see if a forum topic / post is being made and we'll let GES handle the rest!
Since: 1.0-beta
public group_forum_listener ( integer $post_id )
$post_id integer The forum post ID created by bbPress

init() public method

Initializes the class when called upon.
public init ( )

load_inbound_provider() public method

Load inbound provider.
Since: 1.0-RC3

localization() public method

Checks WP_LANG_DIR for the .mo file first, then the plugin's language folder. Allows for a custom language file other than those packaged with the plugin.
Since: 1.0-beta
public localization ( )

message_listener() public method

Saves pertinent message variables to our "listener" object, which is used in {@link BP_Reply_By_Email::wp_mail_filter()}
Since: 1.0-beta
public message_listener ( object $item )
$item object The message object created during {@link BP_Messages_Message::send()}

move_nonrbe_notice_in_bp_html() public method

For BuddyPress 2.5+.
Since: 1.0-RC5.
public move_nonrbe_notice_in_bp_html ( string $retval, string $property_name, string $transform )
$retval string Current email HTML content.
$property_name string The email property being fetched.
$transform string Transformation return type.

move_rbe_marker() public method

WP Better Emails gives admins the ability to wrap the plain-text content around a HTML template. This interferes with the positioning of RBE's marker and how RBE parses the reply. So what we do in this method is to reposition the RBE marker to the beginning of the HTML body. This allows RBE to parse replies the way it was intended.
public move_rbe_marker ( str $html ) : str
$html str The full HTML email content from WPBE
return str Modified HTML content

move_rbe_marker_in_bp_html() public method

For BuddyPress 2.5+.
Since: 1.0-RC4.
public move_rbe_marker_in_bp_html ( string $retval, string $property_name, string $transform )
$retval string Current email HTML content.
$property_name string The email property being fetched.
$transform string Transformation return type.

phpmailer_set_reply_to_header() public method

Have to workaround a PHPMailer mailbox character limit issue by setting the 'Reply-To' email address again after PHPMailer has done its checks. This is done for installs still using wp_mail().
public phpmailer_set_reply_to_header ( PHPMailer $phpmailer )
$phpmailer PHPMailer

post() public method

Validates the parsed data and posts the various BuddyPress content.
Since: 1.0-RC3
public post ( boolean $retval, array $data, array $params ) : array | object
$retval boolean True by default.
$data array { 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. }
$params array Parsed paramaters from the email address querystring. See {@link BP_Reply_By_Email_Parser::get_parameters()}.
return array | object Array of the parsed item on success. WP_Error object on failure.

prepend_nonrbe_notice_to_content() protected method

Prepend our non-RBE notice to a string.
Since: 1.0-RC5
protected prepend_nonrbe_notice_to_content ( string $content = '', $args = [] ) : string
$content string
return string

prepend_rbe_marker_to_content() protected method

This adds the '--- Reply ABOVE THIS LINE to add a comment ---' line to the beginning of an email's content. Inspired by Basecamp!
Since: 1.0-RC4
protected prepend_rbe_marker_to_content ( string $content = '' ) : string
$content string
return string

set_bp_email_headers() public method

This includes the 'Reply-To' and custom 'From' headers.
Since: 1.0-RC4
public set_bp_email_headers ( boolean | WP_Error $retval, BP_Email $email )
$retval boolean | WP_Error Returns true if validation is successful, else a descriptive WP_Error.
$email BP_Email Current instance of the email type class.

set_bp_post_object() public method

For BuddyPress 2.5+.
Since: 1.0-RC4
public set_bp_post_object ( WP_Post $post ) : WP_Post
$post WP_Post BP Email post object.
return WP_Post

set_group_id() public method

Overrides the current group ID with our locally-cached one from {@link BP_Reply_By_Email::get_temporary_variables()} if available.
Since: 1.0-beta
public set_group_id ( integer $retval ) : integer
$retval integer The group ID
return integer $retval The group ID

wp_mail_filter() public method

Also manipulates message content for Basecamp-like behaviour.
Since: 1.0-beta
public wp_mail_filter ( array $args ) : array
$args array Arguments provided via {@link wp_mail()} filter.
return array

Property Details

$inbound_provider public_oe property

Inbound provider loader. Defaults to boolean false.
public $inbound_provider