classes/Pods.php
public function has( $field, $value, $id = null ) {

		$pod =& $this;

		if ( null === $id ) {
			$id = $this->id();
			// @codingStandardsIgnoreLine.
		} elseif ( $id != $this->id() ) {
			$pod = pods( $this->pod, $id );
		}

		$this->do_hook( 'has', $field, $value, $id );

		if ( ! isset( $this->fields[ $field ] ) ) {
			return false;
		}

		// Tableless fields.
		if ( in_array( $this->fields[ $field ]['type'], PodsForm::tableless_field_types(), true ) ) {
			if ( ! is_array( $value ) ) {
				$value = explode( ',', $value );
			}

			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
				$current_value = $pod->raw( $field );

				if ( ! empty( $current_value ) ) {
					$current_value = (array) $current_value;
				}

				foreach ( $current_value as $v ) {
					// @codingStandardsIgnoreLine.
					if ( in_array( $v, $value ) ) {
						return true;
					}
				}
			} else {
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );

				foreach ( $value as $k => $v ) {
					if ( ! preg_match( '/[^\D]/', $v ) ) {
						$value[ $k ] = (int) $v;
					}

					// @todo Convert slugs into IDs.
				}

				foreach ( $related_ids as $v ) {
					// @codingStandardsIgnoreLine.
					if ( in_array( $v, $value ) ) {
						return true;
					}
				}
			}//end if
		} elseif ( in_array( $this->fields[ $field ]['type'], PodsForm::text_field_types(), true ) ) {
			// Text fields.
			$current_value = $pod->raw( $field );

			if ( 0 < strlen( $current_value ) ) {
				return stripos( $current_value, $value );
			}
		} else {
			// All other fields.
			return $this->is( $field, $value, $id );
		}//end if

		return false;
	}
public function has( $field, $value, $id = null ) {

		$pod =& $this;

		if ( null === $id ) {
			$id = $this->id();
			// @codingStandardsIgnoreLine.
		} elseif ( $id != $this->id() ) {
			$pod = pods( $this->pod, $id );
		}

		$this->do_hook( 'has', $field, $value, $id );

		if ( ! isset( $this->fields[ $field ] ) ) {
			return false;
		}

		// Tableless fields.
		if ( in_array( $this->fields[ $field ]['type'], PodsForm::tableless_field_types(), true ) ) {
			if ( ! is_array( $value ) ) {
				$value = explode( ',', $value );
			}

			if ( 'pick' === $this->fields[ $field ]['type'] && in_array( $this->fields[ $field ]['pick_object'], PodsForm::simple_tableless_objects(), true ) ) {
				$current_value = $pod->raw( $field );

				if ( ! empty( $current_value ) ) {
					$current_value = (array) $current_value;
				}

				foreach ( $current_value as $v ) {
					// @codingStandardsIgnoreLine.
					if ( in_array( $v, $value ) ) {
						return true;
					}
				}
			} else {
				$related_ids = $this->api->lookup_related_items( $this->fields[ $field ]['id'], $this->pod_data['id'], $id, $this->fields[ $field ], $this->pod_data );

				foreach ( $value as $k => $v ) {
					if ( ! preg_match( '/[^\D]/', $v ) ) {
						$value[ $k ] = (int) $v;
					}

					// @todo Convert slugs into IDs.
				}

				foreach ( $related_ids as $v ) {
					// @codingStandardsIgnoreLine.
					if ( in_array( $v, $value ) ) {
						return true;
					}
				}
			}//end if
		} elseif ( in_array( $this->fields[ $field ]['type'], PodsForm::text_field_types(), true ) ) {
			// Text fields.
			$current_value = $pod->raw( $field );

			if ( 0 < strlen( $current_value ) ) {
				return stripos( $current_value, $value );
			}
		} else {
			// All other fields.
			return $this->is( $field, $value, $id );
		}//end if

		return false;
	}
public function has ( $ field , $ value , $ id = null ) { $ pod = & $ this ; if ( null === $ id ) { $ id = $ this -> id ( ) ; // @codingStandardsIgnoreLine. } elseif ( $ id != $ this -> id ( ) ) { $ pod = pods ( $ this -> pod , $ id ) ; } $ this -> do_hook ( 'has' , $ field , $ value , $ id ) ; if ( ! isset ( $ this -> fields [ $ field ] ) ) { return false ; } // Tableless fields. if ( in_array ( $ this -> fields [ $ field ] [ 'type' ] , PodsForm :: tableless_field_types ( ) , true ) ) { if ( ! is_array ( $ value ) ) { $ value = explode ( ',' , $ value ) ; } if ( 'pick' === $ this -> fields [ $ field ] [ 'type' ] && in_array ( $ this -> fields [ $ field ] [ 'pick_object' ] , PodsForm :: simple_tableless_objects ( ) , true ) ) { $ current_value = $ pod -> raw ( $ field ) ; if ( ! empty ( $ current_value ) ) { $ current_value = ( array ) $ current_value ; } foreach ( $ current_value as $ v ) { // @codingStandardsIgnoreLine. if ( in_array ( $ v , $ value ) ) { return true ; } } } else { $ related_ids = $ this -> api -> lookup_related_items ( $ this -> fields [ $ field ] [ 'id' ] , $ this -> pod_data [ 'id' ] , $ id , $ this -> fields [ $ field ] , $ this -> pod_data ) ; foreach ( $ value as $ k => $ v ) { if ( ! preg_match ( '/[^\D]/' , $ v ) ) { $ value [ $ k ] = ( int ) $ v ; } // @todo Convert slugs into IDs. } foreach ( $ related_ids as $ v ) { // @codingStandardsIgnoreLine. if ( in_array ( $ v , $ value ) ) { return true ; } } } //end if } elseif ( in_array ( $ this -> fields [ $ field ] [ 'type' ] , PodsForm :: text_field_types ( ) , true ) ) { // Text fields. $ current_value = $ pod -> raw ( $ field ) ; if ( 0 < strlen ( $ current_value ) ) { return stripos ( $ current_value , $ value ) ; } } else { // All other fields. return $ this -> is ( $ field , $ value , $ id ) ; } //end if return false ; }
Check if an item field has a specific value in it

@param string $field Field name.
@param mixed  $value Value to check.
@param int    $id    (optional) ID of the pod item to check.

@return bool Whether the value was found

@since 2.3.3
Check if an item field has a specific value in it