Plugin Updates
This commit is contained in:
@@ -36,8 +36,8 @@ class WPCF7_Pipes {
|
||||
|
||||
private $pipes = array();
|
||||
|
||||
public function __construct( array $texts ) {
|
||||
foreach ( $texts as $text ) {
|
||||
public function __construct( array $texts = null ) {
|
||||
foreach ( (array) $texts as $text ) {
|
||||
$this->add_pipe( $text );
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,10 @@ class WPCF7_Pipes {
|
||||
$this->pipes[] = $pipe;
|
||||
}
|
||||
|
||||
public function merge( self $another ) {
|
||||
$this->pipes = array_merge( $this->pipes, $another->pipes );
|
||||
}
|
||||
|
||||
public function do_pipe( $input ) {
|
||||
$input_canonical = wpcf7_canonicalize( $input, array(
|
||||
'strto' => 'as-is',
|
||||
@@ -109,3 +113,37 @@ class WPCF7_Pipes {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trait for classes that hold cross-tag WPCF7_Pipes object.
|
||||
*/
|
||||
trait WPCF7_PipesHolder {
|
||||
|
||||
protected $pipes;
|
||||
|
||||
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(
|
||||
'name' => $field_name,
|
||||
) );
|
||||
|
||||
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() {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user