WPCF7_FormTag::get_option()
Retrieves option values with the specified option name.
Метод класса: WPCF7_FormTag{}
Хуков нет.
Возвращает
Строку|Массив|true|false
. The option value or an array of option values. False if there is no option matches the pattern.
Использование
$WPCF7_FormTag = new WPCF7_FormTag(); $WPCF7_FormTag->get_option( $option_name, $pattern, $single );
- $option_name(строка) (обязательный)
- Option name.
- $pattern(строка)
- A regular expression pattern or one of the keys of preset patterns. If specified, only options whose value part matches this pattern will be returned.
По умолчанию: '' - $single(true|false)
- If true, only the first matching option will be returned.
По умолчанию: false
Код WPCF7_FormTag::get_option() WPCF7 FormTag::get option CF7 5.9.8
public function get_option( $option_name, $pattern = '', $single = false ) { $preset_patterns = array( 'date' => '[0-9]{4}-[0-9]{2}-[0-9]{2}', 'int' => '[0-9]+', 'signed_int' => '[-]?[0-9]+', 'num' => '(?:[0-9]+|(?:[0-9]+)?[.][0-9]+)', 'signed_num' => '[-]?(?:[0-9]+|(?:[0-9]+)?[.][0-9]+)', 'class' => '[-0-9a-zA-Z_]+', 'id' => '[-0-9a-zA-Z_]+', ); if ( isset( $preset_patterns[$pattern] ) ) { $pattern = $preset_patterns[$pattern]; } if ( '' == $pattern ) { $pattern = '.+'; } $pattern = sprintf( '/^%s:%s$/i', preg_quote( $option_name, '/' ), $pattern ); if ( $single ) { $matches = $this->get_first_match_option( $pattern ); if ( ! $matches ) { return false; } return substr( $matches[0], strlen( $option_name ) + 1 ); } else { $matches_a = $this->get_all_match_options( $pattern ); if ( ! $matches_a ) { return false; } $results = array(); foreach ( $matches_a as $matches ) { $results[] = substr( $matches[0], strlen( $option_name ) + 1 ); } return $results; } }