Skip to content

Add optional query display name #573

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

chriszarate
Copy link
Member

Queries do not currently accept a display name, but I believe a display name will be useful in the future. Asking for it now (optionally) might pay off in the future.

@chriszarate chriszarate requested a review from a team as a code owner June 4, 2025 00:34
@chriszarate chriszarate requested review from alecgeatches and removed request for a team June 4, 2025 00:34
Copy link
Contributor

github-actions bot commented Jun 4, 2025

Test this PR in WordPress Playground.

@@ -156,6 +156,7 @@ private static function generate_generic_http_data_source_config_schema(): array

private static function generate_http_query_config_schema(): array {
return Types::object( [
'display_name' => Types::nullable( Types::string() ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts around making it mandatory? That way we don't need to worry about fallbacks, and it does force users to think about the purpose of the query.

This'll make some of the code I added in #530 redundant which is great as we shouldn't be generating that name ideally.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a breaking change. That's the main reason I made it nullable.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a fair point, and I think I have a solution from it. We can leverage the migration framework that'll be introduced in #530 to generate the display name in the same way that the PR does already. That way, the nullable could be dropped while not breaking anything already existing.

This can happen in a follow up PR

Copy link
Contributor

@ingeniumed ingeniumed left a comment

Choose a reason for hiding this comment

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

Never been so eager to review a PR such as this one

@pkevan
Copy link
Contributor

pkevan commented Jun 4, 2025

I don't know if this has been thought about yet, but how are we planning to use internationalization within the plugin?

I guess display name is an easy one to start with, although if the input is via a user then maybe that isn't important to them, but it might be for end users if it's display somewhere user facing.

@chriszarate
Copy link
Member Author

chriszarate commented Jun 4, 2025

I don't know if this has been thought about yet, but how are we planning to use internationalization within the plugin?

We've thought about it a little:

  1. For plugin code, we make an effort to localize our own strings with a consistent text domain. It undoubtedly needs attention and improvements.
  2. By design, we ask plugins users to define their configuration at runtime (e.g., register_remote_data_block( /* big configuration blob */ ), so they are free to localize strings within that config, including display names and other user-facing content.
  3. For data returned from remote data sources, I don't know if we have a strong opinion. Internationalized APIs might be controlled by parameters that could be adjusted at runtime (e.g., via a filter) depending on the user's location or language preference. Or plugin users could use generate to perform localization themselves. I don't know if there is a strong need for it.

@pkevan
Copy link
Contributor

pkevan commented Jun 5, 2025

I don't know if this has been thought about yet, but how are we planning to use internationalization within the plugin?

We've thought about it a little:

  1. For plugin code, we make an effort to localize our own strings with a consistent text domain. It undoubtedly needs attention and improvements.
  2. By design, we ask plugins users to define their configuration at runtime (e.g., register_remote_data_block( /* big configuration blob */ ), so they are free to localize strings within that config, including display names and other user-facing content.
  3. For data returned from remote data sources, I don't know if we have a strong opinion. Internationalized APIs might be controlled by parameters that could be adjusted at runtime (e.g., via a filter) depending on the user's location or language preference. Or plugin users could use generate to perform localization themselves. I don't know if there is a strong need for it.

Thanks! That makes sense - I wonder if we should provide an example of this?

I'm more thinking around the use-case whereby the plugin is configured across many sites (maybe not via the plugin itself but some mu-plugin code), and these sites have different languages - we should help them in these scenarios somehow.

@chriszarate
Copy link
Member Author

I wonder if we should provide an example of this?

I'm more thinking around the use-case whereby the plugin is configured across many sites (maybe not via the plugin itself but some mu-plugin code), and these sites have different languages - we should help them in these scenarios somehow.

I think 1 and 2 should solve for this, with some additional effort. I created VIPCMS-1316 to track this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants