Upload::__construct( string $form_name, string $name, array $args )

Description #

Initialize the class.

Parameters #

  • $form_name
    string (Required) Name of parent form.
  • $name
    string (Required) Name of field.
  • $args
    array (Required) Field arguments.

Source #

File: lib/form/class-upload.php

	public function __construct( $form_name, $name, $args ) {
		parent::__construct( $form_name, $name, $args );

		// Do not add array in field name.
		$this->field_name = $this->id();

		$this->multiple_upload = $this->args['upload_options']['multiple'];

		// Add array to field name if multiple file allowed.
		if ( true === $this->multiple_upload ) {
			$this->field_name = $this->field_name . '[]';
		}

		// Make sure field is sanitized.
		$this->sanitize_cb = array_merge( array( 'upload' ), $this->sanitize_cb );
		$this->validate_cb = array_merge( array( 'upload' ), $this->validate_cb );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment