WC_Admin_API_Keys_Table_List::column_title()publicWC 1.0

Return title column.

Метод класса: WC_Admin_API_Keys_Table_List{}

Хуков нет.

Возвращает

Строку.

Использование

$WC_Admin_API_Keys_Table_List = new WC_Admin_API_Keys_Table_List();
$WC_Admin_API_Keys_Table_List->column_title( $key );
$key(массив) (обязательный)
Key data.

Код WC_Admin_API_Keys_Table_List::column_title() WC 8.7.0

public function column_title( $key ) {
	$url     = admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys&edit-key=' . $key['key_id'] );
	$user_id = intval( $key['user_id'] );

	// Check if current user can edit other users or if it's the same user.
	$can_edit = current_user_can( 'edit_user', $user_id ) || get_current_user_id() === $user_id;

	$output = '<strong>';
	if ( $can_edit ) {
		$output .= '<a href="' . esc_url( $url ) . '" class="row-title">';
	}
	if ( empty( $key['description'] ) ) {
		$output .= esc_html__( 'API key', 'woocommerce' );
	} else {
		$output .= esc_html( $key['description'] );
	}
	if ( $can_edit ) {
		$output .= '</a>';
	}
	$output .= '</strong>';

	// Get actions.
	$actions = array(
		/* translators: %s: API key ID. */
		'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $key['key_id'] ),
	);

	if ( $can_edit ) {
		$actions['edit']  = '<a href="' . esc_url( $url ) . '">' . __( 'View/Edit', 'woocommerce' ) . '</a>';
		$actions['trash'] = '<a class="submitdelete" aria-label="' . esc_attr__( 'Revoke API key', 'woocommerce' ) . '" href="' . esc_url(
			wp_nonce_url(
				add_query_arg(
					array(
						'revoke-key' => $key['key_id'],
					),
					admin_url( 'admin.php?page=wc-settings&tab=advanced&section=keys' )
				),
				'revoke'
			)
		) . '">' . esc_html__( 'Revoke', 'woocommerce' ) . '</a>';
	}

	$row_actions = array();

	foreach ( $actions as $action => $link ) {
		$row_actions[] = '<span class="' . esc_attr( $action ) . '">' . $link . '</span>';
	}

	$output .= '<div class="row-actions">' . implode( ' | ', $row_actions ) . '</div>';

	return $output;
}