WordPress.org

Ready to get started?Download WordPress

Forums

hCard & vCard Generator
[BUG] Incorrect address format (1 post)

  1. ururk
    Member
    Posted 1 year ago #

    I found a bug - second address is not added to the vCard properly, and extended address and PO Box semicolons are missing. I posted the code below.

    I also think it is unnecessary to generate a file for the vCard - php is capable of generating the code/headers to create a vCard - see http://www.troywolf.com/articles/php/class_vcard/. I try (for security purposes) to minimize the amount of files that are generated outside of uploads.

    From what I've read/tested out, the address line for a vCard requires semicolons for certain fields even if they are not being used. Two are missing, and the second address field is missing - I've attached some code which fixes this issue:

    // Generate the vCard and save as a file
    			$fileContents = 'BEGIN:VCARD
    VERSION:3.0
    N:' . (!empty($user_info->last_name) ? $user_info->last_name : '') . ';' . (!empty($user_info->first_name) ? $user_info->first_name : '') . '
    FN:' . (!empty($user_info->display_name) ? $user_info->display_name : '') . '
    URL:' . (!empty($user_info->user_url) ? $user_info->user_url : '') . '
    PHOTO:' . (!empty($user_info->user_photourl) ? $user_info->user_photourl : '') . '
    ORG:' . (!empty($user_info->user_organization) ? $user_info->user_organization : '') . '
    NOTE:' . (!empty($user_info->user_note) ? $user_info->user_note : '') . '
    TITLE:' . (!empty($user_info->user_job_title) ? $user_info->user_job_title : '') . '
    TEL;TYPE=WORK,VOICE:' . (!empty($user_info->user_phone_work) ? $user_info->user_phone_work : '') . '
    TEL;TYPE=CELL,VOICE:' . (!empty($user_info->user_phone_mobile) ? $user_info->user_phone_mobile : '') . '
    EMAIL;TYPE=PREF,INTERNET:' . (!empty($user_info->user_email) ? $user_info->user_email : '') . '
    ADR;TYPE=work:;;' . (!empty($user_info->user_street_address_line_1) ? $user_info->user_street_address_line_1 : '') .
    (!empty($user_info->user_street_address_line_2) ? '\n' . $user_info->user_street_address_line_2 : '') . ';' .
    (!empty($user_info->user_locality) ? $user_info->user_locality : '') . ';' .
    (!empty($user_info->user_region) ? $user_info->user_region : '') . ';' .
    (!empty($user_info->user_postcode) ? $user_info->user_postcode : '') . ';' .
    (!empty($user_info->user_country) ? $user_info->user_country : '') . '' . '
    END:VCARD';

    John

    http://wordpress.org/extend/plugins/hcard-vcard-generator-wordpress-plugin/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.