Theme Check - Version 20120613

Version Description

Download this release

Release Info

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

Version 20120613

Files changed (54) hide show
  1. checkbase.php +310 -0
  2. checks/admin_menu.php +56 -0
  3. checks/artisteer.php +33 -0
  4. checks/badthings.php +57 -0
  5. checks/basic.php +49 -0
  6. checks/comment_reply.php +27 -0
  7. checks/commpage.php +24 -0
  8. checks/constants.php +33 -0
  9. checks/content-width.php +23 -0
  10. checks/customs.php +26 -0
  11. checks/dep_recommend.php +51 -0
  12. checks/deprecated.php +201 -0
  13. checks/directories.php +36 -0
  14. checks/editorstyle.php +21 -0
  15. checks/filenames.php +66 -0
  16. checks/gravatar.php +24 -0
  17. checks/i18n.php +64 -0
  18. checks/iframes.php +29 -0
  19. checks/include.php +29 -0
  20. checks/lineendings.php +43 -0
  21. checks/links.php +35 -0
  22. checks/malware.php +34 -0
  23. checks/more_deprecated.php +32 -0
  24. checks/navmenu.php +23 -0
  25. checks/nonprintable.php +27 -0
  26. checks/phpshort.php +25 -0
  27. checks/post-formats.php +38 -0
  28. checks/postsnav.php +25 -0
  29. checks/postthumb.php +27 -0
  30. checks/required.php +31 -0
  31. checks/screenshot.php +34 -0
  32. checks/searchform.php +26 -0
  33. checks/style_needed.php +39 -0
  34. checks/style_suggested.php +29 -0
  35. checks/style_tags.php +38 -0
  36. checks/suggested.php +43 -0
  37. checks/tags.php +22 -0
  38. checks/textdomain.php +71 -0
  39. checks/theme_support.php +33 -0
  40. checks/time_date.php +31 -0
  41. checks/worms.php +39 -0
  42. lang/themecheck-de_DE.mo +0 -0
  43. lang/themecheck-de_DE.po +364 -0
  44. lang/themecheck-ja.mo +0 -0
  45. lang/themecheck-ja.po +719 -0
  46. lang/themecheck-ro_RO.mo +0 -0
  47. lang/themecheck-ro_RO.po +364 -0
  48. lang/themecheck-sr_RS.mo +0 -0
  49. lang/themecheck-sr_RS.po +364 -0
  50. lang/themecheck.pot +547 -0
  51. main.php +144 -0
  52. readme.txt +157 -0
  53. style.css +77 -0
  54. theme-check.php +57 -0
checkbase.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $lines = file( $file, FILE_IGNORE_NEW_LINES ); // Read the theme file into an array
82
+ $line_index = 0;
83
+ $bad_lines = '';
84
+ foreach( $lines as $this_line ) {
85
+ if ( stristr ( $this_line, $error ) ) {
86
+ $error = str_replace( '"', "'", $error );
87
+ $this_line = str_replace( '"', "'", $this_line );
88
+ $error = ltrim( $error );
89
+ $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE );
90
+ $pre = ltrim( htmlspecialchars( $pre ) );
91
+ $bad_lines .= __("<pre class='tc-grep'>Line ", "themecheck") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . "</pre>";
92
+ }
93
+ $line_index++;
94
+ }
95
+ return str_replace( $error, '<span class="tc-grep">' . $error . '</span>', $bad_lines );
96
+ }
97
+
98
+ function tc_preg( $preg, $file ) {
99
+ $lines = file( $file, FILE_IGNORE_NEW_LINES ); // Read the theme file into an array
100
+ $line_index = 0;
101
+ $bad_lines = '';
102
+ foreach( $lines as $this_line ) {
103
+ if ( preg_match( $preg, $this_line, $matches ) ) {
104
+ $error = $matches[0];
105
+ $this_line = str_replace( '"', "'", $this_line );
106
+ $error = ltrim( $error );
107
+ $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE );
108
+ $pre = ltrim( htmlspecialchars( $pre ) );
109
+ $bad_lines .= __("<pre class='tc-grep'>Line ", "themecheck") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . "</pre>";
110
+ }
111
+ $line_index++;
112
+
113
+ }
114
+ return str_replace( $error, '<span class="tc-grep">' . $error . '</span>', $bad_lines );
115
+ }
116
+
117
+ function tc_strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
118
+ if(strrpos($haystack, $needle)){
119
+ //Everything before last $needle in $haystack.
120
+ $left = substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive);
121
+ //Switch value of $r_inclusive from 0 to 1 and viceversa.
122
+ $r_inclusive = ($r_inclusive == 0) ? 1 : 0;
123
+ //Everything after last $needle in $haystack.
124
+ $right = substr(strrchr($haystack, $needle), $r_inclusive);
125
+ //Return $left and $right into an array.
126
+ return array($left, $right);
127
+ } else {
128
+ if(strrchr($haystack, $needle)) return array('', substr(strrchr($haystack, $needle), $r_inclusive));
129
+ else return false;
130
+ }
131
+ }
132
+
133
+ function tc_filename( $file ) {
134
+ $filename = ( preg_match( '/themes\/[a-z0-9]*\/(.*)/', $file, $out ) ) ? $out[1] : basename( $file );
135
+ return $filename;
136
+ }
137
+
138
+ function tc_trac( $e ) {
139
+ $trac_left = array( '<strong>', '</strong>' );
140
+ $trac_right= array( "'''", "'''" );
141
+ $html_link = '/<a\s?href\s?=\s?[\'|"]([^"|\']*)[\'|"]>([^<]*)<\/a>/i';
142
+ $html_new = '[$1 $2]';
143
+ if ( defined( 'TC_TRAC' ) ) {
144
+ $e = preg_replace( $html_link, $html_new, $e );
145
+ $e = str_replace( $trac_left, $trac_right, $e );
146
+ $e = preg_replace( '/<pre.*?>/', "\r\n{{{\r\n", $e );
147
+ $e = str_replace( '</pre>', "\r\n}}}\r\n", $e );
148
+ }
149
+ return $e;
150
+ }
151
+
152
+ function listdir( $dir ) {
153
+ $files = array();
154
+ $dir_iterator = new RecursiveDirectoryIterator( $dir );
155
+ $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
156
+
157
+ foreach ($iterator as $file) {
158
+ array_push( $files, $file->getPathname() );
159
+ }
160
+ return $files;
161
+ }
162
+
163
+ function old_listdir( $start_dir='.' ) {
164
+ $files = array();
165
+ if ( is_dir( $start_dir ) ) {
166
+ $fh = opendir( $start_dir );
167
+ while ( ( $file = readdir( $fh ) ) !== false ) {
168
+ # loop through the files, skipping . and .., and recursing if necessary
169
+ if ( strcmp( $file, '.' )==0 || strcmp( $file, '..' )==0 ) continue;
170
+ $filepath = $start_dir . '/' . $file;
171
+ if ( is_dir( $filepath ) )
172
+ $files = array_merge( $files, listdir( $filepath ) );
173
+ else
174
+ array_push( $files, $filepath );
175
+ }
176
+ closedir( $fh );
177
+
178
+ } else {
179
+
180
+ # false if the function was called with an invalid non-directory argument
181
+ $files = false;
182
+ }
183
+ return $files;
184
+ }
185
+
186
+ function tc_print_r( $data ) {
187
+ $out = "\n<pre class='html-print-r'";
188
+ $out .= " style='border: 1px solid #ccc; padding: 7px;'>\n";
189
+ $out .= esc_html( print_r( $data, TRUE ) );
190
+ $out .= "\n</pre>\n";
191
+ echo $out;
192
+ }
193
+
194
+ function get_theme_data_from_contents( $theme_data ) {
195
+ $themes_allowed_tags = array(
196
+ 'a' => array(
197
+ 'href' => array(),'title' => array()
198
+ ),
199
+ 'abbr' => array(
200
+ 'title' => array()
201
+ ),
202
+ 'acronym' => array(
203
+ 'title' => array()
204
+ ),
205
+ 'code' => array(),
206
+ 'em' => array(),
207
+ 'strong' => array()
208
+ );
209
+
210
+ $theme_data = str_replace ( '\r', '\n', $theme_data );
211
+ preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name );
212
+ preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri );
213
+ preg_match( '|Description:(.*)$|mi', $theme_data, $description );
214
+
215
+ if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )
216
+ $author_uri = esc_url( trim( $author_uri[1]) );
217
+ else
218
+ $author_uri = '';
219
+
220
+ if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) )
221
+ $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
222
+ else
223
+ $template = '';
224
+
225
+ if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
226
+ $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
227
+ else
228
+ $version = '';
229
+
230
+ if ( preg_match('|Status:(.*)|i', $theme_data, $status) )
231
+ $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
232
+ else
233
+ $status = 'publish';
234
+
235
+ if ( preg_match('|Tags:(.*)|i', $theme_data, $tags) )
236
+ $tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) );
237
+ else
238
+ $tags = array();
239
+
240
+ $theme = ( isset( $theme_name[1] ) ) ? wp_kses( trim( $theme_name[1] ), $themes_allowed_tags ) : '';
241
+
242
+ $theme_uri = ( isset( $theme_uri[1] ) ) ? esc_url( trim( $theme_uri[1] ) ) : '';
243
+
244
+ $description = ( isset( $description[1] ) ) ? wp_kses( trim( $description[1] ), $themes_allowed_tags ) : '';
245
+
246
+ if ( preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ) ) {
247
+ if ( empty( $author_uri ) ) {
248
+ $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
249
+ } else {
250
+ $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 ) );
251
+ }
252
+ } else {
253
+ $author = __('Anonymous');
254
+ }
255
+
256
+ 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 );
257
+ }
258
+
259
+ /*
260
+ * 3.3/3.4 compat
261
+ *
262
+ */
263
+ function tc_get_themes() {
264
+
265
+ if ( ! class_exists( 'WP_Theme' ) )
266
+ return get_themes();
267
+
268
+ global $wp_themes;
269
+ if ( isset( $wp_themes ) )
270
+ return $wp_themes;
271
+
272
+ $themes = wp_get_themes();
273
+ $wp_themes = array();
274
+
275
+ foreach ( $themes as $theme ) {
276
+ $name = $theme->get('Name');
277
+ if ( isset( $wp_themes[ $name ] ) )
278
+ $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme;
279
+ else
280
+ $wp_themes[ $name ] = $theme;
281
+ }
282
+
283
+ return $wp_themes;
284
+ }
285
+
286
+ function tc_get_theme_data( $theme_file ) {
287
+
288
+ if ( ! class_exists( 'WP_Theme' ) )
289
+ return get_theme_data( $theme_file );
290
+
291
+ $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
292
+
293
+ $theme_data = array(
294
+ 'Name' => $theme->get('Name'),
295
+ 'URI' => $theme->display('ThemeURI', true, false),
296
+ 'Description' => $theme->display('Description', true, false),
297
+ 'Author' => $theme->display('Author', true, false),
298
+ 'AuthorURI' => $theme->display('AuthorURI', true, false),
299
+ 'Version' => $theme->get('Version'),
300
+ 'Template' => $theme->get('Template'),
301
+ 'Status' => $theme->get('Status'),
302
+ 'Tags' => $theme->get('Tags'),
303
+ 'Title' => $theme->get('Name'),
304
+ 'AuthorName' => $theme->display('Author', false, false),
305
+ 'License' => $theme->display( 'License', false, false),
306
+ 'License URI' => $theme->display( 'License URI', false, false),
307
+ 'Template Version' => $theme->display( 'Template Version', false, false)
308
+ );
309
+ return $theme_data;
310
+ }
checks/admin_menu.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="http://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'themecheck' ),
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="http://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'themecheck' )
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</span>: <strong>%1$s</strong>. %2$s%3$s', 'themecheck'), $filename, $check, $grep );
24
+ $ret = false;
25
+ }
26
+ }
27
+ }
28
+
29
+
30
+ //check for add_admin_page
31
+
32
+ $checks = array(
33
+ '/([^_]add_(admin|submenu|menu|dashboard|posts|media|links|pages|comments|plugins|users|management|options)_page\()/' => __( 'Themes should use <strong>add_theme_page()</strong> for adding admin pages.', 'themecheck' )
34
+ );
35
+
36
+
37
+ foreach ( $php_files as $php_key => $phpfile ) {
38
+ foreach ( $checks as $key => $check ) {
39
+ checkcount();
40
+ if ( preg_match( $key, $phpfile, $matches ) ) {
41
+ $filename = tc_filename( $php_key );
42
+ $error = ltrim( rtrim( $matches[0], '(' ) );
43
+ $grep = tc_grep( $error, $php_key );
44
+ $this->error[] = sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: <strong>%1$s</strong>. %2$s%3$s', 'themecheck'), $filename, $check, $grep);
45
+ $ret = false;
46
+ }
47
+ }
48
+ }
49
+
50
+ return $ret;
51
+ }
52
+
53
+ function getError() { return $this->error; }
54
+ }
55
+
56
+ $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</span>: " . __( 'This theme appears to have been auto-generated. Generated themes are not allowed in the themes directory.', 'themecheck' );
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.', 'themecheck' ),
10
+ '/[^a-z0-9](?<!_)(popen|proc_open|[^_]exec|shell_exec|system|passthru)\(/' => __( 'PHP sytem calls should be disabled by server admins anyway!', 'themecheck' ),
11
+ '/\s?ini_set\(/' => __( 'Themes should not change server PHP settings', 'themecheck' ),
12
+ '/base64_decode/' => __( 'base64_decode() is not allowed', 'themecheck' ),
13
+ '/base64_encode/' => __( 'base64_encode() is not allowed', 'themecheck' ),
14
+ '/uudecode/ims' => __( 'uudecode() is not allowed', 'themecheck' ),
15
+ '/str_rot13/ims' => __( 'str_rot13() is not allowed', 'themecheck' ),
16
+ '/cx=[0-9]{21}:[a-z0-9]{10}/' => __( 'Google search code detected', 'themecheck' ),
17
+ '/pub-[0-9]{16}/i' => __( 'Googe advertising code detected', 'themecheck' )
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</span>: Found <strong>%1$s</strong> in the file <strong>%2$s</strong>. %3$s. %4$s', 'themecheck'), $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', 'themecheck' ),
38
+ '/pub-[0-9]{16}/' => __( 'Googe advertising code detected', 'themecheck' )
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', 'themecheck'), $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,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="http://codex.wordpress.org/HTML_to_XHTML">http://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>', 'themecheck' ),
15
+ 'wp_footer\(' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/wp_footer">wp_footer</a><pre> &lt;?php wp_footer(); ?&gt;</pre>', 'themecheck' ),
16
+ 'wp_head\(' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/wp_head">wp_head</a><pre> &lt;?php wp_head(); ?&gt;</pre>', 'themecheck' ),
17
+ 'language_attributes' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/language_attributes">language_attributes</a><pre>&lt;html &lt;?php language_attributes(); ?&gt;</pre>', 'themecheck' ),
18
+ 'charset' => __( 'There must be a charset defined in the Content-Type or the meta charset tag in the head.', 'themecheck' ),
19
+ 'add_theme_support\(\s?("|\')automatic-feed-links("|\')\s?\)' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/add_theme_support">add_theme_support</a><pre> &lt;?php add_theme_support( $feature ); ?&gt;</pre>', 'themecheck' ),
20
+ 'register_sidebar[s]?\(' => __( 'See: <ahref="http://codex.wordpress.org/Function_Reference/register_sidebar">register_sidebar</a><pre> &lt;?php register_sidebar( $args ); ?&gt;</pre>', 'themecheck' ),
21
+ 'dynamic_sidebar\(' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/dynamic_sidebar">dynamic_sidebar</a><pre> &lt;?php dynamic_sidebar( $index ); ?&gt;</pre>', 'themecheck' ),
22
+ 'comments_template\(' => __( 'See: <a href="http://codex.wordpress.org/Template_Tags/comments_template">comments_template</a><pre> &lt;?php comments_template( $file, $separate_comments ); ?&gt;</pre>', 'themecheck' ),
23
+ 'wp_list_comments\(' => __( 'See: <a href="http://codex.wordpress.org/Template_Tags/wp_list_comments">wp_list_comments</a><pre> &lt;?php wp_list_comments( $args ); ?&gt;</pre>', 'themecheck' ),
24
+ 'comment_form\(' => __( 'See: <a href="http://codex.wordpress.org/Template_Tags/comment_form">comment_form</a><pre> &lt;?php comment_form(); ?&gt;</pre>', 'themecheck' ),
25
+ '<body.*body_class\(' => __( 'See: <a href="http://codex.wordpress.org/Template_Tags/body_class">body_class</a><pre> &lt;?php body_class( $class ); ?&gt;</pre>', 'themecheck' ),
26
+ 'wp_link_pages\(' => __( 'See: <a href="http://codex.wordpress.org/Function_Reference/wp_link_pages">wp_link_pages</a><pre> &lt;?php wp_link_pages( $args ); ?&gt;</pre>', 'themecheck' ),
27
+ 'post_class\(' => __( 'See: <a href="http://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>', 'themecheck' )
28
+ );
29
+
30
+ foreach ($checks as $key => $check) {
31
+ checkcount();
32
+ if ( !preg_match( '/' . $key . '/i', $php ) ) {
33
+ if ( $key === 'add_theme_support\(\s?("|\')automatic-feed-links("|\')\s?\)' ) $key = __( 'add_theme_support( \'automatic-feed-links\' )', 'themechek');
34
+ if ( $key === 'wp_enqueue_script\(\s?("|\')comment-reply("|\')' ) $key = __( 'wp_enqueue_script( \'comment-reply\' )', 'themechek');
35
+ if ( $key === '<body.*body_class\(' ) $key = __( 'body_class call in body tag', 'themechek');
36
+ if ( $key === 'register_sidebar[s]?\(' ) $key = __( 'register_sidebar() or register_sidebars()', 'themechek');
37
+ $key = ltrim( trim ( trim( $key, '(' ), '\\' ) );
38
+ $this->error[] = sprintf( __( '<span class="tc-lead tc-required">REQUIRED</span>: Could not find <strong>%1$s</strong>. %2$s', 'themecheck' ), $key, $check );
39
+ $ret = false;
40
+ }
41
+ }
42
+
43
+ return $ret;
44
+ }
45
+
46
+ function getError() { return $this->error; }
47
+ }
48
+
49
+ $themechecks[] = new Basic_Checks;
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="http://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>', 'themecheck' );
15
+ $this->error[] = sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: Could not find the <strong>comment-reply</strong> script enqueued. %1$s', 'themecheck'), $check);
16
+ $ret = false;
17
+ } else {
18
+ $this->error[] = __('<span class="tc-lead tc-info">INFO</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.', 'themecheck');
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</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.', 'themecheck' );
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</span>: <strong>%1$s</strong> was found in the file <strong>%2$s</strong>. Use <strong>%3$s</strong> instead.%4$s', 'themecheck'), $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 && !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</span>: No content width has been defined. Example: <pre>if ( ! isset( \$content_width ) ) \$content_width = 900;</pre>", "themecheck" );
15
+ $ret = false;
16
+ }
17
+
18
+ return $ret;
19
+ }
20
+
21
+ function getError() { return $this->error; }
22
+ }
23
+ $themechecks[] = new ContentWidthCheck;
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</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.", "themecheck" );
15
+ }
16
+
17
+ if ( ! preg_match( '#add_theme_support\s?\(\s?[\'|"]custom-background#', $php ) ) {
18
+ $this->error[] = __( "<span class='tc-lead tc-recommended'>RECOMMENDED</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.", "themecheck" );
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,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // frontend
13
+ array( 'get_themes' => 'wp_get_themes()', '3.4' ),
14
+ array( 'get_theme' => 'wp_get_theme()', '3.4' ),
15
+ array( 'get_current_theme' => 'wp_get_theme()', '3.4' ),
16
+ array( 'clean_pre' => 'none available', '3.4' ),
17
+ array( 'add_custom_image_header' => 'add_theme_support( \'custom-header\', $args )', '3.4' ),
18
+ array( 'remove_custom_image_header' => 'remove_theme_support( \'custom-header\' )', '3.4' ),
19
+ array( 'add_custom_background' => 'add_theme_support( \'custom-background\', $args )', '3.4' ),
20
+ array( 'remove_custom_background' => 'remove_theme_support( \'custom-background\' )', '3.4' ),
21
+ array( 'get_theme_data' => 'wp_get_theme()', '3.4' ),
22
+ array( 'update_page_cache' => 'update_post_cache()', '3.4' ),
23
+ array( 'clean_page_cache' => 'clean_post_cache()', '3.4' ),
24
+
25
+ // admin
26
+ array( 'get_allowed_themes' => 'wp_get_themes( array( \'allowed\' => true ) )', '3.4' ),
27
+ array( 'get_broken_themes' => 'wp_get_themes( array( \'errors\' => true )', '3.4' ),
28
+ array( 'current_theme_info' => 'wp_get_theme()', '3.4' ),
29
+ );
30
+
31
+ foreach ( $php_files as $php_key => $phpfile ) {
32
+ foreach ( $checks as $alt => $check ) {
33
+ checkcount();
34
+ $version = $check;
35
+ $key = key( $check );
36
+ $alt = $check[ $key ];
37
+ if ( preg_match( '/[\s?]' . $key . '\(/', $phpfile, $matches ) ) {
38
+ $filename = tc_filename( $php_key );
39
+ $error = ltrim( rtrim( $matches[0], '(' ) );
40
+ $version = $check[0];
41
+ $grep = tc_grep( $error, $php_key );
42
+ $this->error[] = sprintf(__('<span class="tc-lead tc-recommended">RECOMMENDED</span>: <strong>%1$s</strong> found in the file <strong>%2$s</strong>. Deprecated since version <strong>%3$s</strong>. Use <strong>%4$s</strong> instead.%5$s', 'themecheck'), $error, $filename, $version, $alt, $grep) ;
43
+ }
44
+ }
45
+ }
46
+ return $ret;
47
+ }
48
+
49
+ function getError() { return $this->error; }
50
+ }
51
+ $themechecks[] = new Deprecated_Recommended;
checks/deprecated.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_post_data' => 'get_post()', '1.5.1' ),
14
+ array( 'start_wp' => 'Use 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' => 'none available', '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' => 'none available', '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' => 'none available', '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' => 'none available', '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' => 'none available', '3.0' ),
114
+ array( 'funky_javascript_fix' => 'none available', '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' => 'None available', '3.2' ),
121
+ array( 'the_editor' => 'wp_editor', '3.3' ),
122
+ array( 'get_user_metavalues' => 'none available', '3.3' ),
123
+ array( 'sanitize_user_object' => 'none available', '3.3' ),
124
+ array( 'get_boundary_post_rel_link' => 'none available', '3.3' ),
125
+ array( 'start_post_rel_link' => 'none available ', '3.3' ),
126
+ array( 'get_index_rel_link' => 'none available', '3.3' ),
127
+ array( 'index_rel_link' => 'none available', '3.3' ),
128
+ array( 'get_parent_post_rel_link' => 'none available', '3.3' ),
129
+ array( 'parent_post_rel_link' => 'none available', '3.3' ),
130
+ array( 'wp_admin_bar_dashboard_view_site_menu' => 'none available', '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
+
136
+
137
+
138
+ // end wp-includes deprecated
139
+
140
+ // start wp-admin deprecated
141
+ array( 'tinymce_include' => 'wp_tiny_mce()', '2.1' ),
142
+ array( 'documentation_link' => 'None available', '2.5' ),
143
+ array( 'wp_shrink_dimensions' => 'wp_constrain_dimensions()','3.0' ),
144
+ array( 'dropdown_categories' => 'wp_category_checklist()','2.6' ),
145
+ array( 'dropdown_link_categories' => 'wp_link_category_checklist()','2.6' ),
146
+ array( 'wp_dropdown_cats' => 'wp_dropdown_categories()','3.0' ),
147
+ array( 'add_option_update_handler' => 'register_setting()','3.0' ),
148
+ array( 'remove_option_update_handler' => 'unregister_setting()','3.0' ),
149
+ array( 'codepress_get_lang' => 'None available','3.0' ),
150
+ array( 'codepress_footer_js' => 'None available','3.0' ),
151
+ array( 'use_codepress' => 'None available','3.0' ),
152
+ array( 'get_author_user_ids' => 'None available','3.1' ),
153
+ array( 'get_editable_authors' => 'None available','3.1' ),
154
+ array( 'get_editable_user_ids' => 'None available','3.1' ),
155
+ array( 'get_nonauthor_user_ids' => 'None available','3.1' ),
156
+ array( 'WP_User_Search' => 'WP_User_Query','3.1' ),
157
+ array( 'get_others_unpublished_posts' => 'None available','3.1' ),
158
+ array( 'get_others_drafts' => 'None available','3.1' ),
159
+ array( 'get_others_pending' => 'None available', '3.1' ),
160
+ array( 'wp_dashboard_quick_press()' => 'None available', '3.2' ),
161
+ array( 'wp_tiny_mce' => 'wp_editor', '3.2' ),
162
+ array( 'wp_preload_dialogs' => 'wp_editor()', '3.2' ),
163
+ array( 'wp_print_editor_js' => 'wp_editor()', '3.2' ),
164
+ array( 'wp_quicktags' => 'wp_editor()', '3.2' ),
165
+ array( 'favorite_actions' => 'WP_Admin_Bar', '3.2' ),
166
+ array( 'screen_layout' => '$current_screen->render_screen_layout()', '3.3' ),
167
+ array( 'screen_options' => '$current_screen->render_per_page_options()', '3.3' ),
168
+ array( 'screen_meta' => ' $current_screen->render_screen_meta()', '3.3' ),
169
+ array( 'media_upload_image' => 'wp_media_upload_handler()', '3.3' ),
170
+ array( 'media_upload_audio' => 'wp_media_upload_handler()', '3.3' ),
171
+ array( 'media_upload_video' => 'wp_media_upload_handler()', '3.3' ),
172
+ array( 'media_upload_file' => 'wp_media_upload_handler()', '3.3' ),
173
+ array( 'type_url_form_image' => 'wp_media_insert_url_form( \'image\' )', '3.3' ),
174
+ array( 'type_url_form_audio' => 'wp_media_insert_url_form( \'audio\' )', '3.3' ),
175
+ array( 'type_url_form_video' => 'wp_media_insert_url_form( \'video\' )', '3.3' ),
176
+ array( 'type_url_form_file' => 'wp_media_insert_url_form( \'file\' )', '3.3' ),
177
+ array( 'add_contextual_help' => 'get_current_screen()->add_help_tab()', '3.3' ),
178
+ // end wp-admin
179
+ );
180
+ foreach ( $php_files as $php_key => $phpfile ) {
181
+ foreach ( $checks as $alt => $check ) {
182
+ checkcount();
183
+ $version = $check;
184
+ $key = key( $check );
185
+ $alt = $check[ $key ];
186
+ if ( preg_match( '/[\s?]' . $key . '\(/', $phpfile, $matches ) ) {
187
+ $filename = tc_filename( $php_key );
188
+ $error = ltrim( rtrim( $matches[0], '(' ) );
189
+ $version = $check[0];
190
+ $grep = tc_grep( $error, $php_key );
191
+ $this->error[] = sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: <strong>%1$s</strong> found in the file <strong>%2$s</strong>. Deprecated since version <strong>%3$s</strong>. Use <strong>%4$s</strong> instead.%5$s', 'themecheck'), $error, $filename, $version, $alt, $grep );
192
+ $ret = false;
193
+ }
194
+ }
195
+ }
196
+ return $ret;
197
+ }
198
+
199
+ function getError() { return $this->error; }
200
+ }
201
+ $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 ) $found = true;
19
+ }
20
+
21
+ foreach ( $other_files as $name => $file ) {
22
+ checkcount();
23
+ if ( strpos( $name, '.git' ) !== false || strpos( $name, '.svn' ) !== false ) $found = true;
24
+ }
25
+
26
+ if ($found) {
27
+ $this->error[] = sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: Please remove any extraneous directories like .git or .svn from the ZIP file before uploading it.', 'themecheck') );
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</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.", "themecheck" );
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', 'themecheck' ),
22
+ 'desktop.ini' => __( 'windows system file', 'themecheck' ),
23
+ 'project.properties' => __( 'NetBeans Project File', 'themecheck' ),
24
+ 'project.xml' => __( 'NetBeans Project File', 'themecheck' ),
25
+ '\.kpf' => __( 'Komodo Project File', 'themecheck' ),
26
+ '^\.+[a-zA-Z0-9]' => __( 'Hidden Files or Folders', 'themecheck' ),
27
+ 'php.ini' => __( 'PHP server settings file', 'themecheck' ),
28
+ 'dwsync.xml' => __( 'Dreamweaver project file', 'themecheck' ),
29
+ 'error_log' => __( 'PHP error log', 'themecheck' ),
30
+ 'web.config' => __( 'Server settings file', 'themecheck' ),
31
+ '\.sql' => __( 'SQL dump file', 'themecheck' ),
32
+ '__MACOSX' => __( 'OSX system file', 'themecheck' )
33
+ );
34
+
35
+ $musthave = array( 'index.php', 'comments.php', 'style.css' );
36
+ $rechave = array( 'readme.txt' => __( 'Please see <a href="http://codex.wordpress.org/Theme_Review#Theme_Documentation">Theme_Documentation</a> for more information.', 'themecheck' ) );
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</span>: <strong>%1$s</strong> %2$s found.', 'themecheck'), $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</span>: could not find the file <strong>%1$s</strong> in the theme.', 'themecheck'), $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</span>: could not find the file <strong>%1$s</strong> in the theme. %2$s', 'themecheck'), $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</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.", "themecheck" );
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 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // check for various I18N errors
4
+
5
+ class I18NCheck implements themecheck {
6
+ protected $error = array();
7
+
8
+ function check( $php_files, $css_files, $other_files ) {
9
+ $ret = true;
10
+ $error = '';
11
+ checkcount();
12
+
13
+ // make sure the tokenizer is available
14
+ if ( !function_exists( 'token_get_all' ) ) return true;
15
+
16
+ foreach ( $php_files as $php_key => $phpfile ) {
17
+ $error='';
18
+
19
+ $stmts = array();
20
+ foreach ( array('_e(', '__(', '_e (', '__ (') as $finder) {
21
+ $search = $phpfile;
22
+ while ( ( $pos = strpos($search, $finder) ) !== false ) {
23
+ $search = substr($search,$pos);
24
+ $open=1;
25
+ $i=strpos($search,'(')+1;
26
+ while( $open>0 ) {
27
+ switch($search[$i]) {
28
+ case '(':
29
+ $open++; break;
30
+ case ')':
31
+ $open--; break;
32
+ }
33
+ $i++;
34
+ }
35
+ $stmts[] = substr($search,0,$i);
36
+ $search = substr($search,$i);
37
+ }
38
+ }
39
+
40
+ foreach ( $stmts as $match ) {
41
+ $tokens = @token_get_all('<?php '.$match.';');
42
+ if (!empty($tokens)) {
43
+ foreach ($tokens as $token) {
44
+ if (is_array($token) && in_array( $token[0], array( T_VARIABLE ) ) ) {
45
+ $filename = tc_filename( $php_key );
46
+ $grep = tc_grep( ltrim( $match ), $php_key );
47
+ preg_match( '/[^\s]*\s[0-9]+/', $grep, $line);
48
+ $error = ( !strpos( $error, $line[0] ) ) ? $grep : '';
49
+ $this->error[] = sprintf(__('<span class="tc-lead tc-recommended">RECOMMENDED</span>: Possible variable <strong>%1$s</strong> found in translation function in <strong>%2$s</strong>. Translation function calls must NOT contain PHP variables. %3$s','themecheck'),
50
+ $token[1], $filename, $error);
51
+ break; // stop looking at the tokens on this line once a variable is found
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ }
59
+ return $ret;
60
+ }
61
+
62
+ function getError() { return $this->error; }
63
+ }
64
+ $themechecks[] = new I18NCheck;
checks/iframes.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class IframeCheck implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+ $ret = true;
7
+
8
+ $checks = array(
9
+ '/<(iframe)[^>]*>/' => __( 'iframes are sometimes used to load unwanted adverts and code on your site', 'themecheck' )
10
+ );
11
+
12
+ foreach ( $php_files as $php_key => $phpfile ) {
13
+ foreach ( $checks as $key => $check ) {
14
+ checkcount();
15
+ if ( preg_match( $key, $phpfile, $matches ) ) {
16
+ $filename = tc_filename( $php_key );
17
+ $error = ltrim( $matches[1], '(' );
18
+ $error = rtrim( $error, '(' );
19
+ $grep = tc_grep( $error, $php_key );
20
+ $this->error[] = sprintf(__('<span class="tc-lead tc-info">INFO</span>: <strong>%1$s</strong> was found in the file <strong>%2$s</strong> %3$s.%4$s', 'themecheck'), $error, $filename, $check, $grep ) ;
21
+ }
22
+ }
23
+ }
24
+ return $ret;
25
+ }
26
+
27
+ function getError() { return $this->error; }
28
+ }
29
+ $themechecks[] = new IframeCheck;
checks/include.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class IncludeCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $ret = true;
9
+
10
+ $checks = array( '/(?<![a-z0-9_])(?:requir|includ)e(?:_once)?\s?\(/' => __( 'The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then <strong>get_template_part()</strong> should be used instead.', 'themecheck' ) );
11
+
12
+ foreach ( $php_files as $php_key => $phpfile ) {
13
+ foreach ( $checks as $key => $check ) {
14
+ checkcount();
15
+ if ( preg_match( $key, $phpfile, $matches ) ) {
16
+ $filename = tc_filename( $php_key );
17
+ $error = '/(?<![a-z0-9_])(?:requir|includ)e(?:_once)?\s?\(/';
18
+ $grep = tc_preg( $error, $php_key );
19
+ if ( basename($filename) !== 'functions.php' ) $this->error[] = sprintf ( __( '<span class="tc-lead tc-info">INFO</span>: <strong>%1$s</strong> %2$s %3$s', 'themecheck' ), $filename, $check, $grep );
20
+ }
21
+ }
22
+
23
+ }
24
+ return $ret;
25
+ }
26
+
27
+ function getError() { return $this->error; }
28
+ }
29
+ $themechecks[] = new IncludeCheck;
checks/lineendings.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LineEndingsCheck implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+ $ret = true;
7
+ foreach ( $php_files as $php_key => $phpfile ) {
8
+ if (preg_match("/\r\n/",$phpfile)) {
9
+ if (preg_match("/[^\r]\n/",$phpfile)) {
10
+ $filename = tc_filename( $php_key );
11
+ $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Both DOS and UNIX style line endings were found in the file <strong>%1$s</strong>. This causes a problem with SVN repositories and must be corrected before the theme can be accepted. Please change the file to use only one style of line endings.', 'themecheck'), $filename);
12
+ $ret = false;
13
+ }
14
+ }
15
+ }
16
+ foreach ( $css_files as $css_key => $cssfile ) {
17
+ if (preg_match("/\r\n/",$cssfile)) {
18
+ if (preg_match("/[^\r]\n/",$cssfile)) {
19
+ $filename = tc_filename( $css_key );
20
+ $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Both DOS and UNIX style line endings were found in the file <strong>%1$s</strong>. This causes a problem with SVN repositories and must be corrected before the theme can be accepted. Please change the file to use only one style of line endings.', 'themecheck'), $filename);
21
+ $ret = false;
22
+ }
23
+ }
24
+ }
25
+ foreach ( $other_files as $oth_key => $othfile ) {
26
+ $e = pathinfo($oth_key);
27
+ if ( isset( $e['extension'] ) && in_array( $e['extension'], array( 'txt','js' ) ) ) {
28
+ if (preg_match("/\r\n/",$othfile)) {
29
+ if (preg_match("/[^\r]\n/",$othfile)) {
30
+ $filename = tc_filename( $oth_key );
31
+ $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Both DOS and UNIX style line endings were found in the file <strong>%1$s</strong>. This causes a problem with SVN repositories and must be corrected before the theme can be accepted. Please change the file to use only one style of line endings.', 'themecheck'), $filename);
32
+ $ret = false;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ return $ret;
38
+ }
39
+
40
+ function getError() { return $this->error; }
41
+ }
42
+
43
+ $themechecks[] = new LineEndingsCheck;
checks/links.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Check_Links implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+
7
+ $ret = true;
8
+ global $data;
9
+ foreach ( $php_files as $php_key => $phpfile ) {
10
+ checkcount();
11
+ $grep = '';
12
+ // regex borrowed from TAC
13
+ $url_re = '([[:alnum:]\-\.])+(\\.)([[:alnum:]]){2,4}([[:blank:][:alnum:]\/\+\=\%\&\_\\\.\~\?\-]*)';
14
+ $title_re = '[[:blank:][:alnum:][:punct:]]*'; // 0 or more: any num, letter(upper/lower) or any punc symbol
15
+ $space_re = '(\\s*)';
16
+ if ( preg_match_all( "/(<a)(\\s+)(href" . $space_re . "=" . $space_re . "\"" . $space_re . "((http|https|ftp):\\/\\/)?)" . $url_re . "(\"" . $space_re . $title_re . $space_re . ">)" . $title_re . "(<\\/a>)/is", $phpfile, $out, PREG_SET_ORDER ) ) {
17
+ $filename = tc_filename( $php_key );
18
+ $out = array_unique( $out );
19
+ foreach( $out as $key ) {
20
+ if ( preg_match( '/\<a\s?href\s?=\s?["|\'](.*?)[\'|"](.*?)\>(.*?)\<\/a\>/is', $key[0], $stripped ) ) {
21
+ if ( !empty( $data['AuthorURI'] ) && !empty( $data['URI'] ) && $stripped[1] && !strpos( $stripped[1], $data['URI'] ) && !strpos( $stripped[1], $data['AuthorURI'] ) && !strpos( $stripped[1], 'wordpress.' ) ) {
22
+ $grep .= tc_grep( $stripped[1], $php_key );
23
+ }
24
+ }
25
+ if ( $grep ) {
26
+ $this->error[] = sprintf(__('<span class="tc-lead tc-info">INFO</span>: Possible hard-coded links were found in the file <strong>%1$s</strong>.%2$s', 'themecheck'), $filename, $grep);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ return $ret;
32
+ }
33
+ function getError() { return $this->error; }
34
+ }
35
+ $themechecks[] = new Check_Links;
checks/malware.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MalwareCheck 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](?<!_)(file_get_contents|curl_exec|curl_init|readfile|fopen|fsockopen|pfsockopen|fclose|fread|fwrite|file_put_contents)\s?\(/' => __( 'possible file operations', 'themecheck' ),
10
+ );
11
+
12
+ foreach ( $php_files as $php_key => $phpfile ) {
13
+ foreach ( $checks as $key => $check ) {
14
+ checkcount();
15
+
16
+ if ( preg_match_all( $key, $phpfile, $matches ) ) {
17
+ $filename = tc_filename( $php_key );
18
+
19
+ foreach ($matches[1] as $match ) {
20
+ $error = ltrim( $match, '(' );
21
+ $error = rtrim( $error, '(' );
22
+ $grep = tc_grep( $error, $php_key );
23
+ $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: <strong>%1$s</strong> was found in the file <strong>%2$s</strong> %3$s.%4$s', 'themecheck'), $error, $filename, $check, $grep );
24
+ $ret = false;
25
+ }
26
+ }
27
+ }
28
+ }
29
+ return $ret;
30
+ }
31
+
32
+ function getError() { return $this->error; }
33
+ }
34
+ $themechecks[] = new MalwareCheck;
checks/more_deprecated.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class More_Deprecated 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
+ 'get_bloginfo\(\s?("|\')home("|\')\s?\)' => 'home_url()',
12
+ 'bloginfo\(\s?("|\')home("|\')\s?\)' => 'echo home_url()'
13
+ );
14
+
15
+ foreach ( $php_files as $php_key => $phpfile ) {
16
+ foreach ( $checks as $key => $check ) {
17
+ checkcount();
18
+ if ( preg_match( '/[\s|]' . $key . '/', $phpfile, $matches ) ) {
19
+ $filename = tc_filename( $php_key );
20
+ $error = ltrim( rtrim( $matches[0], '(' ) );
21
+ $grep = tc_grep( $error, $php_key );
22
+ $this->error[] = sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: <strong>%1$s</strong> was found in the file <strong>%2$s</strong>. Use <strong>%3$s</strong> instead.%4$s', 'themecheck'), $error, $filename, $check, $grep);
23
+ $ret = false;
24
+ }
25
+ }
26
+ }
27
+ return $ret;
28
+ }
29
+
30
+ function getError() { return $this->error; }
31
+ }
32
+ $themechecks[] = new More_Deprecated;
checks/navmenu.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class NavMenuCheck 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, 'nav_menu' ) === false ) {
14
+ $this->error[] = __( "<span class='tc-lead tc-recommended'>RECOMMENDED</span>: No reference to nav_menu's was found in the theme. Note that if your theme has a menu bar, it is required to use the WordPress nav_menu functionality for it.", "themecheck" );
15
+ }
16
+
17
+ return $ret;
18
+ }
19
+
20
+ function getError() { return $this->error; }
21
+ }
22
+
23
+ $themechecks[] = new NavMenuCheck;
checks/nonprintable.php ADDED
@@ -0,0 +1,27 @@
 
 
 
</