Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions WordPress/Docs/WP/DiscouragedConstantsStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Discouraged Constants"
>
<standard>
<![CDATA[
The use of certain WordPress constants is discouraged. Examples include `TEMPLATEPATH` and `STYLESHEETPATH`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The use of certain WordPress constants is discouraged. Examples include `TEMPLATEPATH` and `STYLESHEETPATH`.
The use and (re-)declaration of certain WordPress native constants is discouraged. Examples include `TEMPLATEPATH` and `STYLESHEETPATH`.

]]>
</standard>
<code_comparison>
<code title="Valid: Function used instead of constant.">
<![CDATA[
$subdir = <em>get_template_directory()</em> . '/subdir';
]]>
</code>
<code title="Invalid: The TEMPLATEPATH constant is used in the code.">
<![CDATA[
$subdir = <em>TEMPLATEPATH</em> . '/subdir';
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The use of certain WordPress constants is discouraged. Examples include `TEMPLATEPATH` and `STYLESHEETPATH`.
]]>
</standard>
Comment on lines +23 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate <standard> block is unnecessary.

A <standard> can have multiple <code_comparison> blocks associated with it, so this block should be removed.

<code_comparison>
<code title="Valid: Function used instead of constant.">
<![CDATA[
$dir = <em>get_stylesheet_directory()</em>;
]]>
</code>
<code title="Invalid: The STYLESHEETPATH constant is used in the code.">
<![CDATA[
$dir = <em>STYLESHEETPATH</em>;
]]>
</code>
</code_comparison>
</documentation>
Loading