-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettings.php
More file actions
157 lines (116 loc) · 3.91 KB
/
settings.php
File metadata and controls
157 lines (116 loc) · 3.91 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
<?php
function suptic_plugin_path( $path = '' ) {
return path_join( SUPTIC_PLUGIN_DIR, trim( $path, '/' ) );
}
function suptic_plugin_url( $path = '' ) {
return plugins_url( $path, SUPTIC_PLUGIN_BASENAME );
}
function suptic_db_table( $table_name ) {
global $wpdb;
$prefix = $wpdb->prefix;
if ( 'suptic_' != substr( $table_name, 0, 7 ) )
$table_name = 'suptic_' . $table_name;
return $prefix . trim( $table_name );
}
$suptic_form = null;
require_once SUPTIC_PLUGIN_DIR . '/includes/functions.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/formatting.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/pipe.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/shortcodes.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/classes.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/notifications.php';
require_once SUPTIC_PLUGIN_DIR . '/includes/controller.php';
if ( is_admin() ) {
require_once SUPTIC_PLUGIN_DIR . '/admin/install.php';
require_once SUPTIC_PLUGIN_DIR . '/admin/admin.php';
}
function suptic_admin_url( $file, $query = '' ) {
$file = trim( $file, ' /' );
if ( 'admin/' != substr( $file, 0, 6 ) )
$file = 'admin/' . $file;
$path = 'admin.php';
$path .= '?page=' . SUPTIC_PLUGIN_NAME . '/' . $file;
if ( $query = build_query( $query ) )
$path .= '&' . $query;
$url = admin_url( $path );
return $url;
}
function suptic_upload_dir( $type = false ) {
$siteurl = get_option( 'siteurl' );
$upload_path = trim( get_option( 'upload_path' ) );
if ( empty( $upload_path ) )
$dir = WP_CONTENT_DIR . '/uploads';
else
$dir = $upload_path;
$dir = path_join( ABSPATH, $dir );
if ( ! $url = get_option( 'upload_url_path' ) ) {
if ( empty( $upload_path ) || $upload_path == $dir )
$url = WP_CONTENT_URL . '/uploads';
else
$url = trailingslashit( $siteurl ) . $upload_path;
}
if ( defined( 'UPLOADS' ) ) {
$dir = ABSPATH . UPLOADS;
$url = trailingslashit( $siteurl ) . UPLOADS;
}
if ( 'dir' == $type )
return $dir;
if ( 'url' == $type )
return $url;
return array( 'dir' => $dir, 'url' => $url );
}
/* Loading modules */
add_action( 'plugins_loaded', 'suptic_load_modules', 1 );
function suptic_load_modules() {
$dir = SUPTIC_PLUGIN_MODULES_DIR;
if ( ! ( is_dir( $dir ) && $dh = opendir( $dir ) ) )
return false;
while ( ( $module = readdir( $dh ) ) !== false ) {
if ( substr( $module, -4 ) == '.php' )
include_once $dir . '/' . $module;
}
}
add_action( 'wp_head', 'suptic_head' );
function suptic_head() {
$stylesheet_url = suptic_plugin_url( 'styles.css' );
if ( SUPTIC_LOAD_CSS )
echo '<link rel="stylesheet" href="' . $stylesheet_url . '" type="text/css" />';
}
add_action( 'wp_print_scripts', 'suptic_enqueue_scripts' );
function suptic_enqueue_scripts() {
global $wpdb;
if ( is_admin() )
return;
$table = suptic_db_table( 'forms' );
$query = "SELECT DISTINCT page_id FROM $table ORDER BY page_id";
$form_pages = $wpdb->get_col( $query );
if ( SUPTIC_LOAD_JS && is_page( $form_pages ) ) {
$in_footer = true;
if ( 'header' === SUPTIC_LOAD_JS )
$in_footer = false;
wp_enqueue_script( 'suptic', suptic_plugin_url( 'scripts.js' ),
array( 'jquery', 'jquery-form' ), SUPTIC_VERSION, $in_footer );
}
}
/* L10N */
add_action( 'init', 'suptic_load_plugin_textdomain' );
function suptic_load_plugin_textdomain() {
load_plugin_textdomain( 'suptic',
'wp-content/plugins/' . SUPTIC_PLUGIN_NAME . '/languages',
SUPTIC_PLUGIN_NAME . '/languages' );
}
/* Capability */
function suptic_manage_forms_capability() {
return apply_filters( 'suptic_manage_forms_capability', SUPTIC_MANAGE_FORMS_CAPABILITY );
}
function suptic_you_can_manage_forms() {
return current_user_can( suptic_manage_forms_capability() );
}
function suptic_access_all_tickets_capability() {
return apply_filters( 'suptic_access_all_tickets_capability',
SUPTIC_ACCESS_ALL_TICKETS_CAPABILITY );
}
function suptic_you_can_access_all_tickets() {
return current_user_can( suptic_access_all_tickets_capability() );
}
?>