Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/contact-.../includes
File: pipe.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Pipe-related classes.
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://contactform7.com/selectable-recipient-with-pipes/
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Class representing a pair of pipe.
[9] Fix | Delete
*/
[10] Fix | Delete
class WPCF7_Pipe {
[11] Fix | Delete
[12] Fix | Delete
public $before = '';
[13] Fix | Delete
public $after = '';
[14] Fix | Delete
[15] Fix | Delete
public function __construct( $text ) {
[16] Fix | Delete
$text = (string) $text;
[17] Fix | Delete
[18] Fix | Delete
$pipe_pos = strpos( $text, '|' );
[19] Fix | Delete
[20] Fix | Delete
if ( false === $pipe_pos ) {
[21] Fix | Delete
$this->before = $this->after = trim( $text );
[22] Fix | Delete
} else {
[23] Fix | Delete
$this->before = trim( substr( $text, 0, $pipe_pos ) );
[24] Fix | Delete
$this->after = trim( substr( $text, $pipe_pos + 1 ) );
[25] Fix | Delete
}
[26] Fix | Delete
}
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Class representing a list of pipes.
[32] Fix | Delete
*/
[33] Fix | Delete
class WPCF7_Pipes {
[34] Fix | Delete
[35] Fix | Delete
private $pipes = array();
[36] Fix | Delete
[37] Fix | Delete
public function __construct( array $texts = null ) {
[38] Fix | Delete
foreach ( (array) $texts as $text ) {
[39] Fix | Delete
$this->add_pipe( $text );
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
private function add_pipe( $text ) {
[44] Fix | Delete
$pipe = new WPCF7_Pipe( $text );
[45] Fix | Delete
$this->pipes[] = $pipe;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
public function merge( self $another ) {
[49] Fix | Delete
$this->pipes = array_merge( $this->pipes, $another->pipes );
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
public function do_pipe( $input ) {
[53] Fix | Delete
$input_canonical = wpcf7_canonicalize( $input, array(
[54] Fix | Delete
'strto' => 'as-is',
[55] Fix | Delete
) );
[56] Fix | Delete
[57] Fix | Delete
foreach ( $this->pipes as $pipe ) {
[58] Fix | Delete
$before_canonical = wpcf7_canonicalize( $pipe->before, array(
[59] Fix | Delete
'strto' => 'as-is',
[60] Fix | Delete
) );
[61] Fix | Delete
[62] Fix | Delete
if ( $input_canonical === $before_canonical ) {
[63] Fix | Delete
return $pipe->after;
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
return $input;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
public function collect_befores() {
[71] Fix | Delete
$befores = array();
[72] Fix | Delete
[73] Fix | Delete
foreach ( $this->pipes as $pipe ) {
[74] Fix | Delete
$befores[] = $pipe->before;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
return $befores;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
public function collect_afters() {
[81] Fix | Delete
$afters = array();
[82] Fix | Delete
[83] Fix | Delete
foreach ( $this->pipes as $pipe ) {
[84] Fix | Delete
$afters[] = $pipe->after;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
return $afters;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
public function zero() {
[91] Fix | Delete
return empty( $this->pipes );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
public function random_pipe() {
[95] Fix | Delete
if ( $this->zero() ) {
[96] Fix | Delete
return null;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
return $this->pipes[array_rand( $this->pipes )];
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
public function to_array() {
[103] Fix | Delete
return array_map(
[104] Fix | Delete
static function ( WPCF7_Pipe $pipe ) {
[105] Fix | Delete
return array(
[106] Fix | Delete
$pipe->before,
[107] Fix | Delete
$pipe->after,
[108] Fix | Delete
);
[109] Fix | Delete
},
[110] Fix | Delete
$this->pipes
[111] Fix | Delete
);
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Trait for classes that hold cross-tag WPCF7_Pipes object.
[118] Fix | Delete
*/
[119] Fix | Delete
trait WPCF7_PipesHolder {
[120] Fix | Delete
[121] Fix | Delete
protected $pipes;
[122] Fix | Delete
[123] Fix | Delete
public function get_pipes( $field_name ) {
[124] Fix | Delete
if ( isset( $this->pipes[$field_name] ) ) {
[125] Fix | Delete
return $this->pipes[$field_name];
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$result = new WPCF7_Pipes;
[129] Fix | Delete
[130] Fix | Delete
$tags = $this->scan_form_tags( array(
[131] Fix | Delete
'name' => $field_name,
[132] Fix | Delete
) );
[133] Fix | Delete
[134] Fix | Delete
foreach ( $tags as $tag ) {
[135] Fix | Delete
if ( $tag->pipes instanceof WPCF7_Pipes ) {
[136] Fix | Delete
$result->merge( $tag->pipes );
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
return $this->pipes[$field_name] = $result;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
public function scan_form_tags() {
[144] Fix | Delete
return array();
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function