WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

WPCF7_Pipes{} CF7 1.0

Хуков нет.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

Возвращает

null. Ничего.

Использование

$WPCF7_Pipes = new WPCF7_Pipes();
// use class methods

Методы

  1. __construct( array $texts )
  2. add_pipe( $text )
  3. collect_afters()
  4. collect_befores()
  5. do_pipe( $input )
  6. random_pipe()
  7. to_array()
  8. zero()

Код WPCF7_Pipes{} CF7 5.5.3

class WPCF7_Pipes {

	private $pipes = array();

	public function __construct( array $texts ) {
		foreach ( $texts as $text ) {
			$this->add_pipe( $text );
		}
	}

	private function add_pipe( $text ) {
		$pipe = new WPCF7_Pipe( $text );
		$this->pipes[] = $pipe;
	}

	public function do_pipe( $input ) {
		$input_canonical = wpcf7_canonicalize( $input, array(
			'strto' => 'as-is',
		) );

		foreach ( $this->pipes as $pipe ) {

			list( $before, $after ) = array_map(
				function ( $item ) {
					return wpcf7_canonicalize( $item, array(
						'strto' => 'as-is',
					) );
				},
				array( $pipe->before, $pipe->after )
			);

			if ( $input_canonical === $before ) {
				return $after;
			}
		}

		return $input;
	}

	public function collect_befores() {
		$befores = array();

		foreach ( $this->pipes as $pipe ) {
			$befores[] = $pipe->before;
		}

		return $befores;
	}

	public function collect_afters() {
		$afters = array();

		foreach ( $this->pipes as $pipe ) {
			$afters[] = $pipe->after;
		}

		return $afters;
	}

	public function zero() {
		return empty( $this->pipes );
	}

	public function random_pipe() {
		if ( $this->zero() ) {
			return null;
		}

		return $this->pipes[array_rand( $this->pipes )];
	}

	public function to_array() {
		return array_map(
			function( WPCF7_Pipe $pipe ) {
				return array(
					$pipe->before,
					$pipe->after,
				);
			},
			$this->pipes
		);
	}
}