WPCF7_ConfigValidator::detect_upload_filesize_overlimit()publicCF7 1.0

Detects errors of uploadable file size overlimit.

{} Это метод класса: WPCF7_ConfigValidator{}

Хуков нет.

Возвращает

null. Ничего.

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

$WPCF7_ConfigValidator = new WPCF7_ConfigValidator();
$WPCF7_ConfigValidator->detect_upload_filesize_overlimit( $section, $content );
$section (обязательный)
-
$content (обязательный)
-

Код WPCF7_ConfigValidator::detect_upload_filesize_overlimit() CF7 5.6.3

public function detect_upload_filesize_overlimit( $section, $content ) {
	$upload_max_filesize = ini_get( 'upload_max_filesize' );

	if ( ! $upload_max_filesize ) {
		return false;
	}

	$upload_max_filesize = strtolower( $upload_max_filesize );
	$upload_max_filesize = trim( $upload_max_filesize );

	if ( ! preg_match( '/^(\d+)([kmg]?)$/', $upload_max_filesize, $matches ) ) {
		return false;
	}

	if ( 'k' === $matches[2] ) {
		$upload_max_filesize = (int) $matches[1] * KB_IN_BYTES;
	} elseif ( 'm' === $matches[2] ) {
		$upload_max_filesize = (int) $matches[1] * MB_IN_BYTES;
	} elseif ( 'g' === $matches[2] ) {
		$upload_max_filesize = (int) $matches[1] * GB_IN_BYTES;
	} else {
		$upload_max_filesize = (int) $matches[1];
	}

	$form_tags_manager = WPCF7_FormTagsManager::get_instance();

	$tags = $form_tags_manager->filter( $content, array(
		'basetype' => 'file',
	) );

	foreach ( $tags as $tag ) {
		if ( $upload_max_filesize < $tag->get_limit_option() ) {
			return $this->add_error( $section,
				self::error_upload_filesize_overlimit,
				array(
					'message' => __( "Uploadable file size exceeds PHP’s maximum acceptable size.", 'contact-form-7' ),
					'link' => self::get_doc_link( 'upload_filesize_overlimit' ),
				)
			);
		}
	}

	return false;
}