-
Notifications
You must be signed in to change notification settings - Fork 0
/
author-vcards.php
57 lines (49 loc) · 1.15 KB
/
author-vcards.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Plugin Name: Author VCards
* Plugin URI: https://github.com/pie/author-vcards/
* Version: 1.2.8
* Author: The team at PIE
* Author URI: https://pie.co.de
*/
namespace PIE\AuthorVcards;
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
/**
* Load Composer autoloader
*/
require_once __DIR__ . '/vendor/autoload.php';
$update_checker = \Puc_v4_Factory::buildUpdateChecker(
'https://pie.github.io/author-vcards/update.json',
__FILE__,
'author-vcards'
);
/**
* Add vcard endpoint and a comment
*
* @return void
*/
function add_vcard_endpoint()
{
add_rewrite_endpoint('vcf', EP_AUTHORS);
}
add_action('init', __NAMESPACE__ . '\add_vcard_endpoint');
/**
* Add vcard query var
*
* @param array $vars
* @return array
*/
function json_template_redirect()
{
global $wp_query;
// if this is not a request for json or a singular object then bail
if (! isset($wp_query->query_vars['vcf']) || ! is_author()) {
return;
}
// include custom template
include dirname(__FILE__) . '/vcf-template.php';
exit;
}
add_action('template_redirect', __NAMESPACE__ . '\json_template_redirect');