/
wp-event-schedule.php
145 lines (121 loc) · 3.9 KB
/
wp-event-schedule.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
135
136
137
138
139
140
141
142
143
144
145
<?php
/*
Plugin Name: WP Event Schedule
Plugin URI: http://wordpress.org/plugins/wp-event-schedule/
Description: Create the event schedule.
Author: Yoshika (@rnsk)
Author URI: http://rnsk.net/
Version: 0.9.2
License: GPL2
License URI: license.txt
Text Domain: wpes
Domain Path: /lang/
*/
namespace WPES;
if (!defined('ABSPATH')) exit;
date_default_timezone_set(get_option('timezone_string'));
/**
* プラグイン定数設定
*/
const VERSION = '1.0';
//const DB_VERSION = '1.0';
const POST_TYPE = 'wpes';
const PLUGIN_DIR = 'wp-event-schedule';
const CLASS_DIR = 'classes';
const TEMPLATE_DIR = 'templates';
const WIDGET_DIR = 'widgets';
const CSS_DIR = 'css';
const JS_DIR = 'js';
const DS = DIRECTORY_SEPARATOR;
// 外部ファイル読み込み
require_once dirname(__FILE__) . DS . 'wpes-admin.class.php';
require_once dirname(__FILE__) . DS . 'wpes-output.class.php';
require_once dirname(__FILE__) . DS . 'wpes-shortcode.class.php';
require_once dirname(__FILE__) . DS . 'wpes-posttype.class.php';
require_once dirname(__FILE__) . DS . 'wpes-template.class.php';
require_once dirname(__FILE__) . DS . WIDGET_DIR . DS . 'wpes-widget.php';
/**
* 行事予定を作成するプラグイン
*
* @copyright Copyright (c) Yoshika
* @author Yoshika (@rnsk)
* @package EventSchedule
* @license GPL2
*/
class EventSchedule
{
/**
* クラスの初期化
*/
public static function _init() {
static $instance = false;
if (!$instance) {
ob_start();
$instance = new EventSchedule;
}
return $instance;
}
/**
* Constructor.
*/
protected function __construct() {
session_start();
// プラグイン有効時の処理
register_activation_hook(__FILE__, array(&$this, 'plugin_active'));
// プラグイン無効時の処理
register_deactivation_hook(__FILE__, array(&$this, 'plugin_deactive'));
// プラグイン用翻訳ファイル読み込み
//load_plugin_textdomain('wpfb', false, WP_PLUGIN_DIR . DS . PLUGIN_DIR . DS . 'lang');
// CSS & JS
add_action('wp_print_styles', array(&$this, 'event_style'));
add_action('admin_print_styles', array(&$this, 'admin_event_style'));
add_action('admin_footer', array(&$this, 'admin_event_script'));
}
/**
* プラグイン有効時の処理
*/
function plugin_active() {
add_option('wpes_version', VERSION);
}
/**
* プラグイン無効時の処理
*/
function plugin_deactive() {
delete_option('wpes_version');
}
/**
* フロントCSS読み込み
*/
function event_style() {
wp_enqueue_style('wpes', WP_PLUGIN_URL . DS . PLUGIN_DIR . DS . CSS_DIR . DS . 'wpes.css');
if (file_exists(TEMPLATEPATH . DS . 'wpes.css')) {
$template_uri = get_template_directory_uri();
wp_enqueue_style('wpes_overwrite', $template_uri . DS . 'wpes.css');
}
}
/**
* 管理画面CSS読み込み
*/
function admin_event_style() {
global $post_type;
if ($post_type == POST_TYPE) {
wp_enqueue_style('wpes_jquery-ui-custom', WP_PLUGIN_URL . DS . PLUGIN_DIR . DS . CSS_DIR . DS . 'smoothness' . DS . 'jquery-ui-1.10.3.custom.min.css');
wp_enqueue_style('wpes_jquery-ui-timepicker', WP_PLUGIN_URL . DS . PLUGIN_DIR . DS . CSS_DIR . DS . 'jquery-ui-timepicker-addon.css');
}
}
/**
* 管理画面JS読み込み
*/
function admin_event_script() {
global $post_type;
if ($post_type == POST_TYPE) {
wp_enqueue_script('wpes_jquery-ui-timepicker', WP_PLUGIN_URL . DS . PLUGIN_DIR . DS . JS_DIR . DS . 'jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker'));
wp_enqueue_script('wpes_common', WP_PLUGIN_URL . DS . PLUGIN_DIR . DS . JS_DIR . DS . 'common.js');
}
}
}
EventSchedule::_init();
Admin::_init();
Shortcode::_init();
PostType::_init();
$WPES = new TemplateTag;