Skip to content

Commit bf8558a

Browse files
authored
Merge pull request #447 from jenkoian/add-get-page-by-path-to-restricted-functions
Add get_page_by_path() warning to VIP restricted function sniffs.
2 parents 89d7b35 + 5a88cb0 commit bf8558a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ public function getGroups() {
326326
'create_function',
327327
],
328328
],
329+
'get_page_by_path' => [
330+
'type' => 'warning',
331+
'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_get_page_by_path() instead.',
332+
'functions' => [
333+
'get_page_by_path',
334+
],
335+
],
329336
];
330337

331338
$deprecated_vip_helpers = [

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,6 @@ update_site_option( $bar, 'foo' ); // Warning.
221221
update_option( 'foo', $bar ); // Ok.
222222
delete_site_option( $foo ); // Warning.
223223
delete_option( $bar ); // Ok.
224+
225+
wpcom_vip_get_page_by_path(); // Ok - VIP recommended version of get_page_by_path().
226+
get_page_by_path( $page_path ); // Warning.

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function getWarningList() {
133133
138 => 1,
134134
139 => 1,
135135
208 => 1,
136+
226 => 1,
136137
];
137138
}
138139

0 commit comments

Comments
 (0)