Skip to content

Commit

Permalink
Update mail.php
Browse files Browse the repository at this point in the history
  • Loading branch information
takayukister committed Feb 12, 2023
1 parent cc82e7d commit 442d0f2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions includes/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ class WPCF7_MailTaggedText {
private $content = '';
private $replaced_tags = array();


/**
* The constructor method.
*/
public function __construct( $content, $args = '' ) {
$args = wp_parse_args( $args, array(
'html' => false,
Expand All @@ -424,10 +428,20 @@ public function __construct( $content, $args = '' ) {
$this->content = $content;
}


/**
* Retrieves mail-tags that have been replaced by this instance.
*
* @return array List of mail-tags replaced.
*/
public function get_replaced_tags() {
return $this->replaced_tags;
}


/**
* Replaces mail-tags based on regexp.
*/
public function replace_tags() {
$regex = '/(\[?)\[[\t ]*'
. '([a-zA-Z_][0-9a-zA-Z:._-]*)' // [2] = name
Expand All @@ -437,10 +451,18 @@ public function replace_tags() {
return preg_replace_callback( $regex, $this->callback, $this->content );
}


/**
* Callback function for replacement. For HTML message body.
*/
private function replace_tags_callback_html( $matches ) {
return $this->replace_tags_callback( $matches, true );
}


/**
* Callback function for replacement.
*/
private function replace_tags_callback( $matches, $html = false ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] == '['
Expand Down Expand Up @@ -516,6 +538,10 @@ private function replace_tags_callback( $matches, $html = false ) {
return $tag;
}


/**
* Formats string based on the formatting option in the form-tag.
*/
public function format( $original, $format ) {
$original = (array) $original;

Expand Down

0 comments on commit 442d0f2

Please sign in to comment.