INVP::get_meta( string $unprefixed_meta_key, int $post_ID = null )

get_meta


Parameters Parameters

$unprefixed_meta_key

(string) (Required)

$post_ID

(int) (Optional)

Default value: null


Top ↑

Return Return

(string|int|double)


Top ↑

Source Source

File: includes/class-invp.php

	public static function get_meta( $unprefixed_meta_key, $post_ID = null )
	{
		if( empty( $post_ID ) )
		{
			$post_ID = get_the_ID();
		}

		$meta_key = apply_filters( 'invp_prefix_meta_key', $unprefixed_meta_key );

		//Options are stored as a multi-valued meta field
		$single = $unprefixed_meta_key != 'options_array';

		$meta_value = get_post_meta( $post_ID, $meta_key, $single );

		//If the meta key is a number, return a number, and zero instead of empty string
		if( self::meta_value_is_number( $meta_key ) )
		{
			if( empty( $meta_value ) )
			{
				return 0;
			}
			if( false === strpos( $meta_value, '.' ) )
			{
				return (int) $meta_value;
			}
			return (double) $meta_value;
		}
		return $meta_value;
	}