-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaro-events.php
87 lines (79 loc) · 1.77 KB
/
taro-events.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
<?php
/**
* Plugin Name: Taro Events
* Plugin URI: https://github.com/tarosky/taro-events
* Description: Add events feature to your WordPress site.
* Author: Tarosky INC.
* Version: 1.0.8
* Author URI: https://tarosky.co.jp/
* License: GPL3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: taro-events
* Domain Path: /languages
*/
defined( 'ABSPATH' ) or die();
/**
* Init plugins.
*/
function taro_events_init() {
// Register translations.
load_plugin_textdomain( 'taro-events', false, basename( __DIR__ ) . '/languages' );
// Load functions.
require_once __DIR__ . '/includes/functions.php';
// Require Bootstrap.
$autoload = __DIR__ . '/vendor/autoload.php';
if ( ! file_exists( $autoload ) ) {
trigger_error( __( 'Autoloader is missing. Did you ran composer install?', 'taro-events' ), E_USER_WARNING );
} else {
require $autoload;
\Tarosky\Events\Bootstrap::get_instance();
}
}
/**
* Get plugin base URL.
*
* @return string
*/
function taro_events_url() {
return untrailingslashit( plugin_dir_url( __FILE__ ) );
}
/**
* Get directory path.
*
* @return string
*/
function taro_events_dir() {
return __DIR__;
}
/**
* Get version.
*
* @return string
*/
function taro_events_version() {
static $version = null;
if ( is_null( $version ) ) {
$data = get_file_data( __FILE__, [
'version' => 'Version',
] );
$version = $data['version'];
}
return $version;
}
/**
* Get template dir
*
* @param string $file
*
* @return string
*/
function taro_events_template( $file ) {
$template_path = trailingslashit( __DIR__ . '/templates' ) . ltrim( $file, '/' );
if ( file_exists( $template_path ) ) {
return $template_path;
} else {
return '';
}
}
// Register hooks.
add_action( 'plugins_loaded', 'taro_events_init' );