Flsupport_Tokens::get_object_field( $token_field,  $object )


Source Source

File: src/integrations/fluent-support/tokens/flsupport-tokens.php

	protected function get_object_field( $token_field, $object ) {

		if ( ! is_object( $object ) ) {
			return;
		}

		if ( strstr( $token_field, '_' ) ) {
			$parts        = explode( '_', $token_field );
			$property     = isset( $parts[0] ) ? $parts[0] : '';
			$sub_property = isset( $parts[1] ) ? $parts[1] : '';

			if ( '' !== $property && '' !== $sub_property ) {
				if ( isset( $object->$property ) && is_object( $object->$property ) ) {
					if ( isset( $object->$property->$sub_property ) ) {
						return $object->$property->$sub_property;
					}
				}
			}
		}

		$token_field = str_replace( '-', '_', $token_field );
		if ( isset( $object->$token_field ) ) {
			return $object->$token_field;
		}
	}