_list_meta_row( array $entry, int $count ): string
- Since
- 2.5.0
- Source
wp-admin/includes/template.php:631
Compatibility
- WordPress
- since 2.5.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
$entryarray- An array of meta data keyed on 'meta_key' and 'meta_value'.
$countint- Reference to the row number.
Return value
string- A single row of public meta data.
Performance profile
How much work a call to _list_meta_row() 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
- Moderate
- Scaling
- Constant
- Instructions
- 11–160
- Plugin surface
- None
- Called by
- 2
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 163.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- serializeserialisation
maybe_unserialize()called directly - hookthird-party callbacks
apply_filters()one call below _list_meta_row() - optionoption read or write
get_option()one call below _list_meta_row()
Further down the call graph this can also reach cache, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 7 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _list_meta_row() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
is_protected_meta() | 11 | is_protected_meta() |
!is_protected_meta() && is_serialized() && !is_serialized_string() | 27 | is_protected_meta(), is_serialized(), is_serialized_string() |
!is_protected_meta() && is_serialized() && !is_serialized_string() | 31 | is_protected_meta(), wp_create_nonce(), is_serialized(), is_serialized_string() |
!is_protected_meta() && !is_serialized() | 142 | is_protected_meta(), is_serialized(), esc_attr(), esc_textarea(), wp_create_nonce(), __(), __(), data-wp-lists(), __(), data-wp-lists(), wp_nonce_field(), __() |
!is_protected_meta() && !is_serialized() | 146 | is_protected_meta(), wp_create_nonce(), is_serialized(), esc_attr(), esc_textarea(), wp_create_nonce(), __(), __(), data-wp-lists(), __(), data-wp-lists(), wp_nonce_field(), __() |
!is_protected_meta() && is_serialized() && is_serialized_string() | 156 | is_protected_meta(), is_serialized(), is_serialized_string(), maybe_unserialize(), esc_attr(), esc_textarea(), wp_create_nonce(), __(), __(), data-wp-lists(), __(), data-wp-lists(), wp_nonce_field(), __() |
!is_protected_meta() && is_serialized() && is_serialized_string() | 160 | is_protected_meta(), wp_create_nonce(), is_serialized(), is_serialized_string(), maybe_unserialize(), esc_attr(), esc_textarea(), wp_create_nonce(), __(), __(), data-wp-lists(), __(), data-wp-lists(), wp_nonce_field(), __() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 163 instructions, 11–160 executed per call, 4 branches. The work does not change between versions.
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 · 10
- is_protected_meta()Determines whether a meta key is considered protected.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- is_serialized()Checks value to find if it was serialized.
- is_serialized_string()Checks whether serialized data is of string type.
- maybe_unserialize()Unserializes data only if it was serialized.
- esc_attr()Escaping for HTML attributes.
- esc_textarea()Escaping for textarea values.
- __()Retrieves the translation of $text.
- get_submit_button()Returns a submit button, with provided text and appropriate class.
- wp_nonce_field()Retrieves or display nonce hidden field for forms.
Used by · 2
- list_meta()Outputs a post's public meta data in the Custom Fields meta box.
- wp_ajax_add_meta()Handles adding meta via AJAX.
Source code
function _list_meta_row( $entry, &$count ) { static $update_nonce = ''; if ( is_protected_meta( $entry['meta_key'], 'post' ) ) { return ''; } if ( ! $update_nonce ) { $update_nonce = wp_create_nonce( 'add-meta' ); } $r = ''; ++$count; if ( is_serialized( $entry['meta_value'] ) ) { if ( is_serialized_string( $entry['meta_value'] ) ) { // This is a serialized string, so we should display it. $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); } else { // This is a serialized array/object so we should NOT display it. --$count; return ''; } } $entry['meta_key'] = esc_attr( $entry['meta_key'] ); $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // Using a <textarea />. $entry['meta_id'] = (int) $entry['meta_id']; $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t<tr id='meta-{$entry['meta_id']}'>"; $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . /* translators: Hidden accessibility text. */ __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />"; $r .= "\n\t\t<div class='submit'>"; $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); $r .= "\n\t\t"; $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); $r .= '</div>'; $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); $r .= '</td>'; $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . /* translators: Hidden accessibility text. */ __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; return $r;}Changelog
Introduced in 2.5.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.9.7 tag, from
src/wp-admin/includes/template.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.