/** * format - output formatted EE object address information * * @access public * @param object EEI_Address $obj_with_address * @param string $type how the address is formatted. for example: 'multiline' or 'inline' * @param boolean $use_schema whether to apply schema.org formatting to the address * @param bool $add_wrapper * @return string */ public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true) { // check that incoming object implements the EEI_Address interface if (!$obj_with_address instanceof EEI_Address) { $msg = __('The address could not be formatted.', 'event_espresso'); $dev_msg = __('The Address Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso'); EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); return null; } // obtain an address formatter $formatter = EEH_Address::_get_formatter($type); // apply schema.org formatting ? $use_schema = !is_admin() ? $use_schema : false; $formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); $formatted_address = $add_wrapper && !$use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address; // return the formatted address return $formatted_address; }