| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: WP Map Block by aBlocks |
| 5 |
* Plugin URI: https://academylms.net/wp-map-block |
| 6 |
* Description: Gutenberg Map Block for Google Map and OpenStreet Map build with LeafletJS |
| 7 |
* Author: aBlocks - Most Powerful blocks Library |
| 8 |
* Author URI: https://ablocks.pro/ |
| 9 |
* Version: 2.0.3 |
| 10 |
* License: GPL2+ |
| 11 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt |
| 12 |
* Text Domain: wp-map-block |
| 13 |
* Domain Path: /languages/ |
| 14 |
*/ |
| 15 |
|
| 16 |
// Exit if accessed directly. |
| 17 |
if (!defined('ABSPATH')) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) { |
| 22 |
require_once dirname(__FILE__) . '/vendor/autoload.php'; |
| 23 |
} |
| 24 |
|
| 25 |
if (!class_exists('WPMapBlock')) { |
| 26 |
final class WPMapBlock |
| 27 |
{ |
| 28 |
private static $instances = []; |
| 29 |
protected function __construct() |
| 30 |
{ |
| 31 |
$this->define_constant(); |
| 32 |
register_activation_hook(__FILE__, [$this, 'activate']); |
| 33 |
$this->dispatch_hook(); |
| 34 |
} |
| 35 |
public function define_constant() |
| 36 |
{ |
| 37 |
/** |
| 38 |
* Defines CONSTANTS for Whole plugins. |
| 39 |
*/ |
| 40 |
define('WPMAPBLOCK_VERSION', '2.0.3'); |
| 41 |
define('WPMAPBLOCK_PLUGIN_FILE', __FILE__); |
| 42 |
define('WPMAPBLOCK_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
| 43 |
define('WPMAPBLOCK_PLUGIN_SLUG', 'wp-map-block'); |
| 44 |
define('WPMAPBLOCK_PLUGIN_ROOT_URI', plugins_url('/', __FILE__)); |
| 45 |
define('WPMAPBLOCK_ROOT_DIR_PATH', plugin_dir_path(__FILE__)); |
| 46 |
define('WPMAPBLOCK_ASSETS_DIR_PATH', WPMAPBLOCK_ROOT_DIR_PATH . 'assets/'); |
| 47 |
define('WPMAPBLOCK_ASSETS_URI', WPMAPBLOCK_PLUGIN_ROOT_URI . 'assets/'); |
| 48 |
} |
| 49 |
|
| 50 |
public function dispatch_hook() |
| 51 |
{ |
| 52 |
WPMapBlock\Assets::init(); |
| 53 |
WPMapBlock\Block::init(); |
| 54 |
WPMapBlock\Migration::init(); |
| 55 |
if(is_admin()){ |
| 56 |
WPMapBlock\Admin::init(); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
public function activate() |
| 62 |
{ |
| 63 |
WPMapBlock\Installer::init(); |
| 64 |
} |
| 65 |
|
| 66 |
protected function __clone() |
| 67 |
{ |
| 68 |
} |
| 69 |
|
| 70 |
public function __wakeup() |
| 71 |
{ |
| 72 |
throw new \Exception("Cannot unserialize singleton"); |
| 73 |
} |
| 74 |
|
| 75 |
public static function getInstance() |
| 76 |
{ |
| 77 |
$subclass = static::class; |
| 78 |
if (!isset(self::$instances[$subclass])) { |
| 79 |
self::$instances[$subclass] = new static(); |
| 80 |
} |
| 81 |
return self::$instances[$subclass]; |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Initializes the main plugin |
| 88 |
* |
| 89 |
* @return \WPMapBlcok |
| 90 |
*/ |
| 91 |
if (!function_exists('WPMapBlock_Start')) { |
| 92 |
function WPMapBlock_Start() |
| 93 |
{ |
| 94 |
return WPMapBlock::getInstance(); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
// Plugin Start |
| 99 |
WPMapBlock_Start(); |
| 100 |
|