Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I've been tasked with adding these utterly ridiculous vCards to this site I'm building. I can't figure out why I can't use typical WP template tags in my post variables. They don't work. What do I need to do to make them work in that setting? (As a note, this script works before I add in the WP goodies.)
- // wp_vcard.php
- <?php
- require_once('vcard.php');
- $filename = 'test.vcf';
- Header("Content-Disposition: attachment; filename=$filename");
- Header("Connection: close");
- Header("Content-Type: text/x-vCard; name=test.vcf");
- makeVcard();
- ?>
- // vcard.php
- <?php
- //----------------------------- get post variables -----------------------------//
- $v_type = 'individual';
- $v_first = get_the_author_meta('first_name');
- $v_middle = 'Joseph';
- $v_last = 'Giglio';
- $v_nick = 'Tommy Salami';
- $v_company = 'Tommy Giglio Multimedia';
- $v_title = 'Founder and CEO';
- $v_email = 'tommy@tgig.nu';
- $v_web = 'tommygiglio.net';
- $v_street = '1927 Orrington Ave.';
- $v_city = 'Evanston';
- $v_state = 'IL';
- $v_zip = '60201';
- $v_country = 'USA';
- $v_phone = '727-457-7647';
- $v_cell = '727-457-7647';
- $v_fax = '727-457-7647';
- $v_note = 'This is a note';
- //----------------------------- make vcard -----------------------------//
- function makeVcard() {
- if ($v_type=="company") { $vt="WORK"; }
- else { $vt="HOME"; }
- $vcard_content = "BEGIN:VCARD\r";
- $vcard_content .= "VERSION:3.0\r";
- $vcard_content .= "N:".$v_last.";".$v_first.";".$v_middle.";;\r";
- if ($v_type=="company") { $vcard_content .= "FN:".$v_company."\r"; }
- else { $vcard_content .= "FN:".$v_first." ".$v_middle." ".$v_last."\r"; }
- $vcard_content .= "NICKNAME:".$v_nick."\r";
- $vcard_content .= "ORG:".$v_company.";\r";
- $vcard_content .= "TITLE:".$v_title."\r";
- $vcard_content .= "EMAIL;type=INTERNET;type=".$vt.";type=pref:".$v_email."\r";
- $vcard_content .= "TEL;type=".$vt.";type=pref:".$v_phone."\r";
- $vcard_content .= "TEL;type=CELL:".$v_cell."\r";
- $vcard_content .= "TEL;type=".$vt.";type=FAX:".$v_fax."\r";
- $vcard_content .= "item1.ADR;type=".$vt.";type=pref:;;".$v_street.";".$v_city.";".$v_state.";".$v_zip.";".$v_country."\r";
- $vcard_content .= "item1.X-ABADR:us\r";
- $vcard_content .= "item2.URL;type=pref:".$v_web."\r";
- $vcard_content .= "item2.X-ABLabel:_$!<HomePage>!\$\_\r";
- $vcard_content .= "NOTE:".$v_note."\r";
- if ($v_type=="company") { $vcard_content .= "X-ABShowAs:COMPANY\r"; }
- $vcard_content .= "END:VCARD";
- echo $vcard_content;
- }
- // page-authorprofile.php where link is used to download the vCard
- get_header(); ?>
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <div id="article">
- <h1><?php the_title(); ?></h1>
- <?php the_content(); ?>
- <h2><a href="<?php bloginfo('template_directory'); ?>/admin/wp_vcard.php">Download vCard!</a></h2>
- </div>
- <?php endwhile; endif; ?>
- <?php get_footer(); ?>
- ?>
Add Comment
Please, Sign In to add comment