-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbroken-link-detector.php
91 lines (78 loc) · 2.44 KB
/
broken-link-detector.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Plugin Name: Broken Link Detector
* Description: Detects and fixes (if possible) broken links in post_content
* Version: 4.2.7
* Author: Sebastian Thulin
* License: MIT
* License URI: https://opensource.org/licenses/MIT
* Text Domain: broken-link-detector
* Domain Path: /languages
*/
use AcfService\Implementations\NativeAcfService;
use WpService\Implementations\NativeWpService;
use BrokenLinkDetector\Database\Database;
use BrokenLinkDetector\Config\Config;
use BrokenLinkDetector\BrokenLinkRegistry\Registry\ManageRegistry;
use BrokenLinkDetector\Cli\CommandRunner;
/* Assets */
use WpService\FileSystem\BaseFileSystem;
use WpService\FileSystemResolvers\ManifestFilePathResolver;
use WpService\FileSystemResolvers\UrlFilePathResolver;
use WpService\Implementations\FilePathResolvingWpService;
use WpService\Implementations\WpServiceLazyDecorator;
use WpService\Implementations\WpServiceWithTextDomain;
/**
* If this file is called directly, abort.
*/
if (! defined('WPINC')) {
die;
}
/**
* Autoload plugin classes, if dependencies are installed.
*/
try {
require_once __DIR__ . '/vendor/autoload.php';
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
/**
* Bootstrap the plugin
*/
$wpService = new NativeWpService();
$manifestFileWpService = new WpServiceLazyDecorator();
$urlFilePathResolver = new UrlFilePathResolver($manifestFileWpService);
$baseFileSystem = new BaseFileSystem();
$acfService = new NativeAcfService();
$config = new Config(
$wpService,
$acfService,
'BrokenLinkDetector/Config',
$wpService->pluginDirPath(__FILE__),
$wpService->pluginsUrl('', __FILE__)
);
$manifestFilePathResolver = new ManifestFilePathResolver(
$config->getPluginPath() . "dist/manifest.json",
$baseFileSystem,
$manifestFileWpService,
$urlFilePathResolver
);
$wpService = new FilePathResolvingWpService(
new NativeWpService(),
$manifestFilePathResolver
);
$manifestFileWpService->setInner(new WpServiceWithTextDomain($wpService, $config->getTextDomain()));
$database = new Database($config, $wpService);
$registry = new ManageRegistry($database, $config);
$cliRunner = new CommandRunner($wpService, $config);
/**
* Run the plugin
*/
$brokenLinkDetectorApp = new BrokenLinkDetector\App(
$manifestFileWpService,
$acfService,
$database,
$registry,
$config,
$cliRunner
);