wppaste
WordPress

WP_Application_Passwords_List_Table::print_js_template_row()

Since
5.6.0
Source
wp-admin/includes/class-wp-application-passwords-list-table.php:200
Prints the JavaScript template for the new row item.

Compatibility

WordPress
since 5.6.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.

Performance profile

How much work a call to WP_Application_Passwords_List_Table::print_js_template_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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
11–12

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 111.

Plugin surface
1 hook

Third-party callbacks on 'manage_{$this->screen->id}_custom_column_js_template' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksdo_action()called directly

Further down the call graph this can also reach option, cache, serialize, query 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 · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Application_Passwords_List_Table::print_js_template_row() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always11–12->get_column_info()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev11211–12111 more instruction than PHP 8.5
8.511111–1211
8.411111–12113 fewer instructions than PHP 8.3
8.311411–1211
8.211411–12112 fewer instructions than PHP 8.1
8.111614–1511
7.411614–1511

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.

Hooks and filters fired · 1

One hook fires while WP_Application_Passwords_List_Table::print_js_template_row() runs, in this order:

  1. do_action( manage_{$this->screen->id}_custom_column_js_template )actionline 251 (+51 into the body)

    Fires in the JavaScript row template for each custom column in the Application Passwords list table.

Uses · 7

  • esc_attr()Escaping for HTML attributes.
  • wp_strip_all_tags()Properly strips all HTML tags including 'script' and 'style'.
  • wp_json_encode()Encodes a variable into JSON, with some confidence checks.
  • __()Retrieves the translation of $text.
  • esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
  • do_action()Calls the callback functions that have been added to an action hook.
  • WP_Application_Passwords_List_Table::get_column_info()

Source code

	public function print_js_template_row() {		list( $columns, $hidden, , $primary ) = $this->get_column_info(); 		echo '<tr data-uuid="{{ data.uuid }}">'; 		foreach ( $columns as $column_name => $display_name ) {			$is_primary = $primary === $column_name;			$classes    = "{$column_name} column-{$column_name}"; 			if ( $is_primary ) {				$classes .= ' has-row-actions column-primary';			} 			if ( in_array( $column_name, $hidden, true ) ) {				$classes .= ' hidden';			} 			printf( '<td class="%s" data-colname="%s">', esc_attr( $classes ), esc_attr( wp_strip_all_tags( $display_name ) ) ); 			switch ( $column_name ) {				case 'name':					echo '{{ data.name }}';					break;				case 'created':					// JSON encoding automatically doubles backslashes to ensure they don't get lost when printing the inline JS.					echo '<# print( wp.date.dateI18n( ' . wp_json_encode( __( 'F j, Y' ) ) . ', data.created ) ) #>';					break;				case 'last_used':					echo '<# print( data.last_used !== null ? wp.date.dateI18n( ' . wp_json_encode( __( 'F j, Y' ) ) . ", data.last_used ) : '—' ) #>";					break;				case 'last_ip':					echo "{{ data.last_ip || '—' }}";					break;				case 'revoke':					printf(						'<button type="button" class="button delete" aria-label="%1$s">%2$s</button>',						/* translators: %s: the application password's given name. */						esc_attr( sprintf( __( 'Revoke "%s"' ), '{{ data.name }}' ) ),						esc_html__( 'Revoke' )					);					break;				default:					/**					 * Fires in the JavaScript row template for each custom column in the Application Passwords list table.					 *					 * Custom columns are registered using the {@see 'manage_application-passwords-user_columns'} filter.					 *					 * @since 5.6.0					 *					 * @param string $column_name Name of the custom column.					 */					do_action( "manage_{$this->screen->id}_custom_column_js_template", $column_name );					break;			} 			if ( $is_primary ) {				echo '<button type="button" class="toggle-row"><span class="screen-reader-text">' .					/* translators: Hidden accessibility text. */					__( 'Show more details' ) .				'</span></button>';			} 			echo '</td>';		} 		echo '</tr>';	}

Changelog

Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-wp-application-passwords-list-table.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.