-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
executable file
·56 lines (46 loc) · 1.57 KB
/
init.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
<?php
require (__DIR__ . '/includes/sputnik.php');
require(__DIR__ . '/vendor/autoload.php');
add_action('admin_enqueue_scripts', function () {
wp_register_script('sputnik.js', plugin_dir_url(__FILE__) . 'js/sputnik.js', ['jquery']);
wp_enqueue_script('sputnik.js');
});
ob_start();
session_start();
//Incluye las clases basicas
require_once __DIR__ . '/includes/sputnik.php';
require_once __DIR__ . '/includes/baseModel.php';
require_once __DIR__ . '/includes/baseController.php';
require_once __DIR__ . '/includes/baseRestController.php';
require_once __DIR__ . '/includes/baseWidget.php';
require_once __DIR__ . '/includes/baseActiveModel.php';
add_action('init', function() {
global $sputnik;
$sputnik = new sputnik();
$sputnik->debug = true;
if ($sputnik->debug) {
global $wpdb;
$wpdb->show_errors();
}
});
add_action('rest_api_init', function() {
$restControllers = sputnik::getFiles('rest');
global $sputnik;
foreach ($restControllers as $restController) {
$classname = basename($restController, '.php');
$$classname = new $classname();
$$classname->init('sputnik');
}
});
add_action('widgets_init', function() {
sputnik::includeDir('widgets/widgets');
$widgets = sputnik::getFiles('widgets/widgets');
foreach ($widgets as $widget) {
if ($widget == 'index.html') {
continue;
}
register_widget(basename($widget, '.php'));
}
});
register_activation_hook(__FILE__, ['sputnik', 'install']);
register_deactivation_hook(__FILE__, ['sputnik', 'uninstall']);