WPCF7_ConfigValidator::count_errors
Counts detected errors.
Метод класса: WPCF7_ConfigValidator{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WPCF7_ConfigValidator = new WPCF7_ConfigValidator(); $WPCF7_ConfigValidator->count_errors( $options );
- $options
- .
По умолчанию:''
Код WPCF7_ConfigValidator::count_errors() WPCF7 ConfigValidator::count errors CF7 6.1.5
public function count_errors( $options = '' ) {
$options = wp_parse_args( $options, array(
'section' => '',
'code' => '',
) );
$count = 0;
foreach ( $this->errors as $key => $errors ) {
if ( preg_match( '/^mail_[0-9]+\.(.*)$/', $key, $matches ) ) {
$key = sprintf( 'mail.%s', $matches[1] );
}
if (
$options['section'] and
$key !== $options['section'] and
preg_replace( '/\..*$/', '', $key, 1 ) !== $options['section']
) {
continue;
}
foreach ( $errors as $error ) {
if ( empty( $error ) ) {
continue;
}
if ( $options['code'] and $error['code'] !== $options['code'] ) {
continue;
}
$count += 1;
}
}
return $count;
}