-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeclock.php
129 lines (113 loc) · 4.05 KB
/
timeclock.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
<?php
/*
Plugin Name: Time Clock
Description: a time clock and seat reservation (desksharing) plugin for WordPress
Author: Scott Paterson and PBMod
Author URI: https://github.com/svenbolte/
Plugin URI: https://github.com/svenbolte/time-clock/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: etimeclockwp
Domain Path: /languages/
Version: 9.1.2.3.85
Stable tag: 9.1.2.3.85
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// define common variables
if (!defined('ETIMECLOCKWP_PLUGIN_PATH')) {
define('ETIMECLOCKWP_PLUGIN_PATH', plugin_dir_path(__FILE__));
}
if (!defined('ETIMECLOCKWP_PLUGIN_BASENAME')) {
define('ETIMECLOCKWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
}
if (!defined('ETIMECLOCKWP_SITE_URL')) {
define('ETIMECLOCKWP_SITE_URL', get_site_url());
}
if (!defined('ETIMECLOCKWP_NAME')) {
define('ETIMECLOCKWP_NAME', 'Time Clock');
}
if (!defined('ETIMECLOCKWP_VERSION')) {
define('ETIMECLOCKWP_VERSION', '9.1.2.1.62');
}
if (!defined('ETIMECLOCKWP_SETTINGS_PAGE')) {
define('ETIMECLOCKWP_SETTINGS_PAGE', 'etimeclockwp_settings_page');
}
// Load plugin textdomain.
function timeclock_load_textdomain() {
load_plugin_textdomain( 'etimeclockwp', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'timeclock_load_textdomain' );
// activate hook
function etimeclockwp_activation() {
global $wp_rewrite,$wpdb;
// activate includes
include_once ('includes/admin/post_types.php');
// register post types and taxonomies
etimeclockwp_register_post_type();
// save time that plugin was installed
add_option( 'etimeclockwp_install_date', date('Y-m-d G:i:s'), '', 'yes');
// creates raeume table in database if not exists
$table = $wpdb->prefix . "rooms";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS " . $table . " (
id int(11) not null auto_increment,
datum TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
raumname varchar(50) not null,
sitze int(4) not null,
PRIMARY KEY (`id`) ) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
// creates teilnehmer table in database if not exists
$table = $wpdb->prefix . "roombookings";
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS " . $table . " (
id int(11) not null auto_increment,
verandatum TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
raum int(4) not null,
sitz int(4) not null,
belegung varchar(30) not null,
PRIMARY KEY (`id`) ) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
// for debug truncate table
//$sql="TRUNCATE TABLE ".$table;
//$query = $wpdb->query($sql);
}
// deactivate hook
function etimeclockwp_deactivation() {
delete_option("etimeclockwp_firstrun");
}
// uninstall hook
function etimeclockwp_uninstall() {
// remove all plugin data if option is enabled
if (etimeclockwp_get_option('uninstall') == "1") {
etimeclockwp_uninstaller();
}
}
// register hooks
register_activation_hook(__FILE__,'etimeclockwp_activation');
register_deactivation_hook(__FILE__, 'etimeclockwp_deactivation');
register_uninstall_hook(__FILE__,'etimeclockwp_uninstall');
// public includes
include_once ('includes/admin/post_types.php');
include_once ('includes/settings/settings_api.php');
include_once ('includes/enqueue.php');
include_once ('includes/functions.php');
include_once ('includes/actions.php');
include_once ('includes/shortcodes.php');
// get settings
$etimeclockwp_options = etimeclockwp_get_options();
// admin includes
if (is_admin()) {
include_once ('includes/admin/menu.php');
include_once ('includes/admin/activity.php');
include_once ('includes/admin/users.php');
include_once ('includes/admin/menu.php');
include_once ('includes/admin/settings/settings_page.php');
include_once ('includes/admin/settings/settings_dashboard_items.php');
include_once ('includes/admin/ajax_functions_admin.php');
include_once ('includes/admin/uninstall.php');
}