-
Notifications
You must be signed in to change notification settings - Fork 0
/
nevamiss.php
107 lines (88 loc) · 2.37 KB
/
nevamiss.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
declare(strict_types=1);
/**
* Plugin Name: Nevamiss Auto Share
* Plugin URI: https://wordpress.org/plugins/nevamiss
* Description: A WordPress plugin to share content to social media Networks
* Author: Eliasu Abraman
* Text Domain: nevamiss
* Domain Path: /languages
* License: GPL v2 or later
* Requires PHP: 8.0
* Version: 1.0.0
*/
namespace Nevamiss;
use Exception;
use Inpsyde\Modularity\Package;
use Inpsyde\Modularity\Properties\PluginProperties;
use Nevamiss\Application\Application_Module;
use Nevamiss\Infrastructure\Infrastructure_Module;
use Nevamiss\Presentation\Presentation_Module;
use Nevamiss\Service\Factory_Module;
use Nevamiss\Service\Repositories_Module;
use Nevamiss\Services\Services_Module;
use Throwable;
defined( 'ABSPATH' ) || die( 'Not authorized' );
define( 'NEVAMISS_PATH', plugin_dir_path( __FILE__ ) );
define( 'NEVAMISS_URL', plugin_dir_url( __FILE__ ) );
define( 'NEVAMISS_ROOT', __FILE__ );
/**
* @throws Exception
*/
function autoload(): void {
if ( ! file_exists( NEVAMISS_PATH . '/vendor/autoload.php' ) ) {
throw new Exception( 'Autoload file can not be found' );
}
require_once NEVAMISS_PATH . '/vendor/autoload.php';
require_once NEVAMISS_PATH . '/functions.php';
}
function error_notice( string $message ): void {
foreach ( array( 'admin_notices', 'network_admin_notices' ) as $hook ) {
add_action(
$hook,
static function () use ( $message ) {
$class = 'notice notice-error';
printf(
'<div class="%1$s"><p>%2$s</p></div>',
esc_attr( $class ),
wp_kses_post( $message )
);
}
);
}
}
try {
autoload();
init();
} catch ( Exception $exception ) {
error_notice( $exception->getMessage() );
}
/**
* @throws Exception
* @throws Throwable
*/
function plugin(): Package {
static $package;
if ( ! $package ) {
$properties = PluginProperties::new( __FILE__ );
$package = Package::new( $properties );
$package->
addModule( new Application_Module() )->
addModule( new Repositories_Module() )->
addModule( new Presentation_Module() )->
addModule( new Services_Module() )->
addModule( new Factory_Module() )->
addModule(new Infrastructure_Module());
}
return $package;
}
add_action(
'plugins_loaded',
static function (): void {
try {
plugin()->boot();
} catch ( Throwable|\Exception $exception ) {
error_notice( $exception->getMessage() );
}
}
);