WP_Application_Passwords_List_Table::print_js_template_row()

In this article

Prints the JavaScript template for the new row item.

Source

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 '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>';
}

Hooks

do_action( “manage_{$this->screen->id}_custom_column_js_template”, string $column_name )

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

Changelog

VersionDescription
5.6.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.