-
-
Notifications
You must be signed in to change notification settings - Fork 461
/
RestrictedFunctionsStandard.xml
50 lines (50 loc) · 1.52 KB
/
RestrictedFunctionsStandard.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<documentation title="Restricted Date and Time Functions">
<standard>
<![CDATA[
The restricted functions date_default_timezone_set() and date() should not be used.
]]>
</standard>
<standard>
<![CDATA[
Using the PHP native date_default_timezone_set() function isn't allowed, because WordPress Core needs the default time zone to be set to UTC for timezone calculations using the WP Core API to work correctly.
]]>
</standard>
<code_comparison>
<code title="Valid: Using DateTime object.">
<![CDATA[
$date = new <em>DateTime()</em>;
$date->setTimezone(
new DateTimeZone( 'Europe/Amsterdam' )
);
]]>
</code>
<code title="Invalid: Using date_default_timezone_set().">
<![CDATA[
<em>date_default_timezone_set</em>( 'Europe/Amsterdam' );
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Using the PHP native date() function isn't allowed, as it is affected by runtime timezone changes which can cause the date/time to be incorrectly displayed. Use gmdate() instead.
]]>
</standard>
<code_comparison>
<code title="Valid: Using gmdate().">
<![CDATA[
$last_updated = <em>gmdate</em>(
'Y-m-d\TH:i:s',
strtotime( $plugin['last_updated'] )
);
]]>
</code>
<code title="Invalid: Using date().">
<![CDATA[
$last_updated = <em>date</em>(
'Y-m-d\TH:i:s',
strtotime( $plugin['last_updated'] )
);
]]>
</code>
</code_comparison>
</documentation>