wp_credits_section_list( array $credits = array(), string $slug = '' )
- Since
- 5.3.0
- Source
wp-admin/includes/credits.php:122
Compatibility
- WordPress
- since 5.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$creditsarrayoptional- The credits groups returned from the API.Default:
array() $slugstringoptional- The current group to display.Default:
''
Performance profile
How much work a call to wp_credits_section_list() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 11–43
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_user_by().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 155.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below wp_credits_section_list() - optionoption read or write
get_option()one call below wp_credits_section_list() - querycontent query
get_user_by()one call below wp_credits_section_list()
Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_credits_section_list() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 11–39 | none |
$group_data && empty($group_data) | 31–37 | array_walk(), wp_sprintf() |
$group_data && !empty($group_data) | 34–43 | shuffle() |
$group_data && !empty($group_data) | 35–41 | shuffle(), array_walk(), wp_sprintf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 155 | 11–43 | 12 | |
| 8.5 | 155 | 11–43 | 12 | |
| 8.4 | 155 | 11–43 | 12 | |
| 8.3 | 155 | 11–43 | 12 | |
| 8.2 | 155 | 11–43 | 12 | 1 more instruction than PHP 8.1 |
| 8.1 | 154 | 11–43 | 12 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 155 | 11–44 | 12 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- wp_sprintf()WordPress' implementation of PHP sprintf() with filters.
- esc_attr()Escaping for HTML attributes.
- esc_url()Checks and cleans a URL.
- get_avatar_data()Retrieves default data about the avatar.
- esc_html()Escaping for HTML blocks.
- translate()Retrieves the translation of $text.
Source code
function wp_credits_section_list( $credits = array(), $slug = '' ) { $group_data = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array(); $credits_data = $credits['data']; if ( ! count( $group_data ) ) { return; } if ( ! empty( $group_data['shuffle'] ) ) { shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. } switch ( $group_data['type'] ) { case 'list': array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] ); echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; break; case 'libraries': array_walk( $group_data['data'], '_wp_credits_build_object_link' ); echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; break; default: $compact = 'compact' === $group_data['type']; $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' ); echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n"; foreach ( $group_data['data'] as $person_data ) { echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t"; echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">'; $size = $compact ? 80 : 160; $data = get_avatar_data( $person_data[1] . '@sha256.gravatar.com', array( 'size' => $size ) ); $data2x = get_avatar_data( $person_data[1] . '@sha256.gravatar.com', array( 'size' => $size * 2 ) ); echo '<span class="wp-person-avatar"><img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" /></span>' . "\n"; echo esc_html( $person_data[0] ) . "</a>\n\t"; if ( ! $compact && ! empty( $person_data[3] ) ) { // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n"; } echo "</li>\n"; } echo "</ul>\n"; break; }}Changelog
Introduced in 5.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-admin/includes/credits.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.