Checkbox::field_markup()

Description #

Field markup.

Source #

File: lib/form/class-checkbox.php

	public function field_markup() {
		parent::field_markup();

		if ( $this->get( 'options' ) ) {
			$value = $this->value();

			foreach ( $this->get( 'options' ) as $val => $label ) {
				$checked = checked( isset( $value[ $val ] ), 1, false );
				$this->add_html( '<label>' );
				$this->add_html( '<input type="checkbox" value="1" name="' . esc_attr( $this->field_name ) . '[' . $val . ']" id="' . sanitize_html_class( $this->field_name . $val ) . '" class="ap-form-control" ' . $checked . $this->custom_attr() . '/>' );
				$this->add_html( $label . '</label>' );
			}
		} else {
			$checked = checked( $this->value(), 1, false );
			$this->add_html( '<label>' );
			$this->add_html( '<input type="checkbox" value="1" ' . $checked . $this->common_attr() . $this->custom_attr() . '/>' );
			$this->add_html( $this->get( 'desc' ) . '</label>' );
		}

		/** This action is documented in lib/form/class-input.php */
		do_action_ref_array( 'ap_after_field_markup', array( &$this ) );
	}

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