Field::id( string $str = false )

Description #

Return safe css ID.

Parameters #

  • $str
    string (Optional) String. Default value: false

Source #

File: lib/form/class-field.php

	public function id( $str = false ) {
		if ( ! empty( $this->field_id ) ) {
			return $this->field_id;
		}

		if ( false === $str ) {
			$str = $this->field_name;
		}

		return sanitize_html_class(
			rtrim( preg_replace( '/-+/', '-', str_replace( array( '[', ']' ), '-', $str ) ), '-' )
		);
	}

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