Skip to content

Commit c15f4b2

Browse files
authored
Merge pull request #762 from Automattic/fix/740-includingfile-prevent-some-false-positives
2 parents 3e73ba2 + 08c3909 commit c15f4b2

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,33 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
2525
* @var array
2626
*/
2727
public $getPathFunctions = [
28-
'plugin_dir_path',
2928
'dirname',
29+
'get_404_template',
30+
'get_archive_template',
31+
'get_attachment_template',
32+
'get_author_template',
33+
'get_category_template',
34+
'get_date_template',
35+
'get_embed_template',
36+
'get_front_page_template',
37+
'get_page_template',
38+
'get_paged_template', // Deprecated, but should still be accepted for the purpose of this sniff.
39+
'get_home_template',
40+
'get_index_template',
41+
'get_parent_theme_file_path',
42+
'get_privacy_policy_template',
43+
'get_query_template',
44+
'get_search_template',
45+
'get_single_template',
46+
'get_singular_template',
3047
'get_stylesheet_directory',
48+
'get_tag_template',
49+
'get_taxonomy_template',
3150
'get_template_directory',
32-
'locate_template',
33-
'get_parent_theme_file_path',
3451
'get_theme_file_path',
52+
'locate_block_template',
53+
'locate_template',
54+
'plugin_dir_path',
3555
];
3656

3757
/**

WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ include_once dir_function(); // Error - custom functionm with keyword from $al
3434
require CUSTOM_CONSTANT_DIR . 'file.php'; // OK.
3535
require_once ( VIPCS_PATH ) . 'file.php'; // OK.
3636
include_once
37-
DIR_CUSTOM , 'file.php'; // OK.
37+
DIR_CUSTOM , 'file.php'; // OK.
38+
39+
// These are valid (previously false positives).
40+
include( get_404_template() );
41+
require get_query_template( 'post' );
42+
include_once locate_block_template( __DIR__, 'silly_block' );

0 commit comments

Comments
 (0)