-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmg-events.php
More file actions
110 lines (98 loc) · 2.71 KB
/
mg-events.php
File metadata and controls
110 lines (98 loc) · 2.71 KB
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
<?php
/**
* MgEvents
*
* @package Mindgruve Events
* @author kchevalier@mindgruve.com
* @version 1.0
*/
/*
Plugin Name: MG Events
Plugin URI: http://mindgruve.com/
Description: Manage events.
Author: kchevalier@mindgruve.com
Version: 1.0
Author URI: http://mindgruve.com/
*/
if (!class_exists('MgEvents')) {
class MgEvents
{
/**
*
* PROPERTIES
*
*/
public static $pluginName = "MG Events";
/**
*
* METHODS
*
*/
/**
* Init
*
* @return null
*/
public static function init()
{
require('MgEventsRequirements.php');
if (MgEventsRequirements::checkRequirements()) {
add_action('registered_post_type', array('MgEvents', 'load'));
add_action('widgets_init', array('MgEvents', 'registerWidgets'));
}
}
public static function load()
{
self::registerModels();
self::registerValidators();
}
/**
* Register Models
*
* @return null
*/
public static function registerModels()
{
if(!class_exists('MgEventModel')){
include('models/MgEventModel.php');
add_action('init', array('MgEventModel', 'init'));
}
do_action('register_wpml_sync_post_type', MgEventModel::$postType, MgEventModel::$multilanguageSyncFields, MgEventModel::$taxonomy);
}
/**
* Register Validators
*/
public static function registerValidators()
{
$validatorClasses = array();
$path = __DIR__ . '/validators/';
if (realpath($path) && is_readable(realpath($path))) {
$files = scandir($path);
if ($files) {
foreach ($files as $file) {
preg_match('/.+\.php$/', $file, $match);
if (!empty($match)) {
$validatorClasses[] = basename($match[0], '.php');
}
}
}
}
foreach ($validatorClasses as $validatorClass) {
if (!class_exists($validatorClass) && $validatorClass != '.svn') {
include("validators/$validatorClass.php");
}
}
}
/**
* Register Widgets
*
* @return null
*/
public static function registerWidgets()
{
include('widgets/MgListEventsWidget.php');
register_widget('MgListEventsWidget');
}
}
MgEvents::init();
}