基础代码
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<documentation title="Valid Hook Name">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
Use lowercase letters in action and filter names. Separate words using underscores.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: lowercase hook name.">
|
||||
<![CDATA[
|
||||
do_action( <em>'prefix_hook_name'</em>, $var );
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: mixed case hook name.">
|
||||
<![CDATA[
|
||||
do_action( <em>'Prefix_Hook_NAME'</em>, $var );
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<code_comparison>
|
||||
<code title="Valid: words separated by underscores.">
|
||||
<![CDATA[
|
||||
apply_filters( <em>'prefix_hook_name'</em>, $var );
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: using non-underscore characters to separate words.">
|
||||
<![CDATA[
|
||||
apply_filters( <em>'prefix\hook-name'</em>, $var );
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
||||
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
<documentation title="Validate post type slugs">
|
||||
<standard>
|
||||
<![CDATA[
|
||||
The post type slug used in register_post_type() must be between 1 and 20 characters.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: short post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'my_short_slug'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: too long post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'my_own_post_type_too_long'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<standard>
|
||||
<![CDATA[
|
||||
The post type slug used in register_post_type() can only contain lowercase alphanumeric characters, dashes and underscores.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: no special characters in post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'my_post_type_slug'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: invalid characters in post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'my/post/type/slug'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<standard>
|
||||
<![CDATA[
|
||||
One should be careful with passing dynamic slug names to "register_post_type()", as the slug may become too long and could contain invalid characters.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: static post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'my_post_active'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: dynamic post type slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>"my_post_{$status}"</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<standard>
|
||||
<![CDATA[
|
||||
The post type slug used in register_post_type() can not use reserved keywords, such as the ones used by WordPress itself.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: prefixed post slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'prefixed_author'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: using a reserved keyword as slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'author'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
<standard>
|
||||
<![CDATA[
|
||||
The post type slug used in register_post_type() can not use reserved prefixes, such as 'wp_', which is used by WordPress itself.
|
||||
]]>
|
||||
</standard>
|
||||
<code_comparison>
|
||||
<code title="Valid: custom prefix post slug.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'prefixed_author'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
<code title="Invalid: using a reserved prefix.">
|
||||
<![CDATA[
|
||||
register_post_type(
|
||||
<em>'wp_author'</em>,
|
||||
array()
|
||||
);
|
||||
]]>
|
||||
</code>
|
||||
</code_comparison>
|
||||
</documentation>
|
||||
Reference in New Issue
Block a user