-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathticketmanager.php
109 lines (90 loc) · 2.97 KB
/
ticketmanager.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
<?php
/*
Plugin Name: Ticket Manager
Description: Ticket manager is a plugin that allows you to sell all types of tickets ranging from different social events to bus tickets
Version: 1.0
Author: Rixeo
Author URI: http://thebunch.co.ke/
Plugin URI: http://thebunch.co.ke/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'Ticket_Manager' ) ) :
class Ticket_Manager{
/**
* Version
* @var string
*/
public $version = '1.0';
/**
* @var The single instance of the class
* @since 2.1
*/
protected static $_instance = null;
//Get instance
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct() {
$this->define_constants();
$this->load_includes();
$this->init_hooks();
}
private function define_constants(){
$upload_dir = wp_upload_dir();
$this->define( 'TCM_PLUGIN_FILE', __FILE__ );
$this->define( 'TCM_PLUGIN_URL', plugin_dir_url( __FILE__ ) . 'ticketmanager/');
$this->define( 'TCM_PLUGIN_RESOURCES_URL', TCM_PLUGIN_URL . 'resources/');
$this->define( 'TCM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) . 'ticketmanager/');
$this->define( 'TCM_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
$this->define( 'TCM_VERSION', $this->version );
$this->define( 'TCM_FILE_DIR', $upload_dir['basedir'] . '/ticketmanager/' );
}
/**
* Define constant if not already set
* @param string $name
* @param string|bool $value
*/
private function define( $name, $value ) {
if ( ! defined( $name ) ) {
define( $name, $value );
}
}
private function load_includes(){
include_once( TCM_PLUGIN_DIR.'includes/tcm-core.php' );
}
private function init_hooks() {
add_action( 'init', array( $this, 'init' ), 0 );
TCM_Core::init();
}
/**
* Load Localisation files.
*
* Locales are found in:
* - ticketmanager/languages/ticketmanager-LOCALE.mo (which if not found falls back to:)
* - WP_LANG_DIR/ticketmanager/ticketmanager-LOCALE.mo
*
*/
public function load_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'ticketmanager' );
load_textdomain( 'ticketmanager', WP_LANG_DIR . '/ticketmanager/ticketmanager-' . $locale . '.mo' );
load_plugin_textdomain( 'ticketmanager', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages" );
}
public function init() {
// Set up localisation
$this->load_textdomain();
}
}
Ticket_Manager::instance();
else:
function ticket_manager_error_notice() {
$message = __("Another plugin already using the class name Ticket_Manager exists. The Ticket Manager plugin will not work as expected");
echo"<div class='error'> <p>$message</p></div>";
}
add_action( 'admin_notices', 'ticket_manager_error_notice' );
endif;
?>