-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webfinger.php
64 lines (51 loc) · 2.18 KB
/
webfinger.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
58
59
60
61
62
63
64
<?php
/**
* Plugin Name: WebFinger
* Plugin URI: https://github.com/pfefferle/wordpress-webfinger
* Description: WebFinger for WordPress
* Version: 3.2.7
* Author: Matthias Pfefferle
* Author URI: https://notiz.blog/
* License: MIT
* License URI: https://opensource.org/licenses/MIT
*/
defined( 'WEBFINGER_LEGACY' ) || define( 'WEBFINGER_LEGACY', false );
/**
* Initialize plugin
*/
function webfinger_init() {
// list of various public helper functions
require_once( dirname( __FILE__ ) . '/includes/functions.php' );
require_once( dirname( __FILE__ ) . '/includes/class-webfinger.php' );
add_action( 'query_vars', array( 'Webfinger', 'query_vars' ) );
add_action( 'parse_request', array( 'Webfinger', 'parse_request' ) );
add_action( 'init', array( 'Webfinger', 'generate_rewrite_rules' ) );
add_filter( 'webfinger_data', array( 'Webfinger', 'generate_user_data' ), 10, 3 );
add_filter( 'webfinger_data', array( 'Webfinger', 'generate_post_data' ), 10, 3 );
add_filter( 'webfinger_data', array( 'Webfinger', 'filter_by_rel' ), 99, 1 );
// default output
add_action( 'webfinger_render', array( 'Webfinger', 'render_jrd' ) );
// add legacy WebFinger class
if ( WEBFINGER_LEGACY && ! class_exists( 'WebFingerLegacy_Plugin' ) ) {
require_once( dirname( __FILE__ ) . '/includes/class-webfinger-legacy.php' );
add_action( 'query_vars', array( 'Webfinger_Legacy', 'query_vars' ) );
add_filter( 'host_meta', array( 'Webfinger_Legacy', 'host_meta_discovery' ) );
// host-meta recource
add_action( 'host_meta_render', array( 'Webfinger_Legacy', 'render_host_meta' ), -1, 3 );
// XRD output
add_action( 'webfinger_render', array( 'Webfinger_Legacy', 'render_xrd' ), 5 );
// support plugins pre 3.0.0
add_filter( 'webfinger_user_data', array( 'Webfinger_Legacy', 'legacy_filter' ), 10, 3 );
}
}
add_action( 'plugins_loaded', 'webfinger_init' );
/**
* Flush rewrite rules
*/
function webfinger_flush_rewrite_rules() {
require_once( dirname( __FILE__ ) . '/includes/class-webfinger.php' );
Webfinger::generate_rewrite_rules();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'webfinger_flush_rewrite_rules' );
register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );