Guest User

Untitled

a guest
Apr 26th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. //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.)
  2.  
  3.  
  4. // wp_vcard.php
  5.  
  6. <?php
  7.  
  8. require_once('vcard.php');
  9.  
  10. $filename = 'test.vcf';
  11.  
  12. Header("Content-Disposition: attachment; filename=$filename");
  13. Header("Connection: close");
  14. Header("Content-Type: text/x-vCard; name=test.vcf");
  15.  
  16. makeVcard();
  17. ?>
  18.  
  19.  
  20. // vcard.php
  21.  
  22. <?php
  23.  
  24.  
  25. //----------------------------- get post variables -----------------------------//
  26.  
  27. $v_type = 'individual';
  28. $v_first = get_the_author_meta('first_name');
  29. $v_middle = 'Joseph';
  30. $v_last = 'Giglio';
  31. $v_nick = 'Tommy Salami';
  32. $v_company = 'Tommy Giglio Multimedia';
  33. $v_title = 'Founder and CEO';
  34. $v_email = 'tommy@tgig.nu';
  35. $v_web = 'tommygiglio.net';
  36. $v_street = '1927 Orrington Ave.';
  37. $v_city = 'Evanston';
  38. $v_state = 'IL';
  39. $v_zip = '60201';
  40. $v_country = 'USA';
  41. $v_phone = '727-457-7647';
  42. $v_cell = '727-457-7647';
  43. $v_fax = '727-457-7647';
  44. $v_note = 'This is a note';
  45.  
  46. //----------------------------- make vcard -----------------------------//
  47.  
  48. function makeVcard() {
  49.  
  50.  
  51.  
  52. if ($v_type=="company") { $vt="WORK"; }
  53. else { $vt="HOME"; }
  54.  
  55. $vcard_content = "BEGIN:VCARD\r";
  56. $vcard_content .= "VERSION:3.0\r";
  57. $vcard_content .= "N:".$v_last.";".$v_first.";".$v_middle.";;\r";
  58. if ($v_type=="company") { $vcard_content .= "FN:".$v_company."\r"; }
  59. else { $vcard_content .= "FN:".$v_first." ".$v_middle." ".$v_last."\r"; }
  60. $vcard_content .= "NICKNAME:".$v_nick."\r";
  61. $vcard_content .= "ORG:".$v_company.";\r";
  62. $vcard_content .= "TITLE:".$v_title."\r";
  63. $vcard_content .= "EMAIL;type=INTERNET;type=".$vt.";type=pref:".$v_email."\r";
  64. $vcard_content .= "TEL;type=".$vt.";type=pref:".$v_phone."\r";
  65. $vcard_content .= "TEL;type=CELL:".$v_cell."\r";
  66. $vcard_content .= "TEL;type=".$vt.";type=FAX:".$v_fax."\r";
  67. $vcard_content .= "item1.ADR;type=".$vt.";type=pref:;;".$v_street.";".$v_city.";".$v_state.";".$v_zip.";".$v_country."\r";
  68. $vcard_content .= "item1.X-ABADR:us\r";
  69. $vcard_content .= "item2.URL;type=pref:".$v_web."\r";
  70. $vcard_content .= "item2.X-ABLabel:_$!<HomePage>!\$\_\r";
  71. $vcard_content .= "NOTE:".$v_note."\r";
  72. if ($v_type=="company") { $vcard_content .= "X-ABShowAs:COMPANY\r"; }
  73. $vcard_content .= "END:VCARD";
  74.  
  75.  
  76. echo $vcard_content;
  77.  
  78.  
  79. }
  80.  
  81.  
  82. // page-authorprofile.php where link is used to download the vCard
  83.  
  84. get_header(); ?>
  85.  
  86. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  87.  
  88. <div id="article">
  89. <h1><?php the_title(); ?></h1>
  90. <?php the_content(); ?>
  91.  
  92. <h2><a href="<?php bloginfo('template_directory'); ?>/admin/wp_vcard.php">Download vCard!</a></h2>
  93.  
  94. </div>
  95.  
  96. <?php endwhile; endif; ?>
  97.  
  98. <?php get_footer(); ?>
  99.  
  100.  
  101.  
  102. ?>
Add Comment
Please, Sign In to add comment