Skip to content

Show post titles instead of URLs in widget#336

Merged
stklcode merged 2 commits into
developfrom
78-v2
Jun 16, 2026
Merged

Show post titles instead of URLs in widget#336
stklcode merged 2 commits into
developfrom
78-v2

Conversation

@krafit

@krafit krafit commented Jun 13, 2026

Copy link
Copy Markdown
Member

The initial #78 branch solved this with a statifymeta table that captured the document title at track time. That predates the v2 refactor and would add write-path overhead plus reintroduce schema we've since removed, so this PR takes a different route — the one v2 already uses for the statify_content tables.
Approach: resolve titles on demand from the target URL (Statify_Evaluation::post_title() → url_to_postid() + get_the_title()), enriching the target rows in select_data() before they're cached. Because that data already lives in the statify_data transient (15 min), lookups run at most once per cache window over limit rows (≤100, usually far fewer)

Is this too tacky? Let's discuss :)

The dashboard widget listed top targets by raw URL. Resolve each
target's post title in Statify_Dashboard::select_data() via the same
Statify_Evaluation::post_title() helper the content views already use,
and prefer it in the widget's top list (renderTopList).

Title lookups run inside the existing statify_data transient, so they
happen at most once per cache window over `limit` rows rather than on
every dashboard render. Referrer rows are unaffected.

Fixes #78
@krafit
krafit requested a review from stklcode June 13, 2026 09:33
@stklcode stklcode linked an issue Jun 13, 2026 that may be closed by this pull request
@sonarqubecloud

Copy link
Copy Markdown

@stklcode stklcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the API part with a new title field is fine.

Gathering the titles is about the same as we do in the extended view and it's OK for me that way. If we come up with a better solution we might update the backend part without user interruption.

@stklcode stklcode added this to the 2.0.0 milestone Jun 16, 2026
@stklcode
stklcode merged commit 514e4f3 into develop Jun 16, 2026
19 checks passed
@stklcode
stklcode deleted the 78-v2 branch June 16, 2026 18:56
@2ndkauboy

Copy link
Copy Markdown
Member

The is a good first solution! 🙌

The main discussion at Cloudfest was around URLs that don't map to a post/page. Those will now still show the URL. Since getting the page title for special pages like archives, 404, searches, etc. does not work (easily) taking the URL, we have saved the title "on request" using the wp_get_document_title() function, that can easily track this information on the request itself.

We also decided to introduce a meta table to enable us to store more meta information - or allow other to do so via hooks - but then didn't join the work, since we were unsure about how to aggregate this new (meta) data.

See: #251

@stklcode

stklcode commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@2ndkauboy Thanks for commenting on this one. Other point is, titles may change over time which is covered by this simple approach, but may require so,e tweaks with a pre-filled tables.

Think we should discuss about both topics and how we want to proceed and should not block ourselves with (maybe) conflicting ideas. But I’d prefer to postpone it to after 2.0. As said before, the API should be fine to handle for upcoming internal changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show title instead of permalink

3 participants