-
Notifications
You must be signed in to change notification settings - Fork 1
/
tws-menu-framework.php
134 lines (124 loc) · 3.77 KB
/
tws-menu-framework.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Plugin Name: The Web Solver Admin Menu Framework
* Plugin URI: https://github.com/TheWebSolver/tws-menu-framework
* Description: <b>WordPress Admin Menu framework</b> to manage admin menus.
* Version: 1.1
* Author: Shesh Ghimire
* Author URI: https://www.linkedin.com/in/sheshgh/
* Requires at least: 5.3
* Requires PHP: 7.1
* Text Domain: tws-core
* License: GNU General Public License v3.0 (or later)
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt
*
* @package TheWebSolver\Core\Menu_Framework
*
* -----------------------------------
* DEVELOPED-MAINTAINED-SUPPPORTED BY
* -----------------------------------
* ███║ ███╗ ████████████████
* ███║ ███║ ═════════██████╗
* ███║ ███║ ╔══█████═╝
* ████████████║ ╚═█████
* ███║═════███║ █████╗
* ███║ ███║ █████═╝
* ███║ ███║ ████████████████╗
* ╚═╝ ╚═╝ ═══════════════╝
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* The Web Solver Custom Post Type Framework class
*
* @since 1.0
*/
final class HZFEX_Menu_Framework {
/**
* Creates an instance of this class.
*
* @since 1.0
*
* @static
*
* @access public
*
* @return HZFEX_Menu_Framework
*/
public static function activate(): HZFEX_Menu_Framework {
static $tws_menu;
if( ! is_a( $tws_menu, get_class() ) ) {
$tws_menu = new self();
$tws_menu->define_constants()->require_main_file();
}
return $tws_menu;
}
/**
* Define plugin constants.
*
* @return HZFEX_Menu_Framework
*
* @since 1.0
*
* @access public
*/
public function define_constants() {
// Define plugin textdomain.
// TWS Core plugin already defines it.
if( ! defined( 'HZFEX_TEXTDOMAIN' ) ) define( 'HZFEX_TEXTDOMAIN', 'tws-core' );
// Define plugin debug mode. DEBUG: set to true when needed.
// TWS Core plugin already defines it.
if( ! defined( 'HZFEX_DEBUG_MODE' ) ) define( 'HZFEX_DEBUG_MODE', true );
// Define constants.
define( 'HZFEX_MENU' , __( 'The Web Solver Admin Menu Framework' , HZFEX_TEXTDOMAIN ) );
define( 'HZFEX_MENU_FILE' , __FILE__ );
define( 'HZFEX_MENU_URL', plugin_dir_url( __FILE__ ) );
define( 'HZFEX_MENU_BASENAME', plugin_basename( __FILE__ ) );
define( 'HZFEX_MENU_PATH', plugin_dir_path( __FILE__ ) );
define( 'HZFEX_MENU_VERSION', '1.1' );
define( 'HZFEX_ADMIN_MENU', 'tws_dashboard' );
return $this;
}
/**
* Require main plugin file.
*
* @return HZFEX_Menu_Framework
*
* @since 1.0
*
* @access public
*/
public function require_main_file() {
require_once __DIR__ . '/Includes/Menu.php';
}
/**
* Initialize Plugin class.
*
* @return TheWebSolver\Core\Menu\Plugin
*
* @since 1.0
*
* @access public
*/
public function plugin(): TheWebSolver\Core\Menu\Plugin {
return TheWebSolver\Core\Menu\Plugin::boot();
}
/**
* Prevent direct instantiation.
*
* @since 1.0
*/
private function __construct() {}
}
/**
* Main function to instantiate HZFEX_Menu_Framework class.
*
* @return HZFEX_Menu_Framework
*
* @since 1.0
*/
function tws_menu(): HZFEX_Menu_Framework {
return HZFEX_Menu_Framework::activate();
}
// Initializes the plugin.
tws_menu()->plugin();