-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultisiteContentCopier.php
More file actions
76 lines (64 loc) · 2.02 KB
/
MultisiteContentCopier.php
File metadata and controls
76 lines (64 loc) · 2.02 KB
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
<?php
namespace MultisiteContentCopier;
use Monolog\Logger;
use MultisiteContentCopier\Common\DependencyContainer;
use MultisiteContentCopier\Controllers\ContentCopierController;
use MultisiteContentCopier\Controllers\SettingsController;
use MultisiteContentCopier\Exceptions\DependencyNotFoundException;
if ( ! defined( 'WPINC' ) ) {
die();
}
/**
* Class MultisiteContentCopier
*
* Plugin Name: Multisite Content Copier
* Plugin URI: https://github.com/AlexSBlackburn/MultisiteContentCopier
* Description: Allows quick and easy duplication of main site content to a newly created sub-site
* Version: 0.1.4
* Author: Alex Blackburn
* License: MIT License
*
* @package MultisiteContentCopier
*/
class MultisiteContentCopier {
private $logger;
/**
* MultisiteContentCopier constructor
*/
public function __construct() {
if ( is_multisite() && is_admin() ) {
include_once 'functions.php';
include_once 'vendor/autoload.php';
try {
$this->logger = $this->get_logger();
add_action( 'plugins_loaded', [ $this, 'setup' ] );
} catch ( DependencyNotFoundException $e ) {
die( 'Dependency not found error: ' . $e->getMessage() );
}
}
}
/**
* @return Logger
*
* @throws DependencyNotFoundException
*/
private function get_logger(): Logger {
return DependencyContainer::get( Logger::class );
}
/**
* Setup plugin once loaded
*
* @throws DependencyNotFoundException
* @throws Exceptions\DatabaseServiceException
*/
public function setup() {
$result = '';
if ( isset( $_POST['rk_wp_copy_content'] ) && isset( $_POST['site_from'] ) && isset( $_POST['sites_to'] ) ) {
$this->logger->debug( 'Form submit detected.' );
$result = true;
new ContentCopierController( $this->logger );
}
new SettingsController( $this->logger, $result );
}
}
new MultisiteContentCopier();