: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @link https://contactform7.com/selectable-recipient-with-pipes/
* Class representing a pair of pipe.
public function __construct( $text ) {
$pipe_pos = strpos( $text, '|' );
if ( false === $pipe_pos ) {
$this->before = $this->after = trim( $text );
$this->before = trim( substr( $text, 0, $pipe_pos ) );
$this->after = trim( substr( $text, $pipe_pos + 1 ) );
* Class representing a list of pipes.
private $pipes = array();
public function __construct( array $texts = null ) {
foreach ( (array) $texts as $text ) {
$this->add_pipe( $text );
private function add_pipe( $text ) {
$pipe = new WPCF7_Pipe( $text );
public function merge( self $another ) {
$this->pipes = array_merge( $this->pipes, $another->pipes );
public function do_pipe( $input ) {
$input_canonical = wpcf7_canonicalize( $input, array(
foreach ( $this->pipes as $pipe ) {
$before_canonical = wpcf7_canonicalize( $pipe->before, array(
if ( $input_canonical === $before_canonical ) {
public function collect_befores() {
foreach ( $this->pipes as $pipe ) {
$befores[] = $pipe->before;
public function collect_afters() {
foreach ( $this->pipes as $pipe ) {
$afters[] = $pipe->after;
return empty( $this->pipes );
public function random_pipe() {
return $this->pipes[array_rand( $this->pipes )];
public function to_array() {
static function ( WPCF7_Pipe $pipe ) {
* Trait for classes that hold cross-tag WPCF7_Pipes object.
trait WPCF7_PipesHolder {
public function get_pipes( $field_name ) {
if ( isset( $this->pipes[$field_name] ) ) {
return $this->pipes[$field_name];
$result = new WPCF7_Pipes;
$tags = $this->scan_form_tags( array(
foreach ( $tags as $tag ) {
if ( $tag->pipes instanceof WPCF7_Pipes ) {
$result->merge( $tag->pipes );
return $this->pipes[$field_name] = $result;
public function scan_form_tags() {