Skip to content

Commit a107147

Browse files
committed
Twenty Eleven: Improve PHP docblocks with corrected descriptions, missing/corrected tags, and specific types.
Developed in #10482 Props huzaifaalmesbah, dhruvang21, juanfra, sabernhardt, noruzzaman, ravichudasama01, westonruter. See #64224. Fixes #64211. git-svn-id: https://develop.svn.wordpress.org/trunk@61309 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 55145d5 commit a107147

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

src/wp-content/themes/twentyeleven/inc/theme-options.php

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
/**
11-
* Properly enqueues styles and scripts for our theme options page.
11+
* Enqueues styles and scripts for the theme options page.
1212
*
1313
* This function is attached to the admin_enqueue_scripts action hook.
1414
*
@@ -75,6 +75,8 @@ function twentyeleven_theme_options_init() {
7575
* By default, only administrators have either of these capabilities, but the desire here is
7676
* to allow for finer-grained control for roles and users.
7777
*
78+
* @since Twenty Eleven 1.1
79+
*
7880
* @param string $capability The capability used for the page, which is manage_options by default.
7981
* @return string The capability to actually use.
8082
*/
@@ -84,7 +86,7 @@ function twentyeleven_option_page_capability( $capability ) {
8486
add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' );
8587

8688
/**
87-
* Adds a theme options page to the admin menu, including some help documentation.
89+
* Adds the theme options page to the admin menu, including help documentation.
8890
*
8991
* This function is attached to the admin_menu action hook.
9092
*
@@ -107,6 +109,11 @@ function twentyeleven_theme_options_add_page() {
107109
}
108110
add_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
109111

112+
/**
113+
* Adds help documentation to the theme options page.
114+
*
115+
* @since Twenty Eleven 1.3
116+
*/
110117
function twentyeleven_theme_options_help() {
111118

112119
$help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'twentyeleven' ) . '</p>' .
@@ -144,6 +151,8 @@ function twentyeleven_theme_options_help() {
144151
* Returns an array of color schemes registered for Twenty Eleven.
145152
*
146153
* @since Twenty Eleven 1.0
154+
*
155+
* @return array<string, array<string, string>> An associative array of color scheme options.
147156
*/
148157
function twentyeleven_color_schemes() {
149158
$color_scheme_options = array(
@@ -166,7 +175,7 @@ function twentyeleven_color_schemes() {
166175
*
167176
* @since Twenty Eleven 1.0
168177
*
169-
* @param array $color_scheme_options An associative array of color scheme options.
178+
* @param array<string, array<string, string>> $color_scheme_options An associative array of color scheme options.
170179
*/
171180
return apply_filters( 'twentyeleven_color_schemes', $color_scheme_options );
172181
}
@@ -175,6 +184,8 @@ function twentyeleven_color_schemes() {
175184
* Returns an array of layout options registered for Twenty Eleven.
176185
*
177186
* @since Twenty Eleven 1.0
187+
*
188+
* @return array<string, array<string, string>> An associative array of layout options.
178189
*/
179190
function twentyeleven_layouts() {
180191
$layout_options = array(
@@ -200,7 +211,7 @@ function twentyeleven_layouts() {
200211
*
201212
* @since Twenty Eleven 1.0
202213
*
203-
* @param array $layout_options An associative array of layout options.
214+
* @param array<string, array<string, string>> $layout_options An associative array of layout options.
204215
*/
205216
return apply_filters( 'twentyeleven_layouts', $layout_options );
206217
}
@@ -210,7 +221,7 @@ function twentyeleven_layouts() {
210221
*
211222
* @since Twenty Eleven 1.0
212223
*
213-
* @return array An array of default theme options.
224+
* @return array<string, string> An array of default theme options.
214225
*/
215226
function twentyeleven_get_default_theme_options() {
216227
$default_theme_options = array(
@@ -228,7 +239,7 @@ function twentyeleven_get_default_theme_options() {
228239
*
229240
* @since Twenty Eleven 1.0
230241
*
231-
* @param array $default_theme_options An array of default theme options.
242+
* @param array<string, string> $default_theme_options An array of default theme options.
232243
*/
233244
return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
234245
}
@@ -240,7 +251,7 @@ function twentyeleven_get_default_theme_options() {
240251
*
241252
* @param string $color_scheme Optional. Color scheme.
242253
* Default null (or the active color scheme).
243-
* @return string The default link color.
254+
* @return string|false The default link color, or false if not set.
244255
*/
245256
function twentyeleven_get_default_link_color( $color_scheme = null ) {
246257
if ( null === $color_scheme ) {
@@ -260,6 +271,8 @@ function twentyeleven_get_default_link_color( $color_scheme = null ) {
260271
* Returns the options array for Twenty Eleven.
261272
*
262273
* @since Twenty Eleven 1.0
274+
*
275+
* @return array<string, string> The theme options array.
263276
*/
264277
function twentyeleven_get_theme_options() {
265278
return get_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );
@@ -372,6 +385,7 @@ function twentyeleven_theme_options_render_page() {
372385
* @since Twenty Eleven 1.0
373386
*
374387
* @param array $input An array of form input.
388+
* @return array<string, string> An array of sanitized and validated form output.
375389
*/
376390
function twentyeleven_theme_options_validate( $input ) {
377391
$defaults = twentyeleven_get_default_theme_options();
@@ -401,9 +415,9 @@ function twentyeleven_theme_options_validate( $input ) {
401415
*
402416
* @since Twenty Eleven 1.0
403417
*
404-
* @param array $output An array of sanitized form output.
405-
* @param array $input An array of un-sanitized form input.
406-
* @param array $defaults An array of default theme options.
418+
* @param array<string, string> $output An array of sanitized form output.
419+
* @param array $input An array of un-sanitized form input.
420+
* @param array<string, string> $defaults An array of default theme options.
407421
*/
408422
return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );
409423
}
@@ -486,7 +500,8 @@ function twentyeleven_print_link_color_style() {
486500
*
487501
* @since Twenty Eleven 1.0
488502
*
489-
* @param array $existing_classes An array of existing body classes.
503+
* @param string[] $existing_classes An array of existing body classes.
504+
* @return string[] The filtered array of body classes.
490505
*/
491506
function twentyeleven_layout_classes( $existing_classes ) {
492507
$options = twentyeleven_get_theme_options();
@@ -511,8 +526,8 @@ function twentyeleven_layout_classes( $existing_classes ) {
511526
*
512527
* @since Twenty Eleven 1.0
513528
*
514-
* @param array $classes An array of body classes.
515-
* @param string $current_layout The current theme layout.
529+
* @param string[] $classes An array of body classes.
530+
* @param string $current_layout The current theme layout.
516531
*/
517532
$classes = apply_filters( 'twentyeleven_layout_classes', $classes, $current_layout );
518533

@@ -521,7 +536,7 @@ function twentyeleven_layout_classes( $existing_classes ) {
521536
add_filter( 'body_class', 'twentyeleven_layout_classes' );
522537

523538
/**
524-
* Implements Twenty Eleven theme options into Customizer
539+
* Implements Twenty Eleven theme options into Customizer.
525540
*
526541
* @since Twenty Eleven 1.3
527542
*

src/wp-content/themes/twentyeleven/inc/widgets.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function Twenty_Eleven_Ephemera_Widget() {
4949
*
5050
* @since Twenty Eleven 1.0
5151
*
52-
* @param array $args An array of standard parameters for widgets in this theme.
53-
* @param array $instance An array of settings for this widget instance.
52+
* @param array $args An array of standard parameters for widgets in this theme.
53+
* @param array<string, string|int> $instance An array of settings for this widget instance.
5454
*/
5555
public function widget( $args, $instance ) {
5656
$cache = wp_cache_get( 'widget_twentyeleven_ephemera', 'widget' );
@@ -156,6 +156,10 @@ public function widget( $args, $instance ) {
156156
* where any validation should be dealt with.
157157
*
158158
* @since Twenty Eleven 1.0
159+
*
160+
* @param array $new_instance New widget instance.
161+
* @param array $old_instance Original widget instance.
162+
* @return array<string, string|int> Updated widget instance.
159163
*/
160164
public function update( $new_instance, $old_instance ) {
161165
$instance = $old_instance;

0 commit comments

Comments
 (0)