WPCF7_FormTagsManager::parse_atts()privateCF7 1.0

Parses the attributes of a form-tag to extract the name, options, and values.

Метод класса: WPCF7_FormTagsManager{}

Хуков нет.

Возвращает

Массив|Строку. An associative array of the options and values if the input is in the correct syntax, otherwise the input text itself.

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

// private - только в коде основоного (родительского) класса
$result = $this->parse_atts( $text );
$text(строка) (обязательный)
Attributes of a form-tag.

Код WPCF7_FormTagsManager::parse_atts() CF7 5.9.3

private function parse_atts( $text ) {
	$atts = array( 'options' => array(), 'values' => array() );
	$text = preg_replace( "/[\x{00a0}\x{200b}]+/u", " ", $text );
	$text = trim( $text );

	$pattern = '%^([-+*=0-9a-zA-Z:.!?#$&@_/|\%\r\n\t ]*?)((?:[\r\n\t ]*"[^"]*"|[\r\n\t ]*\'[^\']*\')*)$%';

	if ( preg_match( $pattern, $text, $matches ) ) {
		if ( ! empty( $matches[1] ) ) {
			$atts['options'] = preg_split( '/[\r\n\t ]+/', trim( $matches[1] ) );
		}

		if ( ! empty( $matches[2] ) ) {
			preg_match_all( '/"[^"]*"|\'[^\']*\'/', $matches[2], $matched_values );
			$atts['values'] = wpcf7_strip_quote_deep( $matched_values[0] );
		}
	} else {
		$atts = $text;
	}

	return $atts;
}