Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget title addition #230

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

John-H-Smith
Copy link

Added the title to the widget on hover over url so that you can see what page it is if you have short urls enabled.

image

If it's the front page, the title of the website is returned.

@stklcode
Copy link
Contributor

stklcode commented Jul 7, 2022

related to #78

Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

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

LGTM

@2ndkauboy
Copy link
Member

It seems that the url_to_postid() function (which is also quite heavy) does not really work for many types of URLs, such as CPT single views, CPT archives and even category archives. I'm also a bit unsure if this is a good idea in terms of a11y. 🤔

@John-H-Smith
Copy link
Author

John-H-Smith commented Jul 10, 2022

It seems that the url_to_postid() function (which is also quite heavy) does not really work for many types of URLs, such as CPT single views, CPT archives and even category archives. I'm also a bit unsure if this is a good idea in terms of a11y. thinking

Yeah, I thought about that and verified the behaviour with a category archieve. It seems like the function get_page_by_path could be working, but it seems to be quite buggy when switching the permalink structure, so I had switched to url_to_postid. Do you have another function which could be working too?

views/widget-front.php Outdated Show resolved Hide resolved
@MatzeKitt
Copy link
Member

I think the cleanest way would be in storing metadata for the visited page in the Statify table, like post ID as an object ID and the object type, which could be any post type or term type. That way you can find the correct object according to object type and object ID and get the current title of the object.

@John-H-Smith
Copy link
Author

I think the cleanest way would be in storing metadata for the visited page in the Statify table, like post ID as an object ID and the object type, which could be any post type or term type. That way you can find the correct object according to object type and object ID and get the current title of the object.

Yeah, that would be. But as of that, you would have to update the metadata every time the url or the title is updated - I think thats a quite heavy performance issue.

@MatzeKitt
Copy link
Member

But as of that, you would have to update the metadata every time the url or the title is updated - I think thats a quite heavy performance issue.

If you construct it correctly, you can retrieve the current title of all items in the widget with a single SQL query, which is much better than using url_to_postid for every single item.

@John-H-Smith
Copy link
Author

If you construct it correctly, you can retrieve the current title of all items in the widget with a single SQL query, which is much better than using url_to_postid for every single item.

Yeah, that's correct, it would be much better. But modifying the table after it has been created would force you to either uninstall and reinstall statify to create the table correctly or check for every website access if the new columns in the table already exist.
Also, I just noticed that the dashboard widget limits the count of all items to 100, so I am pretty sure using url_to_postid would be no problem.

@sonarcloud
Copy link

sonarcloud bot commented Nov 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@stklcode
Copy link
Contributor

stklcode commented Nov 6, 2022

But modifying the table after it has been created would force you to either uninstall and reinstall statify to create the table correctly [...]

Actually that's not a big deal at all. There is already a routine to initialize the table properly, so the schema may be updated during a plugin update.

@MatzeKitt
Copy link
Member

As addition: take a look into dbDelta

@John-H-Smith
Copy link
Author

Alright - but with what action hook should I modify the table in your opinion? Directly in the functions file for execution on every call would be a bad practice I think...

@MatzeKitt
Copy link
Member

I can only speak for myself, but the best way I found was to store the migration version as option and migrate the database depending on this option.

See here: https://github.com/epiphyt/embed-privacy/blob/main/inc/class-migration.php

@pluginkollektiv pluginkollektiv deleted a comment from sonarcloud bot Mar 18, 2023
@sonarcloud
Copy link

sonarcloud bot commented Mar 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

None yet

5 participants