Skip to content

Commit a3da583

Browse files
committed
Attemp to improve the XML documentation by combining standards
1 parent 95afb67 commit a3da583

File tree

1 file changed

+41
-73
lines changed

1 file changed

+41
-73
lines changed

WordPress/Docs/WP/OptionAutoloadStandard.xml

+41-73
Original file line numberDiff line numberDiff line change
@@ -7,126 +7,94 @@
77
<![CDATA[
88
When using `add_option()`, `update_option()`, `wp_set_options_autoload()`,
99
`wp_set_option_autoload()`, or `wp_set_option_autoload_values()`, it is recommended to
10-
explicitly set the autoload parameter to ensure predictable behavior. This parameter determines whether
11-
the option is automatically loaded on every page load, which can impact site performance.
10+
explicitly set the autoload parameter to ensure predictable behavior. This parameter determines
11+
whether the option is automatically loaded on every page load, which can impact site performance.
1212
]]>
1313
</standard>
1414
<standard>
1515
<![CDATA[
16-
Even though the autoload parameter is optional for `add_option()` and `update_option()`, it is
17-
recommended to always explicitly set it.
16+
The following values should be used when setting the autoload parameter depending on the function:
17+
18+
- For `add_option()` and `update_option()`: `true`, `false`, or `null`.
19+
- For `wp_set_option_autoload_values()`, `wp_set_option_autoload()`, and
20+
`wp_set_options_autoload()`: `true` or `false`.
21+
22+
Using 'yes' or 'no' is deprecated since WordPress 6.6.0. Using 'auto', 'auto-on', 'auto-off',
23+
'on', or 'off' in plugin/theme code is strongly discouraged as those values are meant for
24+
internal-use only.
25+
26+
Any other values, including `null` for functions other than `add_option()` and `update_option()`
27+
are invalid.
1828
]]>
1929
</standard>
2030
<code_comparison>
21-
<code title="Valid: Explicitly setting the autoload parameter.">
31+
<code title="Valid: Using a boolean value or `null`">
2232
<![CDATA[
2333
add_option(
2434
'my_option',
2535
'value',
2636
'',
2737
<em>true</em>
2838
);
29-
]]>
30-
</code>
31-
<code title="Invalid: Autoload parameter missing.">
32-
<![CDATA[
33-
add_option(
34-
'my_option',
35-
'value',
36-
''
37-
);
38-
]]>
39-
</code>
40-
</code_comparison>
41-
<standard>
42-
<![CDATA[
43-
When calling the `add_option()` or `update_option()` functions, use `true`, `false` or `null`
44-
as the value for the autoload parameter. For the `wp_set_option_autoload_values()`,
45-
`wp_set_option_autoload()`, or `wp_set_options_autoload()` functions, use `true` or `false`.
4639
47-
Using 'yes' or 'no' as the value for the autoload parameter is deprecated since WordPress 6.6.0.
48-
]]>
49-
</standard>
50-
<code_comparison>
51-
<code title="Valid: Using a boolean value.">
52-
<![CDATA[
5340
update_option(
5441
'my_option',
5542
'value',
56-
<em>true</em>
43+
<em>null</em>
5744
);
5845
]]>
5946
</code>
60-
<code title="Invalid: Using a deprecated value.">
47+
<code title="Invalid: Using deprecated, internal-only, or invalid values">
6148
<![CDATA[
62-
update_option(
49+
add_option(
6350
'my_option',
6451
'value',
52+
'',
6553
<em>'yes'</em>
6654
);
67-
]]>
68-
</code>
69-
</code_comparison>
70-
<standard>
71-
<![CDATA[
72-
Use `true`|`false`|`null` if using `add_option()` or `update_option()` or `true`|`false` if
73-
using `wp_set_option_autoload_values()`, `wp_set_option_autoload()`, or
74-
`wp_set_options_autoload()`. It is strongly discouraged to use internal-only values ('auto',
75-
'auto-on', 'auto-off', 'on', 'off') in plugin or theme code.
76-
]]>
77-
</standard>
78-
<code_comparison>
79-
<code title="Valid: Using boolean values.">
80-
<![CDATA[
81-
wp_set_option_autoload_values(
82-
array(
83-
'my_option_1' => <em>true</em>,
84-
'my_option_2' => <em>false</em>
85-
)
55+
56+
wp_set_option_autoload(
57+
'my_option',
58+
<em>null</em>
8659
);
87-
]]>
88-
</code>
89-
<code title="Invalid: Using internal-only values.">
90-
<![CDATA[
60+
9161
wp_set_option_autoload_values(
9262
array(
93-
'my_option_1' => <em>'auto-on'</em>,
94-
'my_option_2' => <em>'auto-off'</em>
63+
'option1' => <em>'auto-on'</em>,
64+
'option2' => <em>'off'</em>
9565
)
9666
);
67+
68+
wp_set_options_autoload(
69+
array('option1', 'option2'),
70+
<em>1</em>
71+
);
9772
]]>
9873
</code>
9974
</code_comparison>
10075
<standard>
10176
<![CDATA[
102-
Only `true` and `false` are valid values for the autoload parameter, with one exception: `null`
103-
is also valid for `add_option()` and `update_option()`.
77+
Even though the autoload parameter is optional for `add_option()` and `update_option()`, it is
78+
recommended to always explicitly set it.
10479
]]>
10580
</standard>
10681
<code_comparison>
107-
<code title="Valid: Using `true`, `false`, or `null`.">
82+
<code title="Valid: Explicitly setting the autoload parameter.">
10883
<![CDATA[
109-
wp_set_options_autoload(
110-
array( 'my_option_1', 'my_option_2' ),
111-
<em>false</em>
112-
);
113-
114-
wp_set_option_autoload(
84+
add_option(
11585
'my_option',
86+
'value',
87+
'',
11688
<em>true</em>
11789
);
11890
]]>
11991
</code>
120-
<code title="Invalid: Using invalid values.">
92+
<code title="Invalid: Autoload parameter missing.">
12193
<![CDATA[
122-
wp_set_options_autoload(
123-
array( 'my_option_1', 'my_option_2' ),
124-
<em>1</em>
125-
);
126-
127-
wp_set_option_autoload(
94+
add_option(
12895
'my_option',
129-
<em>null</em> // `null` is invalid for this function.
96+
'value',
97+
''
13098
);
13199
]]>
132100
</code>

0 commit comments

Comments
 (0)