-
Notifications
You must be signed in to change notification settings - Fork 2
/
edje-wp-library.php
97 lines (75 loc) · 2.47 KB
/
edje-wp-library.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
<?php
/**
* Plugin Name: Edje WP Library
* Description: Simplify WordPress complicated functions. Designed to work with Edje Theme
* Plugin URI: http://github.com/hrsetyono/edje-wp-library
* Requires at least: 5.8
* Requires PHP: 7.3
* License: MIT
* Author: Pixel Studio
* Author URI: https://pixelstudio.id
* Version: 9.5.0
*/
if (!defined('WPINC')) { die; } // exit if accessed directly
// Constant
define('H_VERSION', '9.5.0');
define('H_BASE', basename(dirname(__FILE__)).'/'.basename(__FILE__));
define('H_DIR', __DIR__); // for require
define('H_URL', plugin_dir_url(__FILE__)); // for linking assets
define('H_DIST', plugin_dir_url(__FILE__) . '/dist');
if (!class_exists('Edje_WP_Library')):
require_once 'helper/_index.php';
require_once 'module-modify/_index.php';
require_once 'module-vendor/_index.php';
require_once 'module-post-type/_index.php';
require_once 'module-admin-sidenav/_index.php';
require_once 'module-comment/_index.php';
require_once 'module-widgets/_index.php';
require_once 'module-menu/_index.php';
require_once 'module-gutenberg/_index.php';
require_once 'module-block-faq/_index.php';
require_once 'module-block-icon/_index.php';
class Edje_WP_Library {
function __construct() {
require_once 'activation-hook.php';
register_activation_hook(H_BASE, [$this, 'register_activation_hook']);
add_filter('plugin_row_meta', [$this, 'add_doc_links'], 10, 2);
}
/**
* Register activation and deactivation hook
*/
function register_activation_hook() {
$hook = new H_ActivationHook();
$hook->on_activation();
}
/**
* Add "Documentation" link in the plugin listing (besides the Deactivate link)
*
* @action plugin_row_meta 10
*/
function add_doc_links($links, $file) {
if ($file === plugin_basename(__FILE__)) {
$links[] = '<a target="_blank" rel="noopener noreferrer" href="https://github.com/hrsetyono/edje-wp-library/wiki/"> View Documentation » </a>';
}
return $links;
}
}
new Edje_WP_Library();
endif;
/////
if (!class_exists('H')):
/**
* Alternate way to call Edje functions from each module's `_load.php`
* Example: to call `h_register_post_type()`, we can use `H::register_post_type()`
*/
class H {
static function __callStatic($name, $args) {
$func_name = "h_$name";
if (is_callable($func_name)) {
return call_user_func_array($func_name, $args);
} else {
trigger_error("The function H::$name does not exist.", E_USER_ERROR);
}
}
}
endif; // class_exists