-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplugin.php
76 lines (66 loc) · 2.05 KB
/
plugin.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
<?php
use WordPressPluginBoilerplate\Core\Api;
use WordPressPluginBoilerplate\Admin\Menu;
use WordPressPluginBoilerplate\Core\Template;
use WordPressPluginBoilerplate\Assets\Frontend;
use WordPressPluginBoilerplate\Assets\Admin;
use WordPressPluginBoilerplate\Traits\Base;
defined( 'ABSPATH' ) || exit;
/**
* Class WordPressPluginBoilerplate
*
* The main class for the Coldmailar plugin, responsible for initialization and setup.
*
* @since 1.0.0
*/
final class WordPressPluginBoilerplate {
use Base;
/**
* Class constructor to set up constants for the plugin.
*
* @since 1.0.0
* @return void
*/
public function __construct() {
define( 'WORDPRESS_PLUGIN_BOILERPLATE_VERSION', '1.0.0' );
define( 'WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_FILE', __FILE__ );
define( 'WORDPRESS_PLUGIN_BOILERPLATE_DIR', plugin_dir_path( __FILE__ ) );
define( 'WORDPRESS_PLUGIN_BOILERPLATE_URL', plugin_dir_url( __FILE__ ) );
define( 'WORDPRESS_PLUGIN_BOILERPLATE_ASSETS_URL', WORDPRESS_PLUGIN_BOILERPLATE_URL . '/assets' );
define( 'WORDPRESS_PLUGIN_BOILERPLATE_ROUTE_PREFIX', 'wordpress-plugin-boilerplate/v1' );
}
/**
* Main execution point where the plugin will fire up.
*
* Initializes necessary components for both admin and frontend.
*
* @since 1.0.0
* @return void
*/
public function init() {
if ( is_admin() ) {
Menu::get_instance()->init();
Admin::get_instance()->bootstrap();
}
// Initialze core functionalities.
Frontend::get_instance()->bootstrap();
API::get_instance()->init();
Template::get_instance()->init();
add_action( 'init', array( $this, 'i18n' ) );
add_action( 'init', array( $this, 'register_blocks' ) );
}
public function register_blocks() {
register_block_type( __DIR__ . '/assets/blocks/block-1' );
}
/**
* Internationalization setup for language translations.
*
* Loads the plugin text domain for localization.
*
* @since 1.0.0
* @return void
*/
public function i18n() {
load_plugin_textdomain( 'wordpress-plugin-boilerplate', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}