-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-checkin.php
81 lines (75 loc) · 1.77 KB
/
wp-checkin.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
<?php
/*
Plugin Name: WP Checkin
Plugin URI: https://github.com/jawordpressorg/wp-checkin
Description: A plugin for WordCamp Checkin.
Author: Fumiki Takahashi
Author URI: https://takahashifumiki.com
Text Domain: wp-checkin
Domain Path: /languages/
License: GPL v3 or later.
Version: nightly
*/
add_action( 'plugins_loaded', 'wp_checkin_init' );
/**
* Bootstrap
*
* @since 1.0.0
* @access private
*/
function wp_checkin_init() {
// i18n.
load_plugin_textdomain( 'wp-checkin', false, basename( dirname( __FILE__ ) ) . '/languages' );
// Load composer if exists.
require_once __DIR__ . '/vendor/autoload.php';
// Bootstrap plugins.
\WCTokyo\WpCheckin\Bootstrap::get_instance();
}
/**
* Get template part.
*
* @param string $name Relative path of template file on plugin root.
* @param array $args Optional arguments.
*
* @return void
*/
function wp_checkin_template( $name, $args = [] ) {
$path = __DIR__ . '/' . ltrim( $name, '/' );
if ( ! preg_match( '/\.php$/u', $path ) ) {
// If no extension, add .php.
$path .= '.php';
}
if ( ! file_exists( $path ) ) {
return;
}
load_template( $path, false, $args );
}
/**
* Get URL of plugin.
*
* @param string $path Relative path from plugin root.
*
* @return string
*/
function wp_checkin_url( $path = '' ) {
return plugins_url( $path, __FILE__ );
}
/**
* Get the name of ticket owner.
*
* @param array $ticket
* @return string
*/
function wp_checkin_ticket_owner( $ticket ) {
// translators: %1$s is first name, %2$s is last name.
return sprintf( _x( '%2$s %1$s', 'full-name', 'wp-checkin' ), $ticket[2], $ticket[3] );
}
/**
* Get ticket detail with key=value array.
*
* @param array $ticket
* @return array
*/
function wp_checkin_ticket_detail( $ticket ) {
return \WCTokyo\WpCheckin\Tickets::get_meta( $ticket );
}