Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .wordpress-org/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions inc/class-statify-dashboard.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,15 @@ private static function select_data(): array {
);
}

// Resolve post titles for the top targets.
// This runs over at most `limit` rows and is cached together with the
// rest of the widget data (see get_stats()), so the lookups happen only
// once per cache lifetime instead of on every dashboard render.
foreach ( $data['target'] as &$target ) {
$target['title'] = Statify_Evaluation::post_title( $target['url'] );
}
unset( $target );

if ( $show_totals ) {
$data['visit_totals'] = array(
'today' => $wpdb->get_var(
Expand Down
9 changes: 5 additions & 4 deletions js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@
/**
* Render top list table.
*
* @param {HTMLTableElement} table Table element.
* @param {{count: number, url: string, host: ?string}[]} data Data to display.
* @param {HTMLTableElement} table Table element.
* @param {{count: number, url: string, host: ?string, title: ?string}[]} data Data to display.
*/
function renderTopList(table, data) {
const rows = data.map((r) => {
Expand All @@ -544,15 +544,16 @@
row.appendChild(col);
col = document.createElement('TD');
col.classList.add('t');
const label = r.title || r.host || r.url;
if (/^((https?:)?\/)?\//i.test(r.url)) {
const link = document.createElement('A');
link.href = r.url;
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.textContent = r.host || r.url;
link.textContent = label;
col.appendChild(link);
} else {
col.textContent = r.host || r.url;
col.textContent = label;
}
row.appendChild(col);
return row;
Expand Down