-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-checking.php
More file actions
106 lines (94 loc) · 4.29 KB
/
error-checking.php
File metadata and controls
106 lines (94 loc) · 4.29 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
<?php
#########################################################################################
#
# Copyright 2010-2011 Maya Studios (http://www.mayastudios.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################################
MSCL_Api::load(MSCL_Api::OPTIONS_API);
class BlogTextErrorNotifier extends MSCL_ErrorNotifier {
private static function in_editor_interface($including_overview=true) {
if ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php')
|| strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php')) {
return true;
}
if ($including_overview && strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php')) {
return true;
}
return false;
}
/**
* Checks for warnings that concern only editors (ie. users that can publish and edit posts).
*
* @return array|string|null Returns the warning message(s) for the errors that have been found. If there's
* only one, its returned as string. Multiple warning messages will be returned as array of strings. If no
* warnings are found, returns "null" or an empty array.
*/
protected function check_for_editor_warnings() {
// check for problematic editor settings; only display in the backend.
$warnings = array();
if (self::is_in_backend()) {
if (MSCL_BoolOption::is_true(get_user_option('rich_editing')) && self::in_editor_interface()) {
// we're in the editing interface for posts or pages; display the HTML editor warning
$warnings[] = "<b>Warning:</b> The <em>visual editor</em> is enabled. Don't use it to edit your "
. "BlogText postings as this may result in problems. You can disable it in your "
. "<a href=\"".get_admin_url(null, 'profile.php')."\">user settings</a>.";
}
}
return $warnings;
}
/**
* Checks for warnings that concern only admin (ie. users that can manage the blog's options).
*
* @return array|string|null Returns the warning message(s) for the errors that have been found. If there's
* only one, its returned as string. Multiple warning messages will be returned as array of strings. If no
* warnings are found, returns "null" or an empty array.
*/
protected function check_for_admin_warnings() {
if ( self::is_in_backend()
&& !BlogTextSettings::disable_fix_invalid_xhtml_warning()
&& MSCL_BoolOption::is_true(get_option('use_balanceTags'))) {
return "<b>Warning:</b> You should disable the option which tells Wordpress to correct <em>invalidly "
. "nested XHTML automatically</em>. You can do this in "
. "<a href=\"".get_admin_url(null, 'options-writing.php')."\">Writing Settings</a>.";
}
return null;
}
/**
* Checks for errors that concern only admin (ie. users that can manage the blog's options).
*
* @return array|string|null Returns the error message(s) for the errors that have been found. If there's
* only one, its returned as string. Multiple error messages will be returned as array of strings. If no
* errors are found, returns "null" or an empty array.
*/
protected function check_for_admin_errors() {
//
// check for thumbnail cache directory errors
//
MSCL_Api::load(MSCL_Api::THUMBNAIL_API);
$error_msg = array();
try {
// check whether the cache directories could be created
if ( !is_writable(MSCL_ThumbnailCache::get_local_file_cache_dir())
|| !is_writable(MSCL_ThumbnailCache::get_remote_file_cache_dir())) {
$error_msg[] = "Thumbnail cache directory is not writable.";
}
} catch (MSCL_AdminException $e) {
$error_msg[] = $e->getMessage();
}
return $error_msg;
}
}
?>