-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp-map-block-forked.php
94 lines (81 loc) · 2.77 KB
/
wp-map-block-forked.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
<?php
/**
* Plugin Name: WP Map Block (Forked)
* Plugin URI: https://academylms.net/wp-map-block
* Description: Forked: Gutenberg Map Block for Google Map and OpenStreet Map build with LeafletJS
* Author: Academy LMS
* Author URI: https://academylms.net/
* Version: 1.4.2
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
*
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
require_once dirname(__FILE__) . '/vendor/autoload.php';
}
if (!class_exists('WPMapBlock')) {
final class WPMapBlock {
private static $instances = [];
protected function __construct() {
$this->define_constant();
register_activation_hook(__FILE__, [$this, 'activate']);
$this->dispatch_hook();
}
public function define_constant() {
/**
* Defines CONSTANTS for Whole plugins.
*/
define('WPMAPBLOCK_VERSION', '1.4.2');
define('WPMAPBLOCK_PLUGIN_FILE', __FILE__);
define('WPMAPBLOCK_PLUGIN_BASENAME', plugin_basename(__FILE__));
define('WPMAPBLOCK_PLUGIN_SLUG', 'wp-map-block-forked');
define('WPMAPBLOCK_PLUGIN_ROOT_URI', plugins_url('/', __FILE__));
define('WPMAPBLOCK_ROOT_DIR_PATH', plugin_dir_path(__FILE__));
define('WPMAPBLOCK_ASSETS_DIR_PATH', WPMAPBLOCK_ROOT_DIR_PATH . 'assets/');
define('WPMAPBLOCK_ASSETS_URI', WPMAPBLOCK_PLUGIN_ROOT_URI . 'assets/');
}
public function init_plugin() {
$this->load_textdomain();
}
public function dispatch_hook() {
add_action('init', [$this, 'init_plugin']);
WPMapBlock\Assets::init();
WPMapBlock\Block::init();
WPMapBlock\Migration::init();
}
public function load_textdomain() {
load_plugin_textdomain('wp-map-block-forked', false, dirname(WPMAPBLOCK_PLUGIN_BASENAME) . '/languages');
}
public function activate() {
WPMapBlock\Installer::init();
}
protected function __clone() {
}
public function __wakeup() {
throw new \Exception("Cannot unserialize singleton");
}
public static function getInstance() {
$subclass = static::class;
if (!isset(self::$instances[$subclass])) {
self::$instances[$subclass] = new static();
}
return self::$instances[$subclass];
}
}
}
/**
* Initializes the main plugin
*
* @return \WPMapBlcok
*/
if (!function_exists('WPMapBlock_Start')) {
function WPMapBlock_Start() {
return WPMapBlock::getInstance();
}
}
// Plugin Start
WPMapBlock_Start();