Theme Check - Version 20150818.1

Version Description

Download this release

Release Info

Developer Otto42
Plugin Icon 128x128 Theme Check
Version 20150818.1
Comparing to
See all releases

Version 20150818.1

assets/gray-grad.png ADDED
Binary file
assets/style.css ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .tc-box {
2
+ padding:20px 0;
3
+ border-top:1px solid #dfdfdf;
4
+ }
5
+ .tc-warning, .tc-required, .tc-fail {
6
+ color:red;
7
+ }
8
+ .tc-recommended, .tc-pass {
9
+ color: green;
10
+ }
11
+ .tc-info {
12
+ color: blue;
13
+ }
14
+ .tc-grep span {
15
+ background: yellow;
16
+ }
17
+ pre {
18
+ white-space: pre-wrap;
19
+ }
20
+ .tc-success {
21
+ margin:0 20px 20px 20px;
22
+ background:#e6ffe2;
23
+ border:1px solid #d1eecc;
24
+ }
25
+ form {
26
+ margin:20px auto;
27
+ }
28
+ .theme-check {
29
+ margin:20px auto;
30
+ border:1px solid #dfdfdf;
31
+ -moz-border-radius:5px;
32
+ -khtml-border-radius:5px;
33
+ -webkit-border-radius:5px;
34
+ border-radius:5px;
35
+ }
36
+ .theme-check h2 {
37
+ margin:0 0 20px 0;
38
+ padding:0 20px;
39
+ background:#dfdfdf url("gray-grad.png") repeat-x left top;
40
+ font-size:20px;
41
+ border-bottom:1px solid #ccc;
42
+ }
43
+ .theme-check p {
44
+ padding:5px 20px;
45
+ }
46
+ .theme-check form {
47
+ margin-left:20px;
48
+ }
49
+ .theme-check ul {
50
+ margin-left:20px;
51
+ }
52
+ .theme-check h3 {
53
+ margin:0 0 10px 20px;
54
+ padding:0;
55
+ }
56
+ .theme-check ul {
57
+ margin-bottom:10px;
58
+ }
59
+ .theme-info {
60
+ padding:10px;
61
+ border:1px solid #dfdfdf;
62
+ margin:10px 20px 0 20px;
63
+ }
64
+ .theme-info p {
65
+ padding:0;
66
+ margin-bottom:10px;
67
+ }
68
+ .theme-info label {
69
+ float:left;
70
+ width:100px;
71
+ font-weight:bold;
72
+ display:block;
73
+ }
74
+ .theme-info span.info {
75
+ margin-left:100px;
76
+ display:block;
77
+ }
checkbase.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // main global to hold our checks
3
+ global $themechecks;
4
+ $themechecks = array();
5
+
6
+ // counter for the checks
7
+ global $checkcount;
8
+ $checkcount = 0;
9
+
10
+ // interface that all checks should implement
11
+ interface themecheck
12
+ {
13
+ // should return true for good/okay/acceptable, false for bad/not-okay/unacceptable
14
+ public function check( $php_files, $css_files, $other_files );
15
+
16
+ // should return an array of strings explaining any problems found
17
+ public function getError();
18
+ }
19
+
20
+ // load all the checks in the checks directory
21
+ $dir = 'checks';
22
+ foreach (glob(dirname(__FILE__). "/{$dir}/*.php") as $file) {
23
+ include $file;
24
+ }
25
+
26
+ do_action('themecheck_checks_loaded');
27
+
28
+ function run_themechecks($php, $css, $other) {
29
+ global $themechecks;
30
+ $pass = true;
31
+ foreach($themechecks as $check) {
32
+ if ($check instanceof themecheck) {
33
+ $pass = $pass & $check->check($php, $css, $other);
34
+ }
35
+ }
36
+ return $pass;
37
+ }
38
+
39
+ function display_themechecks() {
40
+ $results = '';
41
+ global $themechecks;
42
+ $errors = array();
43
+ foreach ($themechecks as $check) {
44
+ if ($check instanceof themecheck) {
45
+ $error = $check->getError();
46
+ $error = (array) $error;
47
+ if (!empty($error)) {
48
+ $errors = array_unique( array_merge( $error, $errors ) );
49
+ }
50
+ }
51
+ }
52
+ if (!empty($errors)) {
53
+ rsort($errors);
54
+ foreach ($errors as $e) {
55
+
56
+ if ( defined( 'TC_TRAC' ) ) {
57
+ $results .= ( isset( $_POST['s_info'] ) && preg_match( '/INFO/', $e ) ) ? '' : '* ' . tc_trac( $e ) . "\r\n";
58
+ } else {
59
+ $results .= ( isset( $_POST['s_info'] ) && preg_match( '/INFO/', $e ) ) ? '' : '<li>' . tc_trac( $e ) . '</li>';
60
+ }
61
+ }
62
+ }
63
+
64
+ if ( defined( 'TC_TRAC' ) ) {
65
+
66
+ if ( defined( 'TC_PRE' ) ) $results = TC_PRE . $results;
67
+ $results = '<textarea cols=140 rows=20>' . strip_tags( $results );
68
+ if ( defined( 'TC_POST' ) ) $results = $results . TC_POST;
69
+ $results .= '</textarea>';
70
+ }
71
+ return $results;
72
+ }
73
+
74
+ function checkcount() {
75
+ global $checkcount;
76
+ $checkcount++;
77
+ }
78
+
79
+ // some functions theme checks use
80
+ function tc_grep( $error, $file ) {
81
+ if ( ! file_exists( $file ) ) {
82
+ return '';
83
+ }
84
+ $lines = file( $file, FILE_IGNORE_NEW_LINES ); // Read the theme file into an array
85
+ $line_index = 0;
86
+ $bad_lines = '';
87
+ foreach( $lines as $this_line ) {
88
+ if ( stristr ( $this_line, $error ) ) {
89
+ $error = str_replace( '"', "'", $error );
90
+ $this_line = str_replace( '"', "'", $this_line );
91
+ $error = ltrim( $error );
92
+ $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE );
93
+ $pre = ltrim( htmlspecialchars( $pre ) );
94
+ $bad_lines .= "<pre class='tc-grep'>". __("Line ", "theme-check") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . "</pre>";
95
+ }
96
+ $line_index++;
97
+ }
98
+ return str_replace( $error, '<span class="tc-grep">' . $error . '</span>', $bad_lines );
99
+ }
100
+
101
+ function tc_preg( $preg, $file ) {
102
+ if ( ! file_exists( $file ) ) {
103
+ return '';
104
+ }
105
+ $lines = file( $file, FILE_IGNORE_NEW_LINES ); // Read the theme file into an array
106
+ $line_index = 0;
107
+ $bad_lines = '';
108
+ $error = '';
109
+ foreach( $lines as $this_line ) {
110
+ if ( preg_match( $preg, $this_line, $matches ) ) {
111
+ $error = $matches[0];
112
+ $this_line = str_replace( '"', "'", $this_line );
113
+ $error = ltrim( $error );
114
+ $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE );
115
+ $pre = ltrim( htmlspecialchars( $pre ) );
116
+ $bad_lines .= "<pre class='tc-grep'>" . __("Line ", "theme-check") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . "</pre>";
117
+ }
118
+ $line_index++;
119
+
120
+ }
121
+ return str_replace( $error, '<span class="tc-grep">' . $error . '</span>', $bad_lines );
122
+ }
123
+
124
+ function tc_strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
125
+ if(strrpos($haystack, $needle)){
126
+ //Everything before last $needle in $haystack.
127
+ $left = substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive);
128
+ //Switch value of $r_inclusive from 0 to 1 and viceversa.
129
+ $r_inclusive = ($r_inclusive == 0) ? 1 : 0;
130
+ //Everything after last $needle in $haystack.
131
+ $right = substr(strrchr($haystack, $needle), $r_inclusive);
132
+ //Return $left and $right into an array.
133
+ return array($left, $right);
134
+ } else {
135
+ if(strrchr($haystack, $needle)) return array('', substr(strrchr($haystack, $needle), $r_inclusive));
136
+ else return false;
137
+ }
138
+ }
139
+
140
+ function tc_filename( $file ) {
141
+ $filename = ( preg_match( '/themes\/[a-z0-9]*\/(.*)/', $file, $out ) ) ? $out[1] : basename( $file );
142
+ return $filename;
143
+ }
144
+
145
+ function tc_trac( $e ) {
146
+ $trac_left = array( '<strong>', '</strong>' );
147
+ $trac_right= array( "'''", "'''" );
148
+ $html_link = '/<a\s?href\s?=\s?[\'|"]([^"|\']*)[\'|"]>([^<]*)<\/a>/i';
149
+ $html_new = '[$1 $2]';
150
+ if ( defined( 'TC_TRAC' ) ) {
151
+ $e = preg_replace( $html_link, $html_new, $e );
152
+ $e = str_replace( $trac_left, $trac_right, $e );
153
+ $e = preg_replace( '/<pre.*?>/', "\r\n{{{\r\n", $e );
154
+ $e = str_replace( '</pre>', "\r\n}}}\r\n", $e );
155
+ }
156
+ return $e;
157
+ }
158
+
159
+ function listdir( $dir ) {
160
+ $files = array();
161
+ $dir_iterator = new RecursiveDirectoryIterator( $dir );
162
+ $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
163
+
164
+ foreach ($iterator as $file) {
165
+ array_push( $files, $file->getPathname() );
166
+ }
167
+ return $files;
168
+ }
169
+
170
+ function old_listdir( $start_dir='.' ) {
171
+ $files = array();
172
+ if ( is_dir( $start_dir ) ) {
173
+ $fh = opendir( $start_dir );
174
+ while ( ( $file = readdir( $fh ) ) !== false ) {
175
+ # loop through the files, skipping . and .., and recursing if necessary
176
+ if ( strcmp( $file, '.' )==0 || strcmp( $file, '..' )==0 ) continue;
177
+ $filepath = $start_dir . '/' . $file;
178
+ if ( is_dir( $filepath ) )
179
+ $files = array_merge( $files, listdir( $filepath ) );
180
+ else
181
+ array_push( $files, $filepath );
182
+ }
183
+ closedir( $fh );
184
+
185
+ } else {
186
+
187
+ # false if the function was called with an invalid non-directory argument
188
+ $files = false;
189
+ }
190
+ return $files;
191
+ }
192
+
193
+ function tc_print_r( $data ) {
194
+ $out = "\n<pre class='html-print-r'";
195
+ $out .= " style='border: 1px solid #ccc; padding: 7px;'>\n";
196
+ $out .= esc_html( print_r( $data, TRUE ) );
197
+ $out .= "\n</pre>\n";
198
+ echo $out;
199
+ }
200
+
201
+ function get_theme_data_from_contents( $theme_data ) {
202
+ $themes_allowed_tags = array(
203
+ 'a' => array(
204
+ 'href' => array(),'title' => array()
205
+ ),
206
+ 'abbr' => array(
207
+ 'title' => array()
208
+ ),
209
+ 'acronym' => array(
210
+ 'title' => array()
211
+ ),
212
+ 'code' => array(),
213
+ 'em' => array(),
214
+ 'strong' => array()
215
+ );
216
+
217
+ $theme_data = str_replace ( '\r', '\n', $theme_data );
218
+ preg_match( '|^[ \t\/*#@]*Theme Name:(.*)$|mi', $theme_data, $theme_name );
219
+ preg_match( '|^[ \t\/*#@]*Theme URI:(.*)$|mi', $theme_data, $theme_uri );
220
+ preg_match( '|^[ \t\/*#@]*Description:(.*)$|mi', $theme_data, $description );
221
+
222
+ if ( preg_match( '|^[ \t\/*#@]*Author URI:(.*)$|mi', $theme_data, $author_uri ) )
223
+ $author_uri = esc_url( trim( $author_uri[1]) );
224
+ else
225
+ $author_uri = '';
226
+
227
+ if ( preg_match( '|^[ \t\/*#@]*Template:(.*)$|mi', $theme_data, $template ) )
228
+ $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
229
+ else
230
+ $template = '';
231
+
232
+ if ( preg_match( '|^[ \t\/*#@]*Version:(.*)|mi', $theme_data, $version ) )
233
+ $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
234
+ else
235
+ $version = '';
236
+
237
+ if ( preg_match('|^[ \t\/*#@]*Status:(.*)|mi', $theme_data, $status) )
238
+ $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
239
+ else
240
+ $status = 'publish';
241
+
242
+ if ( preg_match('|^[ \t\/*#@]*Tags:(.*)|mi', $theme_data, $tags) )
243
+ $tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) );
244
+ else
245
+ $tags = array();
246
+
247
+ $theme = ( isset( $theme_name[1] ) ) ? wp_kses( trim( $theme_name[1] ), $themes_allowed_tags ) : '';
248
+
249
+ $theme_uri = ( isset( $theme_uri[1] ) ) ? esc_url( trim( $theme_uri[1] ) ) : '';
250
+
251
+ $description = ( isset( $description[1] ) ) ? wp_kses( trim( $description[1] ), $themes_allowed_tags ) : '';
252
+
253
+ if ( preg_match( '|^[ \t\/*#@]*Author:(.*)$|mi', $theme_data, $author_name ) ) {
254
+ if ( empty( $author_uri ) ) {
255
+ $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
256
+ } else {
257
+ $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
258
+ }
259
+ } else {
260
+ $author = __('Anonymous');
261
+ }
262
+
263
+ return array( 'Name' => $theme, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Author_URI' => $author_uri, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );
264
+ }
265
+
266
+ /*
267
+ * 3.3/3.4 compat
268
+ *
269
+ */
270
+ function tc_get_themes() {
271
+
272
+ if ( ! class_exists( 'WP_Theme' ) )
273
+ return get_themes();
274
+
275
+ global $wp_themes;
276
+ if ( isset( $wp_themes ) )
277
+ return $wp_themes;
278
+
279
+ $themes = wp_get_themes();
280
+ $wp_themes = array();
281
+
282
+ foreach ( $themes as $theme ) {
283
+ $name = $theme->get('Name');
284
+ if ( isset( $wp_themes[ $name ] ) )
285
+ $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
286
+ else
287
+ $wp_themes[ $name ] = $theme;
288
+ }
289
+
290
+ return $wp_themes;
291
+ }
292
+
293
+ function tc_get_theme_data( $theme_file ) {
294
+
295
+ if ( ! class_exists( 'WP_Theme' ) )
296
+ return get_theme_data( $theme_file );
297
+
298
+ $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
299
+
300
+ $theme_data = array(
301
+ 'Name' => $theme->get('Name'),
302
+ 'URI' => $theme->display('ThemeURI', true, false),
303
+ 'Description' => $theme->display('Description', true, false),
304
+ 'Author' => $theme->display('Author', true, false),
305
+ 'AuthorURI' => $theme->display('AuthorURI', true, false),
306
+ 'Version' => $theme->get('Version'),
307
+ 'Template' => $theme->get('Template'),
308
+ 'Status' => $theme->get('Status'),
309
+ 'Tags' => $theme->get('Tags'),
310
+ 'Title' => $theme->get('Name'),
311
+ 'AuthorName' => $theme->display('Author', false, false),
312
+ 'License' => $theme->display( 'License', false, false),
313
+ 'License URI' => $theme->display( 'License URI', false, false),
314
+ 'Template Version' => $theme->display( 'Template Version', false, false)
315
+ );
316
+ return $theme_data;
317
+ }
checks/admin_menu.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class AdminMenu implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files) {
6
+
7
+ $ret = true;
8
+
9
+
10
+ //check for levels deprecated in 2.0 in creating menus.
11
+
12
+ $checks = array(
13
+ '/([^_](add_(admin|submenu|menu|dashboard|posts|media|links|pages|comments|theme|plugins|users|management|options)_page)\s?\([^,]*,[^,]*,\s[\'|"]?(level_[0-9]|[0-9])[^;|\r|\r\n]*)/' => __( 'User levels were deprecated in <strong>2.0</strong>. Please see <a href="https://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'theme-check' ),
14
+ '/[^a-z0-9](current_user_can\s?\(\s?[\'\"]level_[0-9][\'\"]\s?\))[^\r|\r\n]*/' => __( 'User levels were deprecated in <strong>2.0</strong>. Please see <a href="https://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'theme-check' )
15
+ );
16
+
17
+ foreach ( $php_files as $php_key => $phpfile ) {
18
+ foreach ( $checks as $key => $check ) {
19
+ checkcount();
20
+ if ( preg_match( $key, $phpfile, $matches ) ) {
21
+ $filename = tc_filename( $php_key );
22
+ $grep = ( isset( $matches[2] ) ) ? tc_grep( $matches[2], $php_key ) : tc_grep( $matches[1], $php_key );
23
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'.__( 'WARNING', 'theme-check' ) . '</span>: <strong>%1$s</strong>. %2$s%3$s', $filename, $check, $grep );
24
+ $ret = false;
25
+ }
26
+ }
27
+ }
28
+
29
+
30
+ // check for add_admin_page's, except for add_theme_page
31
+ // Note to TGMPA: Stop trying to bypass theme check.
32
+
33
+ $checks = array(
34
+ '/(?<!function)[^_>:](add_[^_\'",();]+?_page)/' => __( 'Themes should use <strong>add_theme_page()</strong> for adding admin pages.', 'theme-check' )
35
+ );
36
+
37
+
38
+ foreach ( $php_files as $php_key => $phpfile ) {
39
+ foreach ( $checks as $key => $check ) {
40
+ checkcount();
41
+ if ( preg_match_all( $key, $phpfile, $matches ) ) {
42
+ foreach ($matches[1] as $match) {
43
+ if ($match == 'add_theme_page') {
44
+ continue;
45
+ }
46
+ $filename = tc_filename( $php_key );
47
+ $error = ltrim( rtrim( $match, '(' ) );
48
+ $grep = tc_grep( $error, $php_key );
49
+ $this->error[] = sprintf('<span class="tc-lead tc-required">'.__( 'REQUIRED', 'theme-check' ) .'</span>: <strong>%1$s</strong>. %2$s%3$s', $filename, $check, $grep);
50
+ $ret = false;
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ return $ret;
57
+ }
58
+
59
+ function getError() { return $this->error; }
60
+ }
61
+
62
+ $themechecks[] = new AdminMenu;
checks/artisteer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ArtisteerCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files) {
7
+
8
+ // combine all the php files into one string to make it easier to search
9
+ $php = implode( ' ', $php_files );
10
+
11
+ checkcount();
12
+
13
+ $ret = true;
14
+ if (
15
+ strpos( $php, 'art_normalize_widget_style_tokens' ) !== false
16
+ || strpos( $php, 'art_include_lib' ) !== false
17
+ || strpos( $php, '_remove_last_slash($url) {' ) !== false
18
+ || strpos( $php, 'adi_normalize_widget_style_tokens' ) !== false
19
+ || strpos( $php, 'm_normalize_widget_style_tokens' ) !== false
20
+ || strpos ( $php, "bw = '<!--- BEGIN Widget --->';" ) !== false
21
+ || strpos ( $php, "ew = '<!-- end_widget -->';" ) !== false
22
+ || strpos ( $php, "end_widget' => '<!-- end_widget -->'") !== false
23
+ ) {
24
+ $this->error[] = "<span class='tc-lead tc-warning'>" . __('WARNING', 'theme-check' ). "</span>: " . __( 'This theme appears to have been auto-generated. Generated themes are not allowed in the themes directory.', 'theme-check' );
25
+ $ret = false;
26
+ }
27
+
28
+ return $ret;
29
+ }
30
+
31
+ function getError() { return $this->error; }
32
+ }
33
+ $themechecks[] = new ArtisteerCheck;
checks/badthings.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bad_Checks implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+ $ret = true;
7
+
8
+ $checks = array(
9
+ '/(?<![_|a-z0-9|\.])eval\s?\(/i' => __( 'eval() is not allowed.', 'theme-check' ),
10
+ '/[^a-z0-9](?<!_)(popen|proc_open|[^_]exec|shell_exec|system|passthru)\(/' => __( 'PHP system calls are often disabled by server admins and should not be in themes', 'theme-check' ),
11
+ '/\s?ini_set\(/' => __( 'Themes should not change server PHP settings', 'theme-check' ),
12
+ '/base64_decode/' => __( 'base64_decode() is not allowed', 'theme-check' ),
13
+ '/base64_encode/' => __( 'base64_encode() is not allowed', 'theme-check' ),
14
+ '/uudecode/ims' => __( 'uudecode() is not allowed', 'theme-check' ),
15
+ '/str_rot13/ims' => __( 'str_rot13() is not allowed', 'theme-check' ),
16
+ '/cx=[0-9]{21}:[a-z0-9]{10}/' => __( 'Google search code detected', 'theme-check' ),
17
+ '/pub-[0-9]{16}/i' => __( 'Google advertising code detected', 'theme-check' )
18
+ );
19
+
20
+ $grep = '';
21
+
22
+ foreach ( $php_files as $php_key => $phpfile ) {
23
+ foreach ( $checks as $key => $check ) {
24
+ checkcount();
25
+ if ( preg_match( $key, $phpfile, $matches ) ) {
26
+ $filename = tc_filename( $php_key );
27
+ $error = ltrim( trim( $matches[0], '(' ) );
28
+ $grep = tc_grep( $error, $php_key );
29
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'. __( 'WARNING', 'theme-check' ) . '</span>: Found <strong>%1$s</strong> in the file <strong>%2$s</strong>. %3$s. %4$s', $error, $filename, $check, $grep );
30
+ $ret = false;
31
+ }
32
+ }
33
+ }
34
+
35
+
36
+ $checks = array(
37
+ '/cx=[0-9]{21}:[a-z0-9]{10}/' => __( 'Google search code detected', 'theme-check' ),
38
+ '/pub-[0-9]{16}/' => __( 'Google advertising code detected', 'theme-check' )
39
+ );
40
+
41
+ foreach ( $other_files as $php_key => $phpfile ) {
42
+ foreach ( $checks as $key => $check ) {
43
+ checkcount();
44
+ if ( preg_match( $key, $phpfile, $matches ) ) {
45
+ $filename = tc_filename( $php_key );
46
+ $error = ltrim( rtrim( $matches[0],'(' ) );
47
+ $grep = tc_grep( $error, $php_key );
48
+ $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Found <strong>%1$s</strong> in the file <strong>%2$s</strong>. %3$s.%4$s', 'theme-check'), $error, $filename, $check, $grep);
49
+ $ret = false;
50
+ }
51
+ }
52
+ }
53
+ return $ret;
54
+ }
55
+ function getError() { return $this->error; }
56
+ }
57
+ $themechecks[] = new Bad_Checks;
checks/basic.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // do some basic checks for strings
4
+ class Basic_Checks implements themecheck {
5
+ protected $error = array();
6
+
7
+ function check( $php_files, $css_files, $other_files) {
8
+
9
+ $php = implode( ' ', $php_files );
10
+ $grep = '';
11
+ $ret = true;
12
+
13
+ $checks = array(
14
+ 'DOCTYPE' => __( 'See: <a href="https://codex.wordpress.org/HTML_to_XHTML">https://codex.wordpress.org/HTML_to_XHTML</a><pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"?&gt;</pre>', 'theme-check' ),
15
+ 'wp_footer\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Function_Reference/wp_footer">wp_footer</a><pre> &lt;?php wp_footer(); ?&gt;</pre>', 'theme-check' ),
16
+ 'wp_head\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Function_Reference/wp_head">wp_head</a><pre> &lt;?php wp_head(); ?&gt;</pre>', 'theme-check' ),
17
+ 'language_attributes' => __( 'See: <a href="https://codex.wordpress.org/Function_Reference/language_attributes">language_attributes</a><pre>&lt;html &lt;?php language_attributes(); ?&gt;</pre>', 'theme-check' ),
18
+ 'charset' => __( 'There must be a charset defined in the Content-Type or the meta charset tag in the head.', 'theme-check' ),
19
+ 'add_theme_support\s*\(\s?("|\')automatic-feed-links("|\')\s?\)' => __( 'See: <a href="https://codex.wordpress.org/Function_Reference/add_theme_support">add_theme_support</a><pre> &lt;?php add_theme_support( $feature ); ?&gt;</pre>', 'theme-check' ),
20
+ 'comments_template\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Template_Tags/comments_template">comments_template</a><pre> &lt;?php comments_template( $file, $separate_comments ); ?&gt;</pre>', 'theme-check' ),
21
+ 'wp_list_comments\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Template_Tags/wp_list_comments">wp_list_comments</a><pre> &lt;?php wp_list_comments( $args ); ?&gt;</pre>', 'theme-check' ),
22
+ 'comment_form\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Template_Tags/comment_form">comment_form</a><pre> &lt;?php comment_form(); ?&gt;</pre>', 'theme-check' ),
23
+ 'body_class\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Template_Tags/body_class">body_class</a><pre> &lt;?php body_class( $class ); ?&gt;</pre>', 'theme-check' ),
24
+ 'wp_link_pages\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Function_Reference/wp_link_pages">wp_link_pages</a><pre> &lt;?php wp_link_pages( $args ); ?&gt;</pre>', 'theme-check' ),
25
+ 'post_class\s*\(' => __( 'See: <a href="https://codex.wordpress.org/Template_Tags/post_class">post_class</a><pre> &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;</pre>', 'theme-check' )
26
+ );
27
+
28
+ foreach ($checks as $key => $check) {
29
+ checkcount();
30
+ if ( !preg_match( '/' . $key . '/i', $php ) ) {
31
+ if ( $key === 'add_theme_support\s*\(\s?("|\')automatic-feed-links("|\')\s?\)' ) $key = __( 'add_theme_support( \'automatic-feed-links\' )', 'theme-check');
32
+ if ( $key === 'body_class\s*\(' ) $key = __( 'body_class call in body tag', 'theme-check');
33
+ $key = str_replace( '\s*\(', '', $key );
34
+ $this->error[] = sprintf( '<span class="tc-lead tc-required">'.__('REQUIRED','theme-check').'</span>: '.__('Could not find <strong>%1$s</strong>. %2$s', 'theme-check' ), $key, $check );
35
+ $ret = false;
36
+ }
37
+ }
38
+
39
+ return $ret;
40
+ }
41
+
42
+ function getError() { return $this->error; }
43
+ }
44
+
45
+ $themechecks[] = new Basic_Checks;
checks/cdn.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Checks for resources being loaded from CDNs.
5
+ */
6
+
7
+ class CDNCheck implements themecheck {
8
+ protected $error = array();
9
+
10
+ function check( $php_files, $css_files, $other_files) {
11
+
12
+ $ret = true;
13
+ $php_code = implode( ' ', $php_files );
14
+
15
+ checkcount();
16
+
17
+ $cdn_list = array(
18
+ 'bootstrap-maxcdn' => 'maxcdn.bootstrapcdn.com/bootstrap',
19
+ 'bootstrap-netdna' => 'netdna.bootstrapcdn.com/bootstrap',
20
+ 'bootswatch-maxcdn' => 'maxcdn.bootstrapcdn.com/bootswatch',
21
+ 'bootswatch-netdna' => 'netdna.bootstrapcdn.com/bootswatch',
22
+ 'font-awesome-maxcdn' => 'maxcdn.bootstrapcdn.com/font-awesome',
23
+ 'font-awesome-netdna' => 'netdna.bootstrapcdn.com/font-awesome',
24
+ 'html5shiv-google' => 'html5shiv.googlecode.com/svn/trunk/html5.js',
25
+ 'html5shiv-maxcdn' => 'oss.maxcdn.com/libs/html5shiv',
26
+ 'jquery' => 'code.jquery.com/jquery-',
27
+ 'respond-js' => 'oss.maxcdn.com/libs/respond.js',
28
+ );
29
+
30
+ foreach( $cdn_list as $cdn_slug => $cdn_url ) {
31
+ if ( false !== strpos( $php_code, $cdn_url ) ) {
32
+ $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED','theme-check') . '</span>: ' . sprintf( __( 'Found the URL of a CDN in the code: %s. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.', 'theme-check' ), '<code>' . esc_html( $cdn_url ) . '</code>' );
33
+ //$ret = false;
34
+ }
35
+ }
36
+
37
+ return $ret;
38
+ }
39
+
40
+ function getError() { return $this->error; }
41
+ }
42
+ $themechecks[] = new CDNCheck;
checks/comment_reply.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Comment_Reply implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files) {
6
+
7
+ $php = implode( ' ', $php_files );
8
+ $ret = true;
9
+
10
+ checkcount();
11
+
12
+ if ( ! preg_match( '/wp_enqueue_script\(\s?("|\')comment-reply("|\')/i', $php ) ) {
13
+ if ( ! preg_match( '/comment-reply/', $php ) ) {
14
+ $check = __( 'See: <a href="https://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display">Migrating Plugins and Themes to 2.7/Enhanced Comment Display</a><pre> &lt;?php if ( is_singular() ) wp_enqueue_script( "comment-reply" ); ?&gt;</pre>', 'theme-check' );
15
+ $this->error[] = sprintf('<span class="tc-lead tc-required">'.__('REQUIRED','theme-check').'</span>: '.__('Could not find the <strong>comment-reply</strong> script enqueued. %1$s', 'theme-check'), $check);
16
+ $ret = false;
17
+ } else {
18
+ $this->error[] = '<span class="tc-lead tc-info">'.__('INFO','theme-check').'</span>: '.__('Could not find the <strong>comment-reply</strong> script enqueued, however a reference to \'comment-reply\' was found. Make sure that the comment-reply script is being enqueued properly on singular pages.', 'theme-check');
19
+ }
20
+ }
21
+ return $ret;
22
+ }
23
+
24
+ function getError() { return $this->error; }
25
+ }
26
+
27
+ $themechecks[] = new Comment_Reply;
checks/commpage.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CommentPaginationCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+ $ret = true;
8
+
9
+ // combine all the php files into one string to make it easier to search
10
+ $php = implode( ' ', $php_files );
11
+ checkcount();
12
+ if (strpos( $php, 'paginate_comments_links' ) === false &&
13
+ (strpos( $php, 'next_comments_link' ) === false && strpos( $php, 'previous_comments_link' ) === false ) ) {
14
+
15
+ $this->error[] = '<span class="tc-lead tc-required">'.__('REQUIRED','theme-check').'</span>: '.__('The theme doesn\'t have comment pagination code in it. Use <strong>paginate_comments_links()</strong> or <strong>next_comments_link()</strong> and <strong>previous_comments_link()</strong> to add comment pagination.', 'theme-check' );
16
+ $ret = false;
17
+ }
18
+
19
+ return $ret;
20
+ }
21
+
22
+ function getError() { return $this->error; }
23
+ }
24
+ $themechecks[] = new CommentPaginationCheck;
checks/constants.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Constants implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $ret = true;
9
+
10
+ $checks = array(
11
+ 'STYLESHEETPATH' => 'get_stylesheet_directory()',
12
+ 'TEMPLATEPATH' => 'get_template_directory()',
13
+ 'PLUGINDIR' => 'WP_PLUGIN_DIR',
14
+ 'MUPLUGINDIR' => 'WPMU_PLUGIN_DIR'
15
+ );
16
+
17
+ foreach ( $php_files as $php_key => $phpfile ) {
18
+ foreach ( $checks as $key => $check ) {
19
+ checkcount();
20
+ if ( preg_match( '/[\s|]' . $key . '/', $phpfile, $matches ) ) {
21
+ $filename = tc_filename( $php_key );
22
+ $error = ltrim( rtrim( $matches[0], '(' ) );
23
+ $grep = tc_grep( $error, $php_key );
24
+ $this->error[] = sprintf('<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('<strong>%1$s</strong> was found in the file <strong>%2$s</strong>. Use <strong>%3$s</strong> instead.%4$s', 'theme-check'), $error, $filename, $check, $grep );
25
+ }
26
+ }
27
+ }
28
+ return $ret;
29
+ }
30
+
31
+ function getError() { return $this->error; }
32
+ }
33
+ $themechecks[] = new Constants;
checks/content-width.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ContentWidthCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $ret = true;
9
+
10
+ // combine all the php files into one string to make it easier to search
11
+ $php = implode( ' ', $php_files );
12
+ checkcount();
13
+ if ( strpos( $php, '$content_width' ) === false && strpos( $php, '$GLOBALS' . "['content_width']" ) === false && !preg_match( '/add_filter\(\s?("|\')embed_defaults/', $php ) && !preg_match( '/add_filter\(\s?("|\')content_width/', $php ) ) {
14
+ $this->error[] = '<span class="tc-lead tc-required">'.__('REQUIRED','theme-check').'</span>: '.__('No content width has been defined. Example: <pre>if ( ! isset( $content_width ) ) $content_width = 900;</pre>', 'theme-check' );
15
+ $ret = false;
16
+ }
17
+
18
+ return $ret;
19
+ }
20
+
21
+ function getError() { return $this->error; }
22
+ }
23
+ $themechecks[] = new ContentWidthCheck;
checks/customizer.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Checks for the Customizer.
5
+ */
6
+
7
+ class CustomizerCheck implements themecheck {
8
+ protected $error = array();
9
+
10
+ function check( $php_files, $css_files, $other_files) {
11
+
12
+ $ret = true;
13
+
14
+ checkcount();
15
+
16
+ /**
17
+ * Check whether every Customizer setting has a sanitization callback set.
18
+ */
19
+ foreach ( $php_files as $file_path => $file_content ) {
20
+ // Get the arguments passed to the add_setting method
21
+ if ( preg_match_all( '/\$wp_customize->add_setting\(([^;]+)/', $file_content, $matches ) ) {
22
+ // The full match is in [0], the match group in [1]
23
+ foreach ( $matches[1] as $match ) {
24
+ // Check if we have sanitize_callback or sanitize_js_callback
25
+ if ( false === strpos( $match, 'sanitize_callback' ) && false === strpos( $match, 'sanitize_js_callback' ) ) {
26
+ $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . __( 'Found a Customizer setting that did not have a sanitization callback function. Every call to the <strong>add_setting()</strong> method needs to have a sanitization callback function passed.', 'theme-check' );
27
+ $ret = false;
28
+ } else {
29
+ // There's a callback, check that no empty parameter is passed.
30
+ if ( preg_match( '/[\'"](?:sanitize_callback|sanitize_js_callback)[\'"]\s*=>\s*[\'"]\s*[\'"]/', $match ) ) {
31
+ $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . __( 'Found a Customizer setting that had an empty value passed as sanitization callback. You need to pass a function name as sanitization callback.', 'theme-check' );
32
+ $ret = false;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ return $ret;
40
+ }
41
+
42
+ function getError() { return $this->error; }
43
+ }
44
+ $themechecks[] = new CustomizerCheck;
checks/customs.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CustomCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files) {
7
+
8
+ $ret = true;
9
+ $php = implode( ' ', $php_files );
10
+
11
+ checkcount();
12
+
13
+ if ( ! preg_match( '#add_theme_support\s?\(\s?[\'|"]custom-header#', $php ) ) {
14
+ $this->error[] = '<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('No reference to <strong>add_theme_support( "custom-header", $args )</strong> was found in the theme. It is recommended that the theme implement this functionality if using an image for the header.', 'theme-check' );
15
+ }
16
+
17
+ if ( ! preg_match( '#add_theme_support\s?\(\s?[\'|"]custom-background#', $php ) ) {
18
+ $this->error[] = '<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('No reference to <strong>add_theme_support( "custom-background", $args )</strong> was found in the theme. If the theme uses background images or solid colors for the background, then it is recommended that the theme implement this functionality.', 'theme-check' );
19
+ }
20
+
21
+ return $ret;
22
+ }
23
+
24
+ function getError() { return $this->error; }
25
+ }
26
+ $themechecks[] = new CustomCheck;
checks/dep_recommend.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // recommended deprecations checks... After some time, these will move into deprecated.php and become required.
3
+ class Deprecated_Recommended implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+ $grep = '';
8
+
9
+ $ret = true;
10
+
11
+ $checks = array(
12
+ array( 'rich_edit_exists' => '', '3.9'),
13
+ array( 'default_topic_count_text' => '', '3.9'),
14
+ array( 'format_to_post' => '', '3.9'),
15
+ array( 'get_current_site_name' => 'get_current_site()', '3.9'),
16
+ array( 'wpmu_current_site' => '', '3.9'),
17
+ array( 'get_all_category_ids' => 'get_terms()', '4.0' ),
18
+ array( 'like_escape' => 'wpdb::esc_like()', '4.0' ),
19
+ array( 'url_is_accessable_via_ssl' => '', '4.0' ),
20
+ );
21
+
22
+ foreach ( $php_files as $php_key => $phpfile ) {
23
+ foreach ( $checks as $alt => $check ) {
24
+ checkcount();
25
+ $version = $check;
26
+ $key = key( $check );
27
+ $alt = $check[ $key ];
28
+ if ( preg_match( '/[\s?]' . $key . '\(/', $phpfile, $matches ) ) {
29
+ $filename = tc_filename( $php_key );
30
+ $error = ltrim( rtrim( $matches[0], '(' ) );
31
+ $version = $check[0];
32
+ $grep = tc_grep( $error, $php_key );
33
+
34
+ // Point out the deprecated function.
35
+ $error_msg = sprintf(
36
+ __( '%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check' ),
37
+ '<strong>' . $error . '()</strong>',
38
+ '<strong>' . $filename . '</strong>',
39
+ '<strong>' . $version . '</strong>'
40
+ );
41
+
42
+ // Add alternative function when available.
43
+ if ( $alt ) {
44
+ $error_msg .= ' ' . sprintf( __( 'Use %s instead.', 'theme-check' ), '<strong>' . $alt . '</strong>' );
45
+ }
46
+
47
+ // Add the precise code match that was found.
48
+ $error_msg .= $grep;
49
+
50
+ // Add the finalized error message.
51
+ $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED','theme-check') . '</span>: ' . $error_msg;
52
+ }
53
+ }
54
+ }
55
+ return $ret;
56
+ }
57
+
58
+ function getError() { return $this->error; }
59
+ }
60
+ $themechecks[] = new Deprecated_Recommended;
checks/deprecated.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Deprecated implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+ $grep = '';
8
+
9
+ $ret = true;
10
+
11
+ $checks = array(
12
+ // start wp-includes deprecated
13
+ array( 'get_postdata' => 'get_post()', '1.5.1' ),
14
+ array( 'start_wp' => 'the Loop', '1.5' ),
15
+ array( 'the_category_id' => 'get_the_category()', '0.71' ),
16
+ array( 'the_category_head' => 'get_the_category_by_ID()', '0.71' ),
17
+ array( 'previous_post' => 'previous_post_link()', '2.0' ),
18
+ array( 'next_post' => 'next_post_link()', '2.0' ),
19
+ array( 'user_can_create_post' => 'current_user_can()', '2.0' ),
20
+ array( 'user_can_create_draft' => 'current_user_can()', '2.0' ),
21
+ array( 'user_can_edit_post' => 'current_user_can()', '2.0' ),
22
+ array( 'user_can_delete_post' => 'current_user_can()', '2.0' ),
23
+ array( 'user_can_set_post_date' => 'current_user_can()', '2.0' ),
24
+ array( 'user_can_edit_post_comments' => 'current_user_can()', '2.0' ),
25
+ array( 'user_can_delete_post_comments' => 'current_user_can()', '2.0' ),
26
+ array( 'user_can_edit_user' => 'current_user_can()', '2.0' ),
27
+ array( 'get_linksbyname' => 'get_bookmarks()', '2.1' ),
28
+ array( 'wp_get_linksbyname' => 'wp_list_bookmarks()', '2.1' ),
29
+ array( 'get_linkobjectsbyname' => 'get_bookmarks()', '2.1' ),
30
+ array( 'get_linkobjects' => 'get_bookmarks()', '2.1' ),
31
+ array( 'get_linksbyname_withrating' => 'get_bookmarks()', '2.1' ),
32
+ array( 'get_links_withrating' => 'get_bookmarks()', '2.1' ),
33
+ array( 'get_autotoggle' => '', '2.1' ),
34
+ array( 'list_cats' => 'wp_list_categories', '2.1' ),
35
+ array( 'wp_list_cats' => 'wp_list_categories', '2.1' ),
36
+ array( 'dropdown_cats' => 'wp_dropdown_categories()', '2.1' ),
37
+ array( 'list_authors' => 'wp_list_authors()', '2.1' ),
38
+ array( 'wp_get_post_cats' => 'wp_get_post_categories()', '2.1' ),
39
+ array( 'wp_set_post_cats' => 'wp_set_post_categories()', '2.1' ),
40
+ array( 'get_archives' => 'wp_get_archives', '2.1' ),
41
+ array( 'get_author_link' => 'get_author_posts_url()', '2.1' ),
42
+ array( 'link_pages' => 'wp_link_pages()', '2.1' ),
43
+ array( 'get_settings' => 'get_option()', '2.1' ),
44
+ array( 'permalink_link' => 'the_permalink()', '1.2' ),
45
+ array( 'permalink_single_rss' => 'permalink_rss()', '2.3' ),
46
+ array( 'wp_get_links' => 'wp_list_bookmarks()', '2.1' ),
47
+ array( 'get_links' => 'get_bookmarks()', '2.1' ),
48
+ array( 'get_links_list' => 'wp_list_bookmarks()', '2.1' ),
49
+ array( 'links_popup_script' => '', '2.1' ),
50
+ array( 'get_linkrating' => 'sanitize_bookmark_field()', '2.1' ),
51
+ array( 'get_linkcatname' => 'get_category()', '2.1' ),
52
+ array( 'comments_rss_link' => 'post_comments_feed_link()', '2.5' ),
53
+ array( 'get_category_rss_link' => 'get_category_feed_link()'. '2.5' ),
54
+ array( 'get_author_rss_link' => 'get_author_feed_link()', '2.5' ),
55
+ array( 'comments_rss' => 'get_post_comments_feed_link()', '2.2' ),
56
+ array( 'create_user' => 'wp_create_user()', '2.0' ),
57
+ array( 'gzip_compression' => '', '2.5' ),
58
+ array( 'get_commentdata' => 'get_comment()', '2.7' ),
59
+ array( 'get_catname' => 'get_cat_name()', '2.8' ),
60
+ array( 'get_category_children' => 'get_term_children', '2.8' ),
61
+ array( 'get_the_author_description' => 'get_the_author_meta(\'description\')', '2.8' ),
62
+ array( 'the_author_description' => 'the_author_meta(\'description\')', '2.8' ),
63
+ array( 'get_the_author_login' => 'the_author_meta(\'login\')', '2.8' ),
64
+ array( 'get_the_author_firstname' => 'get_the_author_meta(\'first_name\')', '2.8' ),
65
+ array( 'the_author_firstname' => 'the_author_meta(\'first_name\')', '2.8' ),
66
+ array( 'get_the_author_lastname' => 'get_the_author_meta(\'last_name\')', '2.8' ),
67
+ array( 'the_author_lastname' => 'the_author_meta(\'last_name\')', '2.8' ),
68
+ array( 'get_the_author_nickname' => 'get_the_author_meta(\'nickname\')', '2.8' ),
69
+ array( 'the_author_nickname' => 'the_author_meta(\'nickname\')', '2.8' ),
70
+ array( 'get_the_author_email' => 'get_the_author_meta(\'email\')', '2.8' ),
71
+ array( 'the_author_email' => 'the_author_meta(\'email\')', '2.8' ),
72
+ array( 'get_the_author_icq' => 'get_the_author_meta(\'icq\')', '2.8' ),
73
+ array( 'the_author_icq' => 'the_author_meta(\'icq\')', '2.8' ),
74
+ array( 'get_the_author_yim' => 'get_the_author_meta(\'yim\')', '2.8' ),
75
+ array( 'the_author_yim' => 'the_author_meta(\'yim\')', '2.8' ),
76
+ array( 'get_the_author_msn' => 'get_the_author_meta(\'msn\')', '2.8' ),
77
+ array( 'the_author_msn' => 'the_author_meta(\'msn\')', '2.8' ),
78
+ array( 'get_the_author_aim' => 'get_the_author_meta(\'aim\')', '2.8' ),
79
+ array( 'the_author_aim' => 'the_author_meta(\'aim\')', '2.8' ),
80
+ array( 'get_author_name' => 'get_the_author_meta(\'display_name\')', '2.8' ),
81
+ array( 'get_the_author_url' => 'get_the_author_meta(\'url\')', '2.8' ),
82
+ array( 'the_author_url' => 'the_author_meta(\'url\')', '2.8' ),
83
+ array( 'get_the_author_ID' => 'get_the_author_meta(\'ID\')', '2.8' ),
84
+ array( 'the_author_ID' => 'the_author_meta(\'ID\')', '2.8' ),
85
+ array( 'the_content_rss' => 'the_content_feed()', '2.9' ),
86
+ array( 'make_url_footnote' => '', '2.9' ),
87
+ array( '_c' => '_x()', '2.9' ),
88
+ array( 'translate_with_context' => '_x()', '3.0' ),
89
+ array( 'nc' => 'nx()', '3.0' ),
90
+ array( '__ngettext' => '_n_noop()', '2.8' ),
91
+ array( '__ngettext_noop' => '_n_noop()', '2.8' ),
92
+ array( 'get_alloptions' => 'wp_load_alloptions()', '3.0' ),
93
+ array( 'get_the_attachment_link' => 'wp_get_attachment_link()', '2.5' ),
94
+ array( 'get_attachment_icon_src' => 'wp_get_attachment_image_src()', '2.5' ),
95
+ array( 'get_attachment_icon' => 'wp_get_attachment_image()', '2.5' ),
96
+ array( 'get_attachment_innerhtml' => 'wp_get_attachment_image()', '2.5' ),
97
+ array( 'get_link' => 'get_bookmark()', '2.1' ),
98
+ array( 'sanitize_url' => 'esc_url()', '2.8' ),
99
+ array( 'clean_url' => 'esc_url()', '3.0' ),
100
+ array( 'js_escape' => 'esc_js()', '2.8' ),
101
+ array( 'wp_specialchars' => 'esc_html()', '2.8' ),
102
+ array( 'attribute_escape' => 'esc_attr()', '2.8' ),
103
+ array( 'register_sidebar_widget' => 'wp_register_sidebar_widget()', '2.8' ),
104
+ array( 'unregister_sidebar_widget' => 'wp_unregister_sidebar_widget()', '2.8' ),
105
+ array( 'register_widget_control' => 'wp_register_widget_control()', '2.8' ),
106
+ array( 'unregister_widget_control' => 'wp_unregister_widget_control()', '2.8' ),
107
+ array( 'delete_usermeta' => 'delete_user_meta()', '3.0' ),
108
+ array( 'get_usermeta' => 'get_user_meta()', '3.0' ),
109
+ array( 'update_usermeta' => 'update_user_meta()', '3.0' ),
110
+ array( 'automatic_feed_links' => 'add_theme_support( \'automatic-feed-links\' )', '3.0' ),
111
+ array( 'get_profile' => 'get_the_author_meta()', '3.0' ),
112
+ array( 'get_usernumposts' => 'count_user_posts()', '3.0' ),
113
+ array( 'funky_javascript_callback' => '', '3.0' ),
114
+ array( 'funky_javascript_fix' => '', '3.0' ),
115
+ array( 'is_taxonomy' => 'taxonomy_exists()', '3.0' ),
116
+ array( 'is_term' => 'term_exists()', '3.0' ),
117
+ array( 'is_plugin_page' => '$plugin_page and/or get_plugin_page_hookname() hooks', '3.1' ),
118
+ array( 'update_category_cache' => 'No alternatives', '3.1' ),
119
+ array( 'get_users_of_blog' => 'get_users()', '3.1' ),
120
+ array( 'wp_timezone_supported' => '', '3.2' ),
121
+ array( 'the_editor' => 'wp_editor', '3.3' ),
122
+ array( 'get_user_metavalues' => '', '3.3' ),
123
+ array( 'sanitize_user_object' => '', '3.3' ),
124
+ array( 'get_boundary_post_rel_link' => '', '3.3' ),
125
+ array( 'start_post_rel_link' => 'none available ', '3.3' ),
126
+ array( 'get_index_rel_link' => '', '3.3' ),
127
+ array( 'index_rel_link' => '', '3.3' ),
128
+ array( 'get_parent_post_rel_link' => '', '3.3' ),
129
+ array( 'parent_post_rel_link' => '', '3.3' ),
130
+ array( 'wp_admin_bar_dashboard_view_site_menu' => '', '3.3' ),
131
+ array( 'is_blog_user' => 'is_member_of_blog()', '3.3' ),
132
+ array( 'debug_fopen' => 'error_log()', '3.3' ),
133
+ array( 'debug_fwrite' => 'error_log()', '3.3' ),
134
+ array( 'debug_fclose' => 'error_log()', '3.3' ),
135
+ array( 'get_themes' => 'wp_get_themes()', '3.4' ),
136
+ array( 'get_theme' => 'wp_get_theme()', '3.4' ),
137
+ array( 'get_current_theme' => 'wp_get_theme()', '3.4' ),
138
+ array( 'clean_pre' => '', '3.4' ),
139
+ array( 'add_custom_image_header' => 'add_theme_support( \'custom-header\', $args )', '3.4' ),
140
+ array( 'remove_custom_image_header' => 'remove_theme_support( \'custom-header\' )', '3.4' ),
141
+ array( 'add_custom_background' => 'add_theme_support( \'custom-background\', $args )', '3.4' ),
142
+ array( 'remove_custom_background' => 'remove_theme_support( \'custom-background\' )', '3.4' ),
143
+ array( 'get_theme_data' => 'wp_get_theme()', '3.4' ),
144
+ array( 'update_page_cache' => 'update_post_cache()', '3.4' ),
145
+ array( 'clean_page_cache' => 'clean_post_cache()', '3.4' ),
146
+ array( 'wp_explain_nonce' => 'wp_nonce_ays', '3.4.1' ),
147
+ array( 'sticky_class' => 'post_class()', '3.5' ),
148
+ array( '_get_post_ancestors' => '', '3.5' ),
149
+ array( 'wp_load_image' => 'wp_get_image_editor()', '3.5' ),
150
+ array( 'image_resize' => 'wp_get_image_editor()', '3.5' ),
151
+ array( 'wp_get_single_post' => 'get_post()', '3.5' ),
152
+ array( 'user_pass_ok' => 'wp_authenticate()', '3.5' ),
153
+ array( '_save_post_hook' => '', '3.5' ),
154
+ array( 'gd_edit_image_support' => 'wp_image_editor_supports', '3.5' ),
155
+ array( 'get_user_id_from_string' => 'get_user_by()', '3.6' ),
156
+ array( 'wp_convert_bytes_to_hr' => 'size_format()', '3.6' ),
157
+ array('_search_terms_tidy' => '', '3.7' ),
158
+ array( 'get_blogaddress_by_domain' => '', '3.7' ),
159
+ array( 'rich_edit_exists' => '', '3.9' ),
160
+ array( 'default_topic_count_text' => '', '3.9' ),
161
+ array( 'format_to_post' => 'wpdb::prepare()', '3.9' ),
162
+ array( 'get_current_site_name' => 'get_current_site()', '3.9' ),
163
+ array( 'wpmu_current_site' => '', '3.9' ),
164
+ array( 'get_all_category_ids' => 'get_terms()', '4.0' ),
165
+ array( 'like_escape' => 'wpdb::esc_like()', '4.0' ),
166
+ array( 'url_is_accessable_via_ssl' => '', '4.0' ),
167
+ array( 'prepare_control' => '', '4.1' ),
168
+ array( 'add_tab' => '', '4.1' ),
169
+ array( 'remove_tab' => '', '4.1' ),
170
+ array( 'print_tab_image' => '', '4.1' ),
171
+ array( 'setup_widget_addition_previews' => 'customize_dynamic_setting_args', '4.2' ),
172
+ array( 'prepreview_added_sidebars_widgets' => 'customize_dynamic_setting_args', '4.2' ),
173
+ array( 'prepreview_added_widget_instance' => 'customize_dynamic_setting_args', '4.2' ),
174
+ array( 'remove_prepreview_filters' => 'customize_dynamic_setting_args', '4.2' ),
175
+ array( 'preview_theme' => '', '4.3' ),
176
+ array( '_preview_theme_template_filter' => '', '4.3' ),
177
+ array( '_preview_theme_stylesheet_filter' => '', '4.3' ),
178
+ array( 'preview_theme_ob_filter' => '', '4.3' ),
179
+ array( 'preview_theme_ob_filter_callback' => '', '4.3' ),
180
+ array( 'wp_richedit_pre' => '', '4.3' ),
181
+ array( 'wp_htmledit_pre' => '', '4.3' ),
182
+ // end wp-includes deprecated
183
+
184
+ // start wp-admin deprecated
185
+ array( 'tinymce_include' => 'wp_tiny_mce()', '2.1' ),
186
+ array( 'documentation_link' => '', '2.5' ),
187
+ array( 'wp_shrink_dimensions' => 'wp_constrain_dimensions()','3.0' ),
188
+ array( 'dropdown_categories' => 'wp_category_checklist()','2.6' ),
189
+ array( 'dropdown_link_categories' => 'wp_link_category_checklist()','2.6' ),
190
+ array( 'wp_dropdown_cats' => 'wp_dropdown_categories()','3.0' ),
191
+ array( 'add_option_update_handler' => 'register_setting()','3.0' ),
192
+ array( 'remove_option_update_handler' => 'unregister_setting()','3.0' ),
193
+ array( 'codepress_get_lang' => '','3.0' ),
194
+ array( 'codepress_footer_js' => '','3.0' ),
195
+ array( 'use_codepress' => '','3.0' ),
196
+ array( 'get_author_user_ids' => '','3.1' ),
197
+ array( 'get_editable_authors' => '','3.1' ),
198
+ array( 'get_editable_user_ids' => '','3.1' ),
199
+ array( 'get_nonauthor_user_ids' => '','3.1' ),
200
+ array( 'WP_User_Search' => 'WP_User_Query','3.1' ),
201
+ array( 'get_others_unpublished_posts' => '','3.1' ),
202
+ array( 'get_others_drafts' => '','3.1' ),
203
+ array( 'get_others_pending' => '', '3.1' ),
204
+ array( 'wp_dashboard_quick_press()' => '', '3.2' ),
205
+ array( 'wp_tiny_mce' => 'wp_editor', '3.2' ),
206
+ array( 'wp_preload_dialogs' => 'wp_editor()', '3.2' ),
207
+ array( 'wp_print_editor_js' => 'wp_editor()', '3.2' ),
208
+ array( 'wp_quicktags' => 'wp_editor()', '3.2' ),
209
+ array( 'favorite_actions' => 'WP_Admin_Bar', '3.2' ),
210
+ array( 'screen_layout' => '$current_screen->render_screen_layout()', '3.3' ),
211
+ array( 'screen_options' => '$current_screen->render_per_page_options()', '3.3' ),
212
+ array( 'screen_meta' => ' $current_screen->render_screen_meta()', '3.3' ),
213
+ array( 'media_upload_image' => 'wp_media_upload_handler()', '3.3' ),
214
+ array( 'media_upload_audio' => 'wp_media_upload_handler()', '3.3' ),
215
+ array( 'media_upload_video' => 'wp_media_upload_handler()', '3.3' ),
216
+ array( 'media_upload_file' => 'wp_media_upload_handler()', '3.3' ),
217
+ array( 'type_url_form_image' => 'wp_media_insert_url_form( \'image\' )', '3.3' ),
218
+ array( 'type_url_form_audio' => 'wp_media_insert_url_form( \'audio\' )', '3.3' ),
219
+ array( 'type_url_form_video' => 'wp_media_insert_url_form( \'video\' )', '3.3' ),
220
+ array( 'type_url_form_file' => 'wp_media_insert_url_form( \'file\' )', '3.3' ),
221
+ array( 'add_contextual_help' => 'get_current_screen()->add_help_tab()', '3.3' ),
222
+ array( 'get_allowed_themes' => 'wp_get_themes( array( \'allowed\' => true ) )', '3.4' ),
223
+ array( 'get_broken_themes' => 'wp_get_themes( array( \'errors\' => true )', '3.4' ),
224
+ array( 'current_theme_info' => 'wp_get_theme()', '3.4' ),
225
+ array( '_insert_into_post_button' => '', '3.5' ),
226
+ array( '_media_button' => '', '3.5' ),
227
+ array( 'get_post_to_edit' => 'get_post()', '3.5' ),
228
+ array( 'get_default_page_to_edit' => 'get_default_post_to_edit()', '3.5' ),
229
+ array( 'wp_create_thumbnail' => 'image_resize()', '3.5' ),
230
+ array( 'wp_nav_menu_locations_meta_box' => '', '3.6' ),
231
+ array( 'the_attachment_links' => '', '3.7'),
232
+ array( 'wp_update_core' => 'new Core_Upgrader()', '3.7'),
233
+ array( 'wp_update_plugin' => 'new Plugin_Upgrader()', '3.7'),
234
+ array( 'wp_update_theme' => 'new Theme_Upgrader()', '3.7'),
235
+ array( 'get_screen_icon' => '', '3.8' ),
236
+ array( 'screen_icon' => '', '3.8' ),
237
+ array( 'wp_dashboard_incoming_links' => '', '3.8' ),
238
+ array( 'wp_dashboard_incoming_links_control' => '', '3.8' ),
239
+ array( 'wp_dashboard_incoming_links_output' => '', '3.8' ),
240
+ array( 'wp_dashboard_plugins' => '', '3.8' ),
241
+ array( 'wp_dashboard_primary_control' => '', '3.8' ),
242
+ array( 'wp_dashboard_recent_comments_control' => '', '3.8' ),
243
+ array( 'wp_dashboard_secondary' => '', '3.8' ),
244
+ array( 'wp_dashboard_secondary_control' => '', '3.8' ),
245
+ array( 'wp_dashboard_secondary_output' => '', '3.8' ),
246
+ array( '_relocate_children' => '', '3.9' ),
247
+ array( 'wp_ajax_wp_fullscreen_save_post' => '', '4.3' ),
248
+
249
+ // end wp-admin
250
+ );
251
+ foreach ( $php_files as $php_key => $phpfile ) {
252
+ foreach ( $checks as $alt => $check ) {
253
+ checkcount();
254
+ $key = key( $check );
255
+ $alt = $check[ $key ];
256
+ if ( preg_match( '/(?<!function)[\s?]' . $key . '\s?\(/', $phpfile, $matches ) ) {
257
+ $filename = tc_filename( $php_key );
258
+ $error = ltrim( rtrim( $matches[0], '(' ) );
259
+ $version = $check[0];
260
+ $grep = tc_grep( $error, $php_key );
261
+
262
+ // Point out the deprecated function.
263
+ $error_msg = sprintf(
264
+ __( '%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check' ),
265
+ '<strong>' . $error . '()</strong>',
266
+ '<strong>' . $filename . '</strong>',
267
+ '<strong>' . $version . '</strong>'
268
+ );
269
+
270
+ // Add alternative function when available.
271
+ if ( $alt ) {
272
+ $error_msg .= ' ' . sprintf( __( 'Use %s instead.', 'theme-check' ), '<strong>' . $alt . '</strong>' );
273
+ }
274
+
275
+ // Add the precise code match that was found.
276
+ $error_msg .= $grep;
277
+
278
+ // Add the finalized error message.
279
+ $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . $error_msg;
280
+
281
+ $ret = false;
282
+ }
283
+ }
284
+ }
285
+ return $ret;
286
+ }
287
+
288
+ function getError() { return $this->error; }
289
+ }
290
+ $themechecks[] = new Deprecated;
checks/directories.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class DirectoriesCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $ret = true;
9
+ $found = false;
10
+
11
+ foreach ( $php_files as $name => $file ) {
12
+ checkcount();
13
+ if ( strpos( $name, '.git' ) !== false || strpos( $name, '.svn' ) !== false ) $found = true;
14
+ }
15
+
16
+ foreach ( $css_files as $name => $file ) {
17
+ checkcount();
18
+ if ( strpos( $name, '.git' ) !== false || strpos( $name, '.svn' ) !== false || strpos( $name, '.hg' ) !== false || strpos( $name, '.bzr' ) !== false ) $found = true;
19
+ }
20
+
21
+ foreach ( $other_files as $name => $file ) {
22
+ checkcount();
23
+ if ( strpos( $name, '.git' ) !== false || strpos( $name, '.svn' ) !== false || strpos( $name, '.hg' ) !== false || strpos( $name, '.bzr' ) !== false ) $found = true;
24
+ }
25
+
26
+ if ($found) {
27
+ $this->error[] = sprintf('<span class="tc-lead tc-required">' . __( 'REQUIRED', 'theme-check' ) . '</span>: ' . __( 'Please remove any extraneous directories like .git or .svn from the ZIP file before uploading it.', 'theme-check') );
28
+ $ret = false;
29
+ }
30
+
31
+ return $ret;
32
+ }
33
+
34
+ function getError() { return $this->error; }
35
+ }
36
+ $themechecks[] = new DirectoriesCheck;
checks/editorstyle.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EditorStyleCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+ checkcount();
8
+ $ret = true;
9
+
10
+ $php = implode( ' ', $php_files );
11
+
12
+ if ( strpos( $php, 'add_editor_style' ) === false ) {
13
+ $this->error[] = '<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('No reference to <strong>add_editor_style()</strong> was found in the theme. It is recommended that the theme implement editor styling, so as to make the editor content match the resulting post output in the theme, for a better user experience.', 'theme-check' );
14
+ }
15
+
16
+ return $ret;
17
+ }
18
+
19
+ function getError() { return $this->error; }
20
+ }
21
+ $themechecks[] = new EditorStyleCheck;
checks/filenames.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class File_Checks implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+
7
+ $ret = true;
8
+
9
+ $filenames = array();
10
+
11
+ foreach ( $php_files as $php_key => $phpfile ) {
12
+ array_push( $filenames, strtolower( basename( $php_key ) ) );
13
+ }
14
+ foreach ( $other_files as $php_key => $phpfile ) {
15
+ array_push( $filenames, strtolower( basename( $php_key ) ) );
16
+ }
17
+ foreach ( $css_files as $php_key => $phpfile ) {
18
+ array_push( $filenames, strtolower( basename( $php_key ) ) );
19
+ }
20
+ $blacklist = array(
21
+ 'thumbs.db' => __( 'Windows thumbnail store', 'theme-check' ),
22
+ 'desktop.ini' => __( 'windows system file', 'theme-check' ),
23
+ 'project.properties' => __( 'NetBeans Project File', 'theme-check' ),
24
+ 'project.xml' => __( 'NetBeans Project File', 'theme-check' ),
25
+ '\.kpf' => __( 'Komodo Project File', 'theme-check' ),
26
+ '^\.+[a-zA-Z0-9]' => __( 'Hidden Files or Folders', 'theme-check' ),
27
+ 'php.ini' => __( 'PHP server settings file', 'theme-check' ),
28
+ 'dwsync.xml' => __( 'Dreamweaver project file', 'theme-check' ),
29
+ 'error_log' => __( 'PHP error log', 'theme-check' ),
30
+ 'web.config' => __( 'Server settings file', 'theme-check' ),
31
+ '\.sql' => __( 'SQL dump file', 'theme-check' ),
32
+ '__MACOSX' => __( 'OSX system file', 'theme-check' )
33
+ );
34
+
35
+ $musthave = array( 'index.php', 'style.css' );
36
+ $rechave = array( 'readme.txt' => __( 'Please see <a href="https://codex.wordpress.org/Theme_Review#Theme_Documentation">Theme_Documentation</a> for more information.', 'theme-check' ) );
37
+
38
+ checkcount();
39
+
40
+ foreach( $blacklist as $file => $reason ) {
41
+ if ( $filename = preg_grep( '/' . $file . '/', $filenames ) ) {
42
+ $error = implode( array_unique( $filename ), ' ' );
43
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'.__('WARNING','theme-check').'</span>: '.__('<strong>%1$s</strong> %2$s found.', 'theme-check'), $error, $reason) ;
44
+ $ret = false;
45
+ }
46
+ }
47
+
48
+ foreach( $musthave as $file ) {
49
+ if ( !in_array( $file, $filenames ) ) {
50
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'.__('WARNING','theme-check').'</span>: '.__('could not find the file <strong>%1$s</strong> in the theme.', 'theme-check'), $file);
51
+ $ret = false;
52
+ }
53
+ }
54
+
55
+ foreach( $rechave as $file => $reason ) {
56
+ if ( !in_array( $file, $filenames ) ) {
57
+ $this->error[] = sprintf('<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('could not find the file <strong>%1$s</strong> in the theme. %2$s', 'theme-check'), $file, $reason );
58
+ }
59
+ }
60
+
61
+ return $ret;
62
+ }
63
+
64
+ function getError() { return $this->error; }
65
+ }
66
+ $themechecks[] = new File_Checks;
checks/gravatar.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class GravatarCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $php = implode( ' ', $php_files );
9
+
10
+ checkcount();
11
+
12
+ $ret = true;
13
+
14
+ if ( ( strpos( $php, 'get_avatar' ) === false ) && ( strpos( $php, 'wp_list_comments' ) === false ) ) {
15
+ $this->error[] = '<span class="tc-lead tc-required">'.__('REQUIRED','theme-check').'</span>: '.__("This theme doesn't seem to support the standard avatar functions. Use <strong>get_avatar</strong> or <strong>wp_list_comments</strong> to add this support.", 'theme-check' );
16
+ $ret = false;
17
+ }
18
+
19
+ return $ret;
20
+ }
21
+
22
+ function getError() { return $this->error; }
23
+ }
24
+ $themechecks[] = new GravatarCheck;
checks/i18n.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<