This repository has been archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webmention_pipelines.php
57 lines (47 loc) · 1.62 KB
/
webmention_pipelines.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
use IndieWeb\MentionClient;
use Mf2\Mf2;
function webmention_post_insertion($flux) {
$feedIds = lire_config('webmention/id_syndic');
// Stop execution if no feed is selected.
if (!isset($feedIds)) {
return $flux;
}
// Stop execution if the article does not belong to one of the selected feeds.
if (!in_array(
$flux['data']['id_syndic'],
explode(',', $feedIds)
)) {
return $flux;
}
$sourceURL = generer_url_public(
'repost',
[
'id' => $flux['args']['id_objet'],
],
true,
false
);
$targetURL = $flux['data']['url'];
$client = new MentionClient();
$response = $client->sendWebmention($sourceURL, $targetURL);
if (lire_config('webmention/debug') === 'on') {
spip_log(
[
'sourceURL' => $sourceURL,
'targetURL' => $targetURL,
'$flux' => $flux,
'rels' => $client->c('rels', $targetURL),
'supportsPingback' => $client->c('supportsPingback', $targetURL),
'supportsWebmention' => $client->c('supportsWebmention', $targetURL),
'webmentionServer' => $client->c('webmentionServer', $targetURL),
'supportsWebmention' => $client->c('supportsWebmention', $targetURL),
'supportsWebmention' => $client->c('supportsWebmention', $targetURL),
'response' => $response,
],
'plugin_webmention.' . _LOG_INFO_IMPORTANTE
);
}
return $flux;
}
?>