-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
115 lines (79 loc) · 2.04 KB
/
index.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
<?php
/**
* This file contains all the plugin's boilerplate functions
*
* Plugin Name: WP Plugin Boilerplate
* Description: A simple boilerplate for a WordPress plugin
* Text Domain: wppb
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Plugin URI: https://ahmadkarim.com/wordpress-plugins/wp-plugin-boilerplate/
* Author URI: https://ahmadkarim.com/
* License: GPL-2.0+
* Version: 1.0.0
* Author: Ahmad Karim
* Prefix: wppb
* GitHub URI: ahmu83/wp-plugin-boilerplate
*/
if (!defined('WPINC')) die;
register_activation_hook(__FILE__, 'wppb_activation');
register_deactivation_hook(__FILE__, 'wppb_deactivation');
/**
* Get this plugin URL
*
* @param boolean | string $append • Append to url
* @return string
*/
function wppb_url($append = false) {
return plugin_dir_url(__FILE__) . $append;
}
/**
* Get this plugin directory path
*
* @param boolean | string $append • Append to the directory path
* @return string
*/
function wppb_dir($append = false) {
return plugin_dir_path(__FILE__) . $append;
}
/**
* Include a file
*
* @param string $inc • file path
* @param array $args • Variables to be available on the file
* @return null
*/
function wppb_inc($inc, $args = array()) {
if( is_array($args) && count($args) > 0 ) {
extract($args);
}
include_once $inc;
}
/**
* Render a simple PHP view
*
* @param string $view • View file name
* @param array $args • Variables to be available on the view file
* @return null
*/
function wppb_view($view, $args = array()) {
$settings = wppb_settings();
if( is_array($args) && count($args) > 0 ) {
extract($args);
}
$views_dir = $settings['views_dir'];
include_once wppb_dir("/{$views_dir}/{$view}");
}
/**
* Get this plugin settings
*
* @return array
*/
function wppb_settings() {
$settings = include 'settings.php';
$settings['plugin_data'] = get_plugin_data(__FILE__);
return $settings;
}
$includes = include_once 'includes.php';
foreach ($includes as $include) {
include_once wppb_dir($include);
}