-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEditorHighlight.php
More file actions
58 lines (47 loc) · 997 Bytes
/
EditorHighlight.php
File metadata and controls
58 lines (47 loc) · 997 Bytes
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
<?php
namespace BrokenLinkDetector\Asset;
use BrokenLinkDetector\Asset\AssetRegistry;
class EditorHighlight extends AssetRegistry implements AssetInterface
{
public function shouldEnqueue(): bool
{
return true;
}
public function getHook(): string
{
return 'mce_external_plugins';
}
public function getHandle(): string
{
return 'broken-link-editor-highlight';
}
public function getDependencies(): array
{
return ['editor', 'jquery'];
}
public function getFilename(): string
{
return 'js/editor-highlight.js';
}
public function getLocalizeData(): ?array
{
if (!$this->registry || !$this->getPostid()) {
return [];
}
$links = $this->registry->getBrokenLinksByPostId(
$this->getPostid()
);
$links = array_column($links, 'url');
return [
'links' => $links,
];
}
/**
* Get the post id
*/
private function getPostid(): ?int
{
global $post;
return $post->ID ?? null;
}
}