Theme Check - Version 20160523.1

Version Description

  • Fix for theme-names with dashes in them
  • Comments stripping changes
  • Many changes by the theme review team and others. See Github for full change list.
Download this release

Release Info

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

Code changes from version 20120823 to 20160523.1

Files changed (66) hide show
  1. assets/gray-grad.png +0 -0
  2. style.css → assets/style.css +2 -2
  3. changelog.txt +120 -0
  4. checkbase.php +32 -22
  5. checks/admin_menu.php +18 -12
  6. checks/adminbar.php +42 -0
  7. checks/badthings.php +13 -13
  8. checks/basic.php +16 -20
  9. checks/cdn.php +44 -0
  10. checks/comment_reply.php +4 -4
  11. checks/commpage.php +4 -2
  12. checks/constants.php +3 -2
  13. checks/content-width.php +3 -3
  14. checks/customizer.php +44 -0
  15. checks/customs.php +2 -2
  16. checks/dep_recommend.php +34 -49
  17. checks/deprecated.php +165 -31
  18. checks/deregister.php +30 -0
  19. checks/directories.php +4 -4
  20. checks/editorstyle.php +1 -1
  21. checks/favicon.php +26 -0
  22. checks/filenames.php +19 -18
  23. checks/{artisteer.php → generated.php} +13 -4
  24. checks/gravatar.php +1 -1
  25. checks/i18n.php +14 -8
  26. checks/iframes.php +2 -2
  27. checks/include.php +3 -3
  28. checks/included-plugins.php +34 -0
  29. checks/lineendings.php +4 -4
  30. checks/links.php +3 -4
  31. checks/malware.php +3 -3
  32. checks/more_deprecated.php +43 -11
  33. checks/navmenu.php +1 -1
  34. checks/nonprintable.php +1 -1
  35. checks/phpshort.php +2 -2
  36. checks/plugin-territory.php +41 -0
  37. checks/post-formats.php +1 -1
  38. checks/postsnav.php +5 -2
  39. checks/postthumb.php +2 -2
  40. checks/required.php +0 -31
  41. checks/screenshot.php +15 -6
  42. checks/searchform.php +2 -2
  43. checks/style_needed.php +18 -16
  44. checks/style_suggested.php +1 -1
  45. checks/style_tags.php +17 -12
  46. checks/suggested.php +0 -43
  47. checks/tags.php +1 -1
  48. checks/textdomain.php +140 -47
  49. checks/theme_support.php +0 -33
  50. checks/time_date.php +1 -1
  51. checks/title.php +60 -0
  52. checks/uri.php +31 -0
  53. checks/widgets.php +42 -0
  54. checks/worms.php +6 -12
  55. lang/themecheck-de_DE.mo +0 -0
  56. lang/themecheck-de_DE.po +0 -364
  57. lang/themecheck-ja.mo +0 -0
  58. lang/themecheck-ja.po +0 -719
  59. lang/themecheck-ro_RO.mo +0 -0
  60. lang/themecheck-ro_RO.po +0 -364
  61. lang/themecheck-sr_RS.mo +0 -0
  62. lang/themecheck-sr_RS.po +0 -364
  63. lang/themecheck.pot +0 -547
  64. main.php +94 -64
  65. readme.txt +40 -12
  66. theme-check.php +55 -40
assets/gray-grad.png ADDED
Binary file
style.css → assets/style.css RENAMED
@@ -36,7 +36,7 @@ form {
36
  .theme-check h2 {
37
  margin:0 0 20px 0;
38
  padding:0 20px;
39
- background:#dfdfdf url("../../../wp-admin/images/gray-grad.png") repeat-x left top;
40
  font-size:20px;
41
  border-bottom:1px solid #ccc;
42
  }
@@ -74,4 +74,4 @@ form {
74
  .theme-info span.info {
75
  margin-left:100px;
76
  display:block;
77
- }
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
  }
74
  .theme-info span.info {
75
  margin-left:100px;
76
  display:block;
77
+ }
changelog.txt ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ = 20140929.1 =
2
+ * Added new checks and updates from Frank Klein at Automattic. Thanks Frank!
3
+ * Updated deprecated function listings
4
+ * Customizer check: All add_settings must use sanitization callbacks, for security
5
+ * Plugin territory checks: Themes must not register post types or taxonomies or add shortcodes for post content
6
+ * Widgets: Calls to register_sidebar must be called from the widgets_init action hook
7
+ * Title: <title> tags must exist and not have anything in them other than a call to wp_title()
8
+ * CDN: Checks for use of common CDNs (recommended only)
9
+ * Note: Changed plugin and author URIs due to old URIs being invalid. These may change again in the future, the URIs to my own site are temporarily only.
10
+
11
+ = 20131213.1 =
12
+ * Corrected errors not being displayed by the plugin and it incorrectly giving a "pass" result to everything.
13
+
14
+ = 20131212.1 =
15
+ * Updated for 3.8
16
+ * Most files have changed for better I18N support, so the language files were removed temporarily until translation can be redone.
17
+
18
+ = 20121211.1 =
19
+ * Updated for 3.5
20
+ * Remove Paypal button.
21
+
22
+ = 20110805.1 =
23
+ * TimThumb checks removed.
24
+ * Proper i18n loading. Fixes http://bit.ly/ouD5Ke.
25
+ * Screenshot now previewed in results, with filesize and dimensions.
26
+
27
+ = 20110602.2 =
28
+ * New file list functions hidden folders now detectable.
29
+ * Better fopen checks.
30
+ * TimThumb version bump
31
+
32
+ = 20110602.1 =
33
+ * DOS/UNIX line ending style checks are now a requirement for proper theme uploading.
34
+ * Timthumb version bump
35
+ * Several fixes reported by GaryJ
36
+ * 3.2 deprecated functions added
37
+
38
+ = 20110412.1 =
39
+ * Fix regex's
40
+ * Added check for latest footer injection hack.
41
+ * Fix tags check to use new content function correctly
42
+ * Sync of all changes made for wporg uploader theme-check.
43
+ * Updated checks post 3.1. added screenshot check to svn.
44
+ * Fix links check to not return a false failure in some cases
45
+ * rm one of the checks that causes problems on wporg uploader (and which is also unnecessary)
46
+ * Move unneeded functions out of checkbase into main.php.
47
+ * Minor formatting changes only (spacing and such)
48
+ * Add check for wp_link_pages() + fix eval() check
49
+
50
+ = 20110219.2 =
51
+ * Merged new UI props Gua Bob [1](http://guabob.com/)
52
+ * Last tested theme is always pre-selected in the themes list.
53
+ * Fixed php error in admin_menu.php
54
+
55
+ = 20110219.1 =
56
+ * See [commit log](https://github.com/Pross/theme-check/commits/) for changes.
57
+
58
+ = 20110201.2 =
59
+ * UI bug fixes [forum post](http://bit.ly/ff7amN) props Mamaduka.
60
+ * Textdomain checks for twentyten and no domain.
61
+ * Fix div not closing props Mamaduka.
62
+
63
+ = 20110201.1 =
64
+ * i18n working
65
+ * sr_RS de_DE ro_RO langs props Daniel Tara and Emil Uzelac.
66
+ * Child theme support added, checks made against parent AND child at runtime.
67
+ * Trac formatting button added for reviewers.
68
+
69
+ = 20101228.3 =
70
+ * Last revision for 3.1 (hopefully)
71
+ * Chips suggestion of checking for inclusion of searchform.php ( not
72
+ perfect yet, need more examples to look for ).
73
+ * add_theme_page is required, all others flagged and displayed with line
74
+ numbers.
75
+ * <?= detected properly, short tags outputted with line umbers.
76
+ * Mostly internationalized, needs translations now.
77
+ * Bug fixes.
78
+
79
+ = 20101228.2 =
80
+ * Added menu checking.
81
+ * ThemeURI AuthourURI added to results.
82
+ * Lots of small fixes.
83
+ * Started translation.
84
+
85
+ = 20101228.1 =
86
+ * Fix embed_defaults filter check and stylesheet file data check.
87
+
88
+ = 20101226.1 =
89
+ * Whole system redesign to allow easier synching with WordPress.org uploader. Many other additions/subtractions/changes as well.
90
+ * WordPress 3.1 guidelines added, to help theme authors ensure compatibility for upcoming release.
91
+
92
+ = 20101110.7 =
93
+ * Re-added malware.php checks for fopen and file_get_contents (INFO)
94
+ * fixed a couple of undefined index errors.
95
+
96
+ = 20101110.4_r2 =
97
+ * Fixed Warning: Wrong parameter count for stristr()
98
+
99
+ = 20101110.4_r1 =
100
+ * Added `echo` to suggested.php
101
+
102
+ = 20101110.4 =
103
+ * Fixed deprecated function call to get_plugins()
104
+
105
+ = 20101110.3 =
106
+ * Fixed undefined index.
107
+
108
+ = 20101110.2 =
109
+ * Missing `<` in main.php
110
+ * Added conditional checks for licence.txt OR Licence tags in style.css
111
+ * UI improvements.
112
+
113
+ = 20101110.1 =
114
+ * Date fix!
115
+
116
+ = 10112010_r1 =
117
+ * Fixed hardcoded links check. Added FAQ
118
+
119
+ = 10112010 =
120
+ * First release.
checkbase.php CHANGED
@@ -60,7 +60,7 @@ function display_themechecks() {
60
  }
61
  }
62
  }
63
-
64
  if ( defined( 'TC_TRAC' ) ) {
65
 
66
  if ( defined( 'TC_PRE' ) ) $results = TC_PRE . $results;
@@ -78,6 +78,9 @@ function checkcount() {
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 = '';
@@ -88,25 +91,32 @@ function tc_grep( $error, $file ) {
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
 
@@ -131,7 +141,7 @@ function tc_strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
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
 
@@ -153,7 +163,7 @@ 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
  }
@@ -174,9 +184,9 @@ function old_listdir( $start_dir='.' ) {
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
  }
@@ -208,31 +218,31 @@ function get_theme_data_from_contents( $theme_data ) {
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();
@@ -243,7 +253,7 @@ function get_theme_data_from_contents( $theme_data ) {
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 {
@@ -261,7 +271,7 @@ function get_theme_data_from_contents( $theme_data ) {
261
  *
262
  */
263
  function tc_get_themes() {
264
-
265
  if ( ! class_exists( 'WP_Theme' ) )
266
  return get_themes();
267
 
@@ -280,11 +290,11 @@ function tc_get_themes() {
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
 
@@ -307,4 +317,4 @@ function tc_get_theme_data( $theme_file ) {
307
  'Template Version' => $theme->display( 'Template Version', false, false)
308
  );
309
  return $theme_data;
310
- }
60
  }
61
  }
62
  }
63
+
64
  if ( defined( 'TC_TRAC' ) ) {
65
 
66
  if ( defined( 'TC_PRE' ) ) $results = TC_PRE . $results;
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 = '';
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 = '';
115
+ if ( !empty( $error ) ) {
116
+ $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE );
117
+ }
118
  $pre = ltrim( htmlspecialchars( $pre ) );
119
+ $bad_lines .= "<pre class='tc-grep'>" . __("Line ", "theme-check") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . "</pre>";
120
  }
121
  $line_index++;
122
 
141
  }
142
 
143
  function tc_filename( $file ) {
144
+ $filename = ( preg_match( '/themes\/[a-z0-9-]*\/(.*)/', $file, $out ) ) ? $out[1] : basename( $file );
145
  return $filename;
146
  }
147
 
163
  $files = array();
164
  $dir_iterator = new RecursiveDirectoryIterator( $dir );
165
  $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
166
+
167
  foreach ($iterator as $file) {
168
  array_push( $files, $file->getPathname() );
169
  }
184
  array_push( $files, $filepath );
185
  }
186
  closedir( $fh );
187
+
188
  } else {
189
+
190
  # false if the function was called with an invalid non-directory argument
191
  $files = false;
192
  }
218
  );
219
 
220
  $theme_data = str_replace ( '\r', '\n', $theme_data );
221
+ preg_match( '|^[ \t\/*#@]*Theme Name:(.*)$|mi', $theme_data, $theme_name );
222
+ preg_match( '|^[ \t\/*#@]*Theme URI:(.*)$|mi', $theme_data, $theme_uri );
223
+ preg_match( '|^[ \t\/*#@]*Description:(.*)$|mi', $theme_data, $description );
224
 
225
+ if ( preg_match( '|^[ \t\/*#@]*Author URI:(.*)$|mi', $theme_data, $author_uri ) )
226
  $author_uri = esc_url( trim( $author_uri[1]) );
227
  else
228
  $author_uri = '';
229
 
230
+ if ( preg_match( '|^[ \t\/*#@]*Template:(.*)$|mi', $theme_data, $template ) )
231
  $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
232
  else
233
  $template = '';
234
 
235
+ if ( preg_match( '|^[ \t\/*#@]*Version:(.*)|mi', $theme_data, $version ) )
236
  $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
237
  else
238
  $version = '';
239
 
240
+ if ( preg_match('|^[ \t\/*#@]*Status:(.*)|mi', $theme_data, $status) )
241
  $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
242
  else
243
  $status = 'publish';
244
 
245
+ if ( preg_match('|^[ \t\/*#@]*Tags:(.*)|mi', $theme_data, $tags) )
246
  $tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) );
247
  else
248
  $tags = array();
253
 
254
  $description = ( isset( $description[1] ) ) ? wp_kses( trim( $description[1] ), $themes_allowed_tags ) : '';
255
 
256
+ if ( preg_match( '|^[ \t\/*#@]*Author:(.*)$|mi', $theme_data, $author_name ) ) {
257
  if ( empty( $author_uri ) ) {
258
  $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
259
  } else {
271
  *
272
  */
273
  function tc_get_themes() {
274
+
275
  if ( ! class_exists( 'WP_Theme' ) )
276
  return get_themes();
277
 
290
  $wp_themes[ $name ] = $theme;
291
  }
292
 
293
+ return $wp_themes;
294
  }
295
 
296
  function tc_get_theme_data( $theme_file ) {
297
+
298
  if ( ! class_exists( 'WP_Theme' ) )
299
  return get_theme_data( $theme_file );
300
 
317
  'Template Version' => $theme->display( 'Template Version', false, false)
318
  );
319
  return $theme_data;
320
+ }
checks/admin_menu.php CHANGED
@@ -10,8 +10,8 @@ class AdminMenu implements themecheck {
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 ) {
@@ -20,29 +20,35 @@ class AdminMenu implements themecheck {
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
  }
@@ -53,4 +59,4 @@ class AdminMenu implements themecheck {
53
  function getError() { return $this->error; }
54
  }
55
 
56
- $themechecks[] = new AdminMenu;
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 ) {
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
  }
59
  function getError() { return $this->error; }
60
  }
61
 
62
+ $themechecks[] = new AdminMenu;
checks/adminbar.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This checks, if the admin bar gets hidden by the theme
4
+ **/
5
+ class NoHiddenAdminBar implements themecheck {
6
+ protected $error = array();
7
+
8
+ function check( $php_files, $css_files, $other_files ) {
9
+ $ret = true;
10
+ checkcount();
11
+ $php_regex = "/(add_filter(\s*)\((\s*)(\"|')show_admin_bar(\"|')(\s*)(.*))|(([^\S])show_admin_bar(\s*)\((.*))/";
12
+ $css_regex = "/(#wpadminbar)/";
13
+
14
+ //Check php files for filter show_admin_bar and show_admin_bar()
15
+ foreach ( $php_files as $file_path => $file_content ) {
16
+
17
+ $filename = tc_filename( $file_path );
18
+
19
+ if ( preg_match( $php_regex, $file_content, $matches ) ) {
20
+ $this->error[] = sprintf( '<span class="tc-lead tc-required">' . __( 'REQUIRED', 'theme-check').'</span>: ' . __( 'You are not allowed to hide the admin bar.', 'theme-check' ),
21
+ '<strong>' . $filename . '</strong>');
22
+ $ret = false;
23
+ }
24
+ }
25
+
26
+ //Check CSS Files for #wpadminbar
27
+ foreach ( $css_files as $file_path => $file_content ) {
28
+
29
+ $filename = tc_filename( $file_path );
30
+
31
+ if ( preg_match( $css_regex, $file_content, $matches ) ) {
32
+ $this->error[] = sprintf( '<span class="tc-lead tc-required">' . __( 'REQUIRED', 'theme-check').'</span>: ' . __( 'You are not allowed to hide the admin bar.', 'theme-check' ),
33
+ '<strong>' . $filename . '</strong>');
34
+ $ret = false;
35
+ }
36
+ }
37
+ return $ret;
38
+ }
39
+
40
+ function getError() { return $this->error; }
41
+ }
42
+ $themechecks[] = new NoHiddenAdminBar;
checks/badthings.php CHANGED
@@ -6,15 +6,15 @@ class Bad_Checks implements themecheck {
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 = '';
@@ -26,7 +26,7 @@ class Bad_Checks implements themecheck {
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
  }
@@ -34,8 +34,8 @@ class Bad_Checks implements themecheck {
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 ) {
@@ -45,7 +45,7 @@ class Bad_Checks implements themecheck {
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
  }
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 = '';
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 %1$s in the file %2$s. %3$s. %4$s', 'theme-check' ), '<strong>' . $error . '</strong>', '<strong>' . $filename . '</strong>', $check, $grep );
30
  $ret = false;
31
  }
32
  }
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 ) {
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
  }
checks/basic.php CHANGED
@@ -11,31 +11,27 @@ class Basic_Checks implements themecheck {
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
  }
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 %1$s. %2$s', 'theme-check' ), '<strong>' . $key . '</strong>', $check );
 
 
35
  $ret = false;
36
  }
37
  }
checks/cdn.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $css_code = implode( ' ', $css_files );
15
+ $all_code = $php_code . ' ' . $css_code;
16
+
17
+ checkcount();
18
+
19
+ $cdn_list = array(
20
+ 'bootstrap-maxcdn' => 'maxcdn.bootstrapcdn.com/bootstrap',
21
+ 'bootstrap-netdna' => 'netdna.bootstrapcdn.com/bootstrap',
22
+ 'bootswatch-maxcdn' => 'maxcdn.bootstrapcdn.com/bootswatch',
23
+ 'bootswatch-netdna' => 'netdna.bootstrapcdn.com/bootswatch',
24
+ 'font-awesome-maxcdn' => 'maxcdn.bootstrapcdn.com/font-awesome',
25
+ 'font-awesome-netdna' => 'netdna.bootstrapcdn.com/font-awesome',
26
+ 'html5shiv-google' => 'html5shiv.googlecode.com/svn/trunk/html5.js',
27
+ 'html5shiv-maxcdn' => 'oss.maxcdn.com/libs/html5shiv',
28
+ 'jquery' => 'code.jquery.com/jquery-',
29
+ 'respond-js' => 'oss.maxcdn.com/libs/respond.js',
30
+ );
31
+
32
+ foreach( $cdn_list as $cdn_slug => $cdn_url ) {
33
+ if ( false !== strpos( $all_code, $cdn_url ) ) {
34
+ $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>' );
35
+ //$ret = false;
36
+ }
37
+ }
38
+
39
+ return $ret;
40
+ }
41
+
42
+ function getError() { return $this->error; }
43
+ }
44
+ $themechecks[] = new CDNCheck;
checks/comment_reply.php CHANGED
@@ -6,16 +6,16 @@ class Comment_Reply implements themecheck {
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;
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;
checks/commpage.php CHANGED
@@ -10,9 +10,11 @@ class CommentPaginationCheck implements themecheck {
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
 
@@ -21,4 +23,4 @@ class CommentPaginationCheck implements themecheck {
21
 
22
  function getError() { return $this->error; }
23
  }
24
- $themechecks[] = new CommentPaginationCheck;
10
  $php = implode( ' ', $php_files );
11
  checkcount();
12
  if (strpos( $php, 'paginate_comments_links' ) === false &&
13
+ strpos( $php, 'the_comments_navigation' ) === false &&
14
+ strpos( $php, 'the_comments_pagination' ) === false &&
15
  (strpos( $php, 'next_comments_link' ) === false && strpos( $php, 'previous_comments_link' ) === false ) ) {
16
 
17
+ $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>the_comments_navigation</strong> or <strong>the_comments_pagination</strong> or <strong>next_comments_link()</strong> and <strong>previous_comments_link()</strong> to add comment pagination.', 'theme-check' );
18
  $ret = false;
19
  }
20
 
23
 
24
  function getError() { return $this->error; }
25
  }
26
+ $themechecks[] = new CommentPaginationCheck;
checks/constants.php CHANGED
@@ -21,7 +21,8 @@ class Constants implements themecheck {
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
  }
@@ -30,4 +31,4 @@ class Constants implements themecheck {
30
 
31
  function getError() { return $this->error; }
32
  }
33
- $themechecks[] = new Constants;
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-required">'.__('REQUIRED','theme-check').'</span>: '.__('%1$s was found in the file %2$s. Use %3$s instead.%4$s', 'theme-check'), '<strong>' . $error . '</strong>', '<strong>' . $filename . '</strong>', '<strong>' . $check . '</strong>', $grep );
25
+ $ret = false;
26
  }
27
  }
28
  }
31
 
32
  function getError() { return $this->error; }
33
  }
34
+ $themechecks[] = new Constants;
checks/content-width.php CHANGED
@@ -10,8 +10,8 @@ class ContentWidthCheck implements themecheck {
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
 
@@ -20,4 +20,4 @@ class ContentWidthCheck implements themecheck {
20
 
21
  function getError() { return $this->error; }
22
  }
23
- $themechecks[] = new ContentWidthCheck;
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
 
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 CHANGED
@@ -11,11 +11,11 @@ class CustomCheck implements themecheck {
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;
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;
checks/dep_recommend.php CHANGED
@@ -9,55 +9,22 @@ class Deprecated_Recommended implements themecheck {
9
  $ret = true;
10
 
11
  $checks = array(
12
-
13
- // wp-includes deprecated
14
- array( 'the_editor' => 'wp_editor', '3.3' ),
15
- array( 'get_user_metavalues' => 'none available', '3.3' ),
16
- array( 'sanitize_user_object' => 'none available', '3.3' ),
17
- array( 'get_boundary_post_rel_link' => 'none available', '3.3' ),
18
- array( 'start_post_rel_link' => 'none available ', '3.3' ),
19
- array( 'get_index_rel_link' => 'none available', '3.3' ),
20
- array( 'index_rel_link' => 'none available', '3.3' ),
21
- array( 'get_parent_post_rel_link' => 'none available', '3.3' ),
22
- array( 'parent_post_rel_link' => 'none available', '3.3' ),
23
- array( 'wp_admin_bar_dashboard_view_site_menu' => 'none available', '3.3' ),
24
- array( 'is_blog_user' => 'is_member_of_blog()', '3.3' ),
25
- array( 'debug_fopen' => 'error_log()', '3.3' ),
26
- array( 'debug_fwrite' => 'error_log()', '3.3' ),
27
- array( 'debug_fclose' => 'error_log()', '3.3' ),
28
-
29
- // wp-admin deprecated
30
- array( 'screen_layout' => '$current_screen->render_screen_layout()', '3.3' ),
31
- array( 'screen_options' => '$current_screen->render_per_page_options()', '3.3' ),
32
- array( 'screen_meta' => ' $current_screen->render_screen_meta()', '3.3' ),
33
- array( 'media_upload_image' => 'wp_media_upload_handler()', '3.3' ),
34
- array( 'media_upload_audio' => 'wp_media_upload_handler()', '3.3' ),
35
- array( 'media_upload_video' => 'wp_media_upload_handler()', '3.3' ),
36
- array( 'media_upload_file' => 'wp_media_upload_handler()', '3.3' ),
37
- array( 'type_url_form_image' => 'wp_media_insert_url_form( \'image\' )', '3.3' ),
38
- array( 'type_url_form_audio' => 'wp_media_insert_url_form( \'audio\' )', '3.3' ),
39
- array( 'type_url_form_video' => 'wp_media_insert_url_form( \'video\' )', '3.3' ),
40
- array( 'type_url_form_file' => 'wp_media_insert_url_form( \'file\' )', '3.3' ),
41
- array( 'add_contextual_help' => 'get_current_screen()->add_help_tab()', '3.3' ),
42
-
43
- // frontend
44
- array( 'get_themes' => 'wp_get_themes()', '3.4' ),
45
- array( 'get_theme' => 'wp_get_theme()', '3.4' ),
46
- array( 'get_current_theme' => 'wp_get_theme()', '3.4' ),
47
- array( 'clean_pre' => 'none available', '3.4' ),
48
- array( 'add_custom_image_header' => 'add_theme_support( \'custom-header\', $args )', '3.4' ),
49
- array( 'remove_custom_image_header' => 'remove_theme_support( \'custom-header\' )', '3.4' ),
50
- array( 'add_custom_background' => 'add_theme_support( \'custom-background\', $args )', '3.4' ),
51
- array( 'remove_custom_background' => 'remove_theme_support( \'custom-background\' )', '3.4' ),
52
- array( 'get_theme_data' => 'wp_get_theme()', '3.4' ),
53
- array( 'update_page_cache' => 'update_post_cache()', '3.4' ),
54
- array( 'clean_page_cache' => 'clean_post_cache()', '3.4' ),
55
 
56
- // admin
57
- array( 'get_allowed_themes' => 'wp_get_themes( array( \'allowed\' => true ) )', '3.4' ),
58
- array( 'get_broken_themes' => 'wp_get_themes( array( \'errors\' => true )', '3.4' ),
59
- array( 'current_theme_info' => 'wp_get_theme()', '3.4' ),
60
- );
 
 
61
 
62
  foreach ( $php_files as $php_key => $phpfile ) {
63
  foreach ( $checks as $alt => $check ) {
@@ -70,7 +37,25 @@ class Deprecated_Recommended implements themecheck {
70
  $error = ltrim( rtrim( $matches[0], '(' ) );
71
  $version = $check[0];
72
  $grep = tc_grep( $error, $php_key );
73
- $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) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
  }
76
  }
9
  $ret = true;
10
 
11
  $checks = array(
12
+ array( 'preview_theme' => '', '4.3' ),
13
+ array( '_preview_theme_template_filter' => '', '4.3' ),
14
+ array( '_preview_theme_stylesheet_filter' => '', '4.3' ),
15
+ array( 'preview_theme_ob_filter' => '', '4.3' ),
16
+ array( 'preview_theme_ob_filter_callback' => '', '4.3' ),
17
+ array( 'wp_richedit_pre' => '', '4.3' ),
18
+ array( 'wp_htmledit_pre' => '', '4.3' ),
19
+ array( 'wp_ajax_wp_fullscreen_save_post' => '', '4.3' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ array( 'post_permalink' => 'get_permalink', '4.4'),
22
+ array( 'wp_get_http' => 'WP_Http', '4.4'),
23
+ array( 'force_ssl_login' => 'force_ssl_admin', '4.4'),
24
+ array( 'create_empty_blog' => '', '4.4'),
25
+ array( 'get_admin_users_for_domain' => '', '4.4'),
26
+ //array( 'flush_widget_cache' => '', '4.4'),
27
+ );
28
 
29
  foreach ( $php_files as $php_key => $phpfile ) {
30
  foreach ( $checks as $alt => $check ) {
37
  $error = ltrim( rtrim( $matches[0], '(' ) );
38
  $version = $check[0];
39
  $grep = tc_grep( $error, $php_key );
40
+
41
+ // Point out the deprecated function.
42
+ $error_msg = sprintf(
43
+ __( '%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check' ),
44
+ '<strong>' . $error . '()</strong>',
45
+ '<strong>' . $filename . '</strong>',
46
+ '<strong>' . $version . '</strong>'
47
+ );
48
+
49
+ // Add alternative function when available.
50
+ if ( $alt ) {
51
+ $error_msg .= ' ' . sprintf( __( 'Use %s instead.', 'theme-check' ), '<strong>' . $alt . '</strong>' );
52
+ }
53
+
54
+ // Add the precise code match that was found.
55
+ $error_msg .= $grep;
56
+
57
+ // Add the finalized error message.
58
+ $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED','theme-check') . '</span>: ' . $error_msg;
59
  }
60
  }
61
  }
checks/deprecated.php CHANGED
@@ -10,8 +10,8 @@ class Deprecated implements themecheck {
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' ),
@@ -30,7 +30,7 @@ class Deprecated implements themecheck {
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' ),
@@ -46,7 +46,7 @@ class Deprecated implements themecheck {
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' ),
@@ -54,7 +54,7 @@ class Deprecated implements themecheck {
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' ),
@@ -83,7 +83,7 @@ class Deprecated implements themecheck {
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' ),
@@ -110,57 +110,191 @@ class Deprecated implements themecheck {
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
-
122
- // end wp-includes deprecated
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
- // start wp-admin deprecated
125
  array( 'tinymce_include' => 'wp_tiny_mce()', '2.1' ),
126
- array( 'documentation_link' => 'None available', '2.5' ),
127
- array( 'wp_shrink_dimensions' => 'wp_constrain_dimensions()','3.0' ),
 
128
  array( 'dropdown_categories' => 'wp_category_checklist()','2.6' ),
129
  array( 'dropdown_link_categories' => 'wp_link_category_checklist()','2.6' ),
 
130
  array( 'wp_dropdown_cats' => 'wp_dropdown_categories()','3.0' ),
131
  array( 'add_option_update_handler' => 'register_setting()','3.0' ),
132
  array( 'remove_option_update_handler' => 'unregister_setting()','3.0' ),
133
- array( 'codepress_get_lang' => 'None available','3.0' ),
134
- array( 'codepress_footer_js' => 'None available','3.0' ),
135
- array( 'use_codepress' => 'None available','3.0' ),
136
- array( 'get_author_user_ids' => 'None available','3.1' ),
137
- array( 'get_editable_authors' => 'None available','3.1' ),
138
- array( 'get_editable_user_ids' => 'None available','3.1' ),
139
- array( 'get_nonauthor_user_ids' => 'None available','3.1' ),
 
 
140
  array( 'WP_User_Search' => 'WP_User_Query','3.1' ),
141
- array( 'get_others_unpublished_posts' => 'None available','3.1' ),
142
- array( 'get_others_drafts' => 'None available','3.1' ),
143
- array( 'get_others_pending' => 'None available', '3.1' ),
144
- array( 'wp_dashboard_quick_press()' => 'None available', '3.2' ),
 
145
  array( 'wp_tiny_mce' => 'wp_editor', '3.2' ),
146
  array( 'wp_preload_dialogs' => 'wp_editor()', '3.2' ),
147
  array( 'wp_print_editor_js' => 'wp_editor()', '3.2' ),
148
  array( 'wp_quicktags' => 'wp_editor()', '3.2' ),
149
  array( 'favorite_actions' => 'WP_Admin_Bar', '3.2' ),
150
- // end wp-admin
151
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  foreach ( $php_files as $php_key => $phpfile ) {
153
  foreach ( $checks as $alt => $check ) {
154
  checkcount();
155
- $version = $check;
156
  $key = key( $check );
157
  $alt = $check[ $key ];
158
- if ( preg_match( '/[\s?]' . $key . '\(/', $phpfile, $matches ) ) {
159
  $filename = tc_filename( $php_key );
160
  $error = ltrim( rtrim( $matches[0], '(' ) );
161
  $version = $check[0];
162
  $grep = tc_grep( $error, $php_key );
163
- $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 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  $ret = false;
165
  }
166
  }
@@ -170,4 +304,4 @@ class Deprecated implements themecheck {
170
 
171
  function getError() { return $this->error; }
172
  }
173
- $themechecks[] = new Deprecated;
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' ),
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' ),
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' ),
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' ),
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' ),
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
 
 
158
  array( 'tinymce_include' => 'wp_tiny_mce()', '2.1' ),
159
+
160
+ array( 'documentation_link' => '', '2.5' ),
161
+
162
  array( 'dropdown_categories' => 'wp_category_checklist()','2.6' ),
163
  array( 'dropdown_link_categories' => 'wp_link_category_checklist()','2.6' ),
164
+
165
  array( 'wp_dropdown_cats' => 'wp_dropdown_categories()','3.0' ),
166
  array( 'add_option_update_handler' => 'register_setting()','3.0' ),
167
  array( 'remove_option_update_handler' => 'unregister_setting()','3.0' ),
168
+ array( 'codepress_get_lang' => '','3.0' ),
169
+ array( 'codepress_footer_js' => '','3.0' ),
170
+ array( 'use_codepress' => '','3.0' ),
171
+ array( 'wp_shrink_dimensions' => 'wp_constrain_dimensions()','3.0' ),
172
+
173
+ array( 'get_author_user_ids' => '','3.1' ),
174
+ array( 'get_editable_authors' => '','3.1' ),
175
+ array( 'get_editable_user_ids' => '','3.1' ),
176
+ array( 'get_nonauthor_user_ids' => '','3.1' ),
177
  array( 'WP_User_Search' => 'WP_User_Query','3.1' ),
178
+ array( 'get_others_unpublished_posts' => '','3.1' ),
179
+ array( 'get_others_drafts' => '','3.1' ),
180
+ array( 'get_others_pending' => '', '3.1' ),
181
+
182
+ array( 'wp_dashboard_quick_press()' => '', '3.2' ),
183
  array( 'wp_tiny_mce' => 'wp_editor', '3.2' ),
184
  array( 'wp_preload_dialogs' => 'wp_editor()', '3.2' ),
185
  array( 'wp_print_editor_js' => 'wp_editor()', '3.2' ),
186
  array( 'wp_quicktags' => 'wp_editor()', '3.2' ),
187
  array( 'favorite_actions' => 'WP_Admin_Bar', '3.2' ),
188
+
189
+ array( 'screen_layout' => '$current_screen->render_screen_layout()', '3.3' ),
190
+ array( 'screen_options' => '$current_screen->render_per_page_options()', '3.3' ),
191
+ array( 'screen_meta' => ' $current_screen->render_screen_meta()', '3.3' ),
192
+ array( 'media_upload_image' => 'wp_media_upload_handler()', '3.3' ),
193
+ array( 'media_upload_audio' => 'wp_media_upload_handler()', '3.3' ),
194
+ array( 'media_upload_video' => 'wp_media_upload_handler()', '3.3' ),
195
+ array( 'media_upload_file' => 'wp_media_upload_handler()', '3.3' ),
196
+ array( 'type_url_form_image' => 'wp_media_insert_url_form( \'image\' )', '3.3' ),
197
+ array( 'type_url_form_audio' => 'wp_media_insert_url_form( \'audio\' )', '3.3' ),
198
+ array( 'type_url_form_video' => 'wp_media_insert_url_form( \'video\' )', '3.3' ),
199
+ array( 'type_url_form_file' => 'wp_media_insert_url_form( \'file\' )', '3.3' ),
200
+ array( 'add_contextual_help' => 'get_current_screen()->add_help_tab()', '3.3' ),
201
+
202
+ array( 'get_allowed_themes' => 'wp_get_themes( array( \'allowed\' => true ) )', '3.4' ),
203
+ array( 'get_broken_themes' => 'wp_get_themes( array( \'errors\' => true )', '3.4' ),
204
+ array( 'current_theme_info' => 'wp_get_theme()', '3.4' ),
205
+
206
+ array( '_insert_into_post_button' => '', '3.5' ),
207
+ array( '_media_button' => '', '3.5' ),
208
+ array( 'get_post_to_edit' => 'get_post()', '3.5' ),
209
+ array( 'get_default_page_to_edit' => 'get_default_post_to_edit()', '3.5' ),
210
+ array( 'wp_create_thumbnail' => 'image_resize()', '3.5' ),
211
+
212
+ array( 'wp_nav_menu_locations_meta_box' => '', '3.6' ),
213
+
214
+ array( 'the_attachment_links' => '', '3.7'),
215
+ array( 'wp_update_core' => 'new Core_Upgrader()', '3.7'),
216
+ array( 'wp_update_plugin' => 'new Plugin_Upgrader()', '3.7'),
217
+ array( 'wp_update_theme' => 'new Theme_Upgrader()', '3.7'),
218
+ array( '_search_terms_tidy' => '', '3.7' ),
219
+ array( 'get_blogaddress_by_domain' => '', '3.7' ),
220
+
221
+ array( 'get_screen_icon' => '', '3.8' ),
222
+ array( 'screen_icon' => '', '3.8' ),
223
+ array( 'wp_dashboard_incoming_links' => '', '3.8' ),
224
+ array( 'wp_dashboard_incoming_links_control' => '', '3.8' ),
225
+ array( 'wp_dashboard_incoming_links_output' => '', '3.8' ),
226
+ array( 'wp_dashboard_plugins' => '', '3.8' ),
227
+ array( 'wp_dashboard_primary_control' => '', '3.8' ),
228
+ array( 'wp_dashboard_recent_comments_control' => '', '3.8' ),
229
+ array( 'wp_dashboard_secondary' => '', '3.8' ),
230
+ array( 'wp_dashboard_secondary_control' => '', '3.8' ),
231
+ array( 'wp_dashboard_secondary_output' => '', '3.8' ),
232
+
233
+ array( 'rich_edit_exists' => '', '3.9'),
234
+ array( 'default_topic_count_text' => '', '3.9'),
235
+ array( 'format_to_post' => '', '3.9'),
236
+ array( 'get_current_site_name' => 'get_current_site()', '3.9'),
237
+ array( 'wpmu_current_site' => '', '3.9'),
238
+ array( '_relocate_children' => '', '3.9' ),
239
+
240
+ array( 'get_all_category_ids' => 'get_terms()', '4.0' ),
241
+ array( 'like_escape' => 'wpdb::esc_like()', '4.0' ),
242
+ array( 'url_is_accessable_via_ssl' => '', '4.0' ),
243
+ array( 'get_all_category_ids' => 'get_terms()', '4.0' ),
244
+ array( 'like_escape' => 'wpdb::esc_like()', '4.0' ),
245
+ array( 'url_is_accessable_via_ssl' => '', '4.0' ),
246
+
247
+ array( 'prepare_control' => '', '4.1' ),
248
+ array( 'add_tab' => '', '4.1' ),
249
+ array( 'remove_tab' => '', '4.1' ),
250
+ array( 'print_tab_image' => '', '4.1' ),
251
+
252
+ array( 'setup_widget_addition_previews' => 'customize_dynamic_setting_args', '4.2' ),
253
+ array( 'prepreview_added_sidebars_widgets' => 'customize_dynamic_setting_args', '4.2' ),
254
+ array( 'prepreview_added_widget_instance' => 'customize_dynamic_setting_args', '4.2' ),
255
+ array( 'remove_prepreview_filters' => 'customize_dynamic_setting_args', '4.2' ),
256
+
257
+ array( 'wp_get_http' => 'WP_Http', '4.4' ),
258
+
259
+ array( 'is_comments_popup' => '', '4.5' ),
260
+ array( 'add_object_page' => 'add_menu_page', '4.5' ),
261
+ array( 'add_utility_page' => 'add_menu_page', '4.5' ),
262
+ array( 'get_comments_popup_template' => '', '4.5' ),
263
+ array( 'comments_popup_script' => '', '4.5' ),
264
+ array( 'popuplinks' => '', '4.5' ),
265
+ array( 'get_currentuserinfo' => 'wp_get_current_user', '4.5' ),
266
+
267
+ );
268
  foreach ( $php_files as $php_key => $phpfile ) {
269
  foreach ( $checks as $alt => $check ) {
270
  checkcount();
 
271
  $key = key( $check );
272
  $alt = $check[ $key ];
273
+ if ( preg_match( '/(?<!function)[\s?]' . $key . '\s?\(/', $phpfile, $matches ) ) {
274
  $filename = tc_filename( $php_key );
275
  $error = ltrim( rtrim( $matches[0], '(' ) );
276
  $version = $check[0];
277
  $grep = tc_grep( $error, $php_key );
278
+
279
+ // Point out the deprecated function.
280
+ $error_msg = sprintf(
281
+ __( '%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check' ),
282
+ '<strong>' . $error . '()</strong>',
283
+ '<strong>' . $filename . '</strong>',
284
+ '<strong>' . $version . '</strong>'
285
+ );
286
+
287
+ // Add alternative function when available.
288
+ if ( $alt ) {
289
+ $error_msg .= ' ' . sprintf( __( 'Use %s instead.', 'theme-check' ), '<strong>' . $alt . '</strong>' );
290
+ }
291
+
292
+ // Add the precise code match that was found.
293
+ $error_msg .= $grep;
294
+
295
+ // Add the finalized error message.
296
+ $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . $error_msg;
297
+
298
  $ret = false;
299
  }
300
  }
304
 
305
  function getError() { return $this->error; }
306
  }
307
+ $themechecks[] = new Deprecated;
checks/deregister.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class DeregisterCheck implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+
7
+ $ret = true;
8
+ checkcount();
9
+
10
+ foreach ( $php_files as $file_path => $file_content ) {
11
+
12
+ $filename = tc_filename( $file_path );
13
+
14
+ if ( preg_match( '/wp_deregister_script/', $file_content) ) {
15
+
16
+ $error = '/wp_deregister_script/';
17
+ $grep = tc_preg( $error, $file_path );
18
+
19
+ $this->error[] = sprintf( '<span class="tc-lead tc-warning">' . __('WARNING','theme-check') . '</span>: ' . __( 'Found wp_deregister_script in %1$s. Themes must not deregister core scripts.', 'theme-check' ),
20
+ '<strong>' . $filename . '</strong>') . $grep;
21
+ $ret = false;
22
+ }
23
+ }
24
+ return $ret;
25
+
26
+ }
27
+
28
+ function getError() { return $this->error; }
29
+ }
30
+ $themechecks[] = new DeregisterCheck;
checks/directories.php CHANGED
@@ -15,16 +15,16 @@ class DirectoriesCheck implements themecheck {
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
 
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
 
checks/editorstyle.php CHANGED
@@ -10,7 +10,7 @@ class EditorStyleCheck implements themecheck {
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;
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;
checks/favicon.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FaviconCheck implements themecheck {
4
+ protected $error = array();
5
+
6
+ function check( $php_files, $css_files, $other_files ) {
7
+
8
+ $ret = true;
9
+
10
+ checkcount();
11
+
12
+ foreach ( $php_files as $file_path => $file_content ) {
13
+
14
+ $filename = tc_filename( $file_path );
15
+
16
+ if ( preg_match( '/(<link rel=[\'"]icon[\'"])|(<link rel=[\'"]apple-touch-icon-precomposed[\'"])|(<meta name=[\'"]msapplication-TileImage[\'"])/', $file_content, $matches ) ) {
17
+ $this->error[] = sprintf( '<span class="tc-lead tc-info">' . __('INFO','theme-check') . '</span>: ' . __( 'Possible Favicon found in %1$s. Favicons are handled by the Site Icon setting in the customizer since version 4.3.', 'theme-check' ),
18
+ '<strong>' . $filename . '</strong>');
19
+ }
20
+ }
21
+ return $ret;
22
+ }
23
+
24
+ function getError() { return $this->error; }
25
+ }
26
+ $themechecks[] = new FaviconCheck;
checks/filenames.php CHANGED
@@ -18,43 +18,44 @@ class File_Checks implements themecheck {
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
 
@@ -63,4 +64,4 @@ class File_Checks implements themecheck {
63
 
64
  function getError() { return $this->error; }
65
  }
66
- $themechecks[] = new File_Checks;
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
+ '\.lubith' => __( 'Lubith theme generator file', 'theme-check' ),
34
  );
35
 
36
+ $musthave = array( 'index.php', 'style.css' );
37
+ $rechave = array( 'readme.txt' => __( 'Please see <a href="https://codex.wordpress.org/Theme_Review#Theme_Documentation">Theme_Documentation</a> for more information.', 'theme-check' ) );
38
 
39
  checkcount();
40
 
41
  foreach( $blacklist as $file => $reason ) {
42
  if ( $filename = preg_grep( '/' . $file . '/', $filenames ) ) {
43
  $error = implode( array_unique( $filename ), ' ' );
44
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'.__('WARNING','theme-check').'</span>: '.__('%1$s %2$s found.', 'theme-check'), '<strong>' . $error . '</strong>', $reason) ;
45
  $ret = false;
46
  }
47
  }
48
 
49
  foreach( $musthave as $file ) {
50
  if ( !in_array( $file, $filenames ) ) {
51
+ $this->error[] = sprintf('<span class="tc-lead tc-warning">'.__('WARNING','theme-check').'</span>: '.__('Could not find the file %s in the theme.', 'theme-check'), '<strong>' . $file . '</strong>' );
52
  $ret = false;
53
  }
54
  }
55
 
56
  foreach( $rechave as $file => $reason ) {
57
  if ( !in_array( $file, $filenames ) ) {
58
+ $this->error[] = sprintf('<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('Could not find the file %1$s in the theme. %2$s', 'theme-check'), '<strong>' . $file . '</strong>', $reason );
59
  }
60
  }
61
 
64
 
65
  function getError() { return $this->error; }
66
  }
67
+ $themechecks[] = new File_Checks;
checks/{artisteer.php → generated.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class ArtisteerCheck implements themecheck {
4
  protected $error = array();
5
 
6
  function check( $php_files, $css_files, $other_files) {
@@ -12,16 +12,25 @@ class ArtisteerCheck implements themecheck {
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
 
@@ -30,4 +39,4 @@ class ArtisteerCheck implements themecheck {
30
 
31
  function getError() { return $this->error; }
32
  }
33
- $themechecks[] = new ArtisteerCheck;
1
  <?php
2
 
3
+ class GeneratedCheck implements themecheck {
4
  protected $error = array();
5
 
6
  function check( $php_files, $css_files, $other_files) {
12
 
13
  $ret = true;
14
  if (
15
+ //Artisteer
16
  strpos( $php, 'art_normalize_widget_style_tokens' ) !== false
17
  || strpos( $php, 'art_include_lib' ) !== false
18
+ || strpos( $php, '_remove_last_slash($url) {' ) !== false
19
  || strpos( $php, 'adi_normalize_widget_style_tokens' ) !== false
20
  || strpos( $php, 'm_normalize_widget_style_tokens' ) !== false
21
  || strpos ( $php, "bw = '<!--- BEGIN Widget --->';" ) !== false
22
  || strpos ( $php, "ew = '<!-- end_widget -->';" ) !== false
23
  || strpos ( $php, "end_widget' => '<!-- end_widget -->'") !== false
24
+ //Lubith
25
+ || strpos ( $php, "Lubith") !== false
26
+ //Templatetoaster
27
+ || strpos ( $php, "templatetoaster_") !== false
28
+ || strpos ( $php, "Templatetoaster_") !== false
29
+ || strpos ( $php, "@package templatetoaster") !== false
30
+ //wpthemegenerator
31
+ || strpos ( $php, "wptg_") !== false
32
  ) {
33
+ $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' );
34
  $ret = false;
35
  }
36
 
39
 
40
  function getError() { return $this->error; }
41
  }
42
+ $themechecks[] = new GeneratedCheck;
checks/gravatar.php CHANGED
@@ -12,7 +12,7 @@ class GravatarCheck implements themecheck {
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
 
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
 
checks/i18n.php CHANGED
@@ -9,13 +9,13 @@ class I18NCheck implements themecheck {
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;
@@ -36,7 +36,7 @@ class I18NCheck implements themecheck {
36
  $search = substr($search,$i);
37
  }
38
  }
39
-
40
  foreach ( $stmts as $match ) {
41
  $tokens = @token_get_all('<?php '.$match.';');
42
  if (!empty($tokens)) {
@@ -45,16 +45,22 @@ class I18NCheck implements themecheck {
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
  }
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;
36
  $search = substr($search,$i);
37
  }
38
  }
39
+
40
  foreach ( $stmts as $match ) {
41
  $tokens = @token_get_all('<?php '.$match.';');
42
  if (!empty($tokens)) {
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 = '';
49
+ if ( isset( $line[0] ) ) {
50
+ $error = ( !strpos( $error, $line[0] ) ) ? $grep : '';
51
+ }
52
+ $this->error[] = sprintf('<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</span>: '.__('Possible variable %1$s found in translation function in %2$s. Translation function calls must NOT contain PHP variables. %3$s','theme-check'),
53
+ '<strong>' . $token[1] . '</strong>',
54
+ '<strong>' . $filename . '</strong>',
55
+ $error
56
+ );
57
  break; // stop looking at the tokens on this line once a variable is found
58
  }
59
  }
60
  }
61
  }
62
+
63
+
64
  }
65
  return $ret;
66
  }
checks/iframes.php CHANGED
@@ -6,7 +6,7 @@ class IframeCheck implements themecheck {
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 ) {
@@ -17,7 +17,7 @@ class IframeCheck implements themecheck {
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
  }
6
  $ret = true;
7
 
8
  $checks = array(
9
+ '/<(iframe)[^>]*>/' => __( 'iframes are sometimes used to load unwanted adverts and code on your site', 'theme-check' )
10
  );
11
 
12
  foreach ( $php_files as $php_key => $phpfile ) {
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','theme-check').'</span>: '.__('%1$s was found in the file %2$s %3$s.%4$s', 'theme-check'), '<strong>' . $error . '</strong>', '<strong>' . $filename . '</strong>', $check, $grep ) ;
21
  }
22
  }
23
  }
checks/include.php CHANGED
@@ -7,16 +7,16 @@ class IncludeCheck implements themecheck {
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
 
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.', 'theme-check' ) );
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','theme-check').'</span>: '.__('%1$s %2$s %3$s', 'theme-check' ), '<strong>' . $filename . '</strong>', $check, $grep );
20
  }
21
  }
22
 
checks/included-plugins.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class IncludedPlugins implements themecheck {
3
+ protected $error = array();
4
+
5
+ function check( $php_files, $css_files, $other_files ) {
6
+ $ret = true;
7
+
8
+ $filenames = array();
9
+
10
+ foreach ( $other_files as $other_key => $otherfile ) {
11
+ array_push( $filenames, strtolower( basename( $other_key ) ) );
12
+ }
13
+
14
+ $blacklist = array(
15
+ '\.zip' => __( 'Zipped Plugin', 'theme-check' ),
16
+ );
17
+
18
+ checkcount();
19
+
20
+ foreach ( $blacklist as $file => $reason ) {
21
+ if ( $filename = preg_grep( '/' . $file . '/', $filenames ) ) {
22
+ $error = implode( array_unique( $filename ), ' ' );
23
+ $this->error[] = sprintf( '<span class="tc-lead tc-required">' . __( 'REQUIRED','theme-check' ) . '</span>: ' . __( '<strong>Zip file found.</strong> Plugins are not allowed in themes. The zip file found was <em>%s</em>.', 'theme-check' ), $error );
24
+ $ret = false;
25
+ }
26
+ }
27
+
28
+ return $ret;
29
+ }
30
+
31
+ function getError() { return $this->error; }
32
+ }
33
+
34
+ $themechecks[] = new IncludedPlugins;
checks/lineendings.php CHANGED
@@ -8,7 +8,7 @@ class LineEndingsCheck implements themecheck {
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
  }
@@ -17,18 +17,18 @@ class LineEndingsCheck implements themecheck {
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
  }
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','theme-check').'</span>: '.__('Both DOS and UNIX style line endings were found in the file %1$s. 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.', 'theme-check'), '<strong>' . $filename . '</strong>' );
12
  $ret = false;
13
  }
14
  }
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','theme-check').'</span>: '.__('Both DOS and UNIX style line endings were found in the file %1$s. 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.', 'theme-check'), '<strong>' . $filename . '</strong>' );
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','theme-check').'</span>: '.__('Both DOS and UNIX style line endings were found in the file %1$s. 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.', 'theme-check'), '<strong>' . $filename . '</strong>' );
32
  $ret = false;
33
  }
34
  }
checks/links.php CHANGED
@@ -15,16 +15,15 @@ class Check_Links implements themecheck {
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
  }
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
  foreach( $out as $key ) {
19
  if ( preg_match( '/\<a\s?href\s?=\s?["|\'](.*?)[\'|"](.*?)\>(.*?)\<\/a\>/is', $key[0], $stripped ) ) {
20
  if ( !empty( $data['AuthorURI'] ) && !empty( $data['URI'] ) && $stripped[1] && !strpos( $stripped[1], $data['URI'] ) && !strpos( $stripped[1], $data['AuthorURI'] ) && !strpos( $stripped[1], 'wordpress.' ) ) {
21
  $grep .= tc_grep( $stripped[1], $php_key );
22
  }
23
  }
24
+ }
25
+ if ( $grep ) {
26
+ $this->error[] = sprintf('<span class="tc-lead tc-info">'.__('INFO','theme-check').'</span>: '.__('Possible hard-coded links were found in the file %1$s.%2$s', 'theme-check'), '<strong>' . $filename . '</strong>', $grep);
27
  }
28
  }
29
  }
checks/malware.php CHANGED
@@ -6,7 +6,7 @@ class MalwareCheck implements themecheck {
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 ) {
@@ -20,10 +20,10 @@ class MalwareCheck implements themecheck {
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;
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?\(/' => __( 'File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls', 'theme-check' ),
10
  );
11
 
12
  foreach ( $php_files as $php_key => $phpfile ) {
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','theme-check').'</span>: '.__('%1$s was found in the file %2$s %3$s.%4$s', 'theme-check'), '<strong>' . $error. '</strong>', '<strong>' . $filename . '</strong>', $check, $grep );
24
  $ret = false;
25
  }
26
+ }
27
  }
28
  }
29
  return $ret;
checks/more_deprecated.php CHANGED
@@ -1,5 +1,9 @@
1
  <?php
2
 
 
 
 
 
3
  class More_Deprecated implements themecheck {
4
  protected $error = array();
5
 
@@ -8,22 +12,50 @@ class More_Deprecated implements themecheck {
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
 
1
  <?php
2
 
3
+ /**
4
+ * Checks for the use of deprecated function parameters.
5
+ */
6
+
7
  class More_Deprecated implements themecheck {
8
  protected $error = array();
9
 
12
  $ret = true;
13
 
14
  $checks = array(
15
+ 'get_bloginfo' => array(
16
+ 'home' => 'home_url()',
17
+ 'url' => 'home_url()',
18
+ 'wpurl' => 'site_url()',
19
+ 'stylesheet_directory' => 'get_stylesheet_directory_uri()',
20
+ 'template_directory' => 'get_template_directory_uri()',
21
+ 'template_url' => 'get_template_directory_uri()',
22
+ 'text_direction' => 'is_rtl()',
23
+ 'feed_url' => "get_feed_link( 'feed' ), where feed is rss, rss2 or atom",
24
+ ),
25
+ 'bloginfo' => array(
26
+ 'home' => 'echo esc_url( home_url() )',
27
+ 'url' => 'echo esc_url( home_url() )',
28
+ 'wpurl' => 'echo esc_url( site_url() )',
29
+ 'stylesheet_directory' => 'echo esc_url( get_stylesheet_directory_uri() )',
30
+ 'template_directory' => 'echo esc_url( get_template_directory_uri() )',
31
+ 'template_url' => 'echo esc_url( get_template_directory_uri() )',
32
+ 'text_direction' => 'is_rtl()',
33
+ 'feed_url' => "echo esc_url( get_feed_link( 'feed' ) ), where feed is rss, rss2 or atom",
34
+ ),
35
+ 'get_option' => array(
36
+ 'home' => 'home_url()',
37
+ 'site_url' => 'site_url()',
38
+ )
39
+ );
40
 
41
+ foreach ( $php_files as $php_key => $php_file ) {
42
+ // Loop through all functions.
43
+ foreach ( $checks as $function => $data ) {
44
  checkcount();
45
+
46
+ // Loop through the parameters and look for all function/parameter combinations.
47
+ foreach ( $data as $parameter => $replacement ) {
48
+ if ( preg_match( '/' . $function . '\(\s*("|\')' . $parameter . '("|\')\s*\)/', $php_file, $matches ) ) {
49
+ $filename = tc_filename( $php_key );
50
+ $error = ltrim( rtrim( $matches[0], '(' ) );
51
+ $grep = tc_grep( $error, $php_key );
52
+ $this->error[] = sprintf( '<span class="tc-lead tc-required">' . __( 'REQUIRED', 'theme-check' ) . '</span>: ' . __( '%1$s was found in the file %2$s. Use %3$s instead.%4$s', 'theme-check' ), '<strong>' . $error . '</strong>', '<strong>' . $filename . '</strong>', '<strong>' . $replacement . '</strong>', $grep );
53
+ $ret = false;
54
+ }
55
  }
56
  }
57
  }
58
+
59
  return $ret;
60
  }
61
 
checks/navmenu.php CHANGED
@@ -11,7 +11,7 @@ class NavMenuCheck implements themecheck {
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;
11
  $php = implode( ' ', $php_files );
12
  checkcount();
13
  if ( strpos( $php, 'nav_menu' ) === false ) {
14
+ $this->error[] = '<span class="tc-lead tc-recommended">'.__('RECOMMENDED','theme-check').'</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.", 'theme-check' );
15
  }
16
 
17
  return $ret;
checks/nonprintable.php CHANGED
@@ -13,7 +13,7 @@ class NonPrintableCheck implements themecheck {
13
  if ( preg_match('/[\x00-\x08\x0B-\x0C\x0E-\x1F\x80-\xFF]/', $content, $matches ) ) {
14
  $filename = tc_filename( $name );
15
  $non_print = tc_preg( '/[\x00-\x08\x0B-\x0C\x0E-\x1F\x80-\xFF]/', $name );
16
- $this->error[] = sprintf(__('<span class="tc-lead tc-info">INFO</span>: Non-printable characters were found in the <strong>%1$s</strong> file. You may want to check this file for errors.%2$s', 'themecheck'), $filename, $non_print);
17
  }
18
  }
19
 
13
  if ( preg_match('/[\x00-\x08\x0B-\x0C\x0E-\x1F\x80-\xFF]/', $content, $matches ) ) {
14
  $filename = tc_filename( $name );
15
  $non_print = tc_preg( '/[\x00-\x08\x0B-\x0C\x0E-\x1F\x80-\xFF]/', $name );
16
+ $this->error[] = sprintf('<span class="tc-lead tc-info">'.__('INFO','theme-check').'</span>: '.__('Non-printable characters were found in the %1$s file. You may want to check this file for errors.%2$s', 'theme-check'), '<strong>' . $filename . '</strong>', $non_print);
17
  }
18
  }