-
Notifications
You must be signed in to change notification settings - Fork 133
Include standalone plugin slugs in generator tag #949
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
Include standalone plugin slugs in generator tag #949
Conversation
What if one installs these plugins without installing Performance Lab? Especially now that PL doesn‘t offer much on its own, I‘d expect many people will just install the individual plugins they want, as they don‘t necessarily need PL at all. IMO this case needs to be considered. |
@swissspidy It's definitely going to happen, agreed. But the Performance Lab plugin still has a very large install number, and it's hard to predict whether people will uninstall it or keep it around. Part of the reason it was decided to keep it was to provide a single entry point to the performance team's features, and any end users interested in that will likely still keep PL active. In any case, I agree with you and we certainly wouldn't be able to conclude from the PL's generator tag alone how much usage the standalone plugins have. My thinking though is that it's not worth mandating a generator tag in every standalone plugin. I agree with you there would be value in having it, but how about leaving it up to the individual standalone plugins on whether they implement their own generator tag? That would function entirely decoupled from the PL one anyway. This way, the PL generator tag provides a "sort of catch all" solution, which helps monitor how many sites use PL with the relevant standalone plugins, which I think is a valuable insight on PL adoption itself. Separate generator tags could be implemented in the standalone plugins, which would then basically provide similar information as the respective plugin's active install count number - with the benefit of seeing more granular updates, while having the trade-off of being limited to smaller datasets like HTTP Archive. WDYT? |
That‘s what I would suggest, but that that we actually do it. It‘s just a few lines of code anyway, repetition and maintenance overhead is tiny. |
Yeah, I would agree that the PL plugin shouldn't orchestrate the generator tag for the standalone plugins. They can each generate their own so that they can be detected even when the PL plugin is not installed. |
I also agree with @westonruter and @swissspidy. At some point, if we release a major chunk of modules into a plugin, the majority of folks may not install the Performance Lab plugin. In that case, having individual generator tags for each plugin would make it easier to identify on HTTP Archive. |
I don't think this has to be an either or decision. Why not do both?
So I think doing both makes most sense. |
Humm. I'm still not seeing the value of both. If a standalone plugin has a generator tag anyway, then having the standalone plugin mentioned in the PL generator tag is just redundancy, right? The standalone plugin generator tag would have to already be tracked regardless. If wanting to track adoption of PL plugin plus the standalone plugin, wouldn't this just involve looking for the two generator [meta] tags? For a uniform structure, wouldn't we just agree on a convention for the standalone plugins to construct their generator tags? |
Yes and no. Those are two different things to track. A query that tracks Performance Lab adoption in combination with standalone plugins could work by itself, while a query to track the standalone plugins adoption would work differently.
That would be possible, but more complicated. Plus it's not addressing the point on not mandating the use of a generator tag in every standalone plugin.
The only way I can see that work is if we used a generator value like I don't see any downsides in having both. Having both approaches allows tracking different things and is more robust than only having one or the other. |
For security reasons, many users remove the generator tags. In this case, users would need to add different filter codes to remove these tags if we consider adding the generator tag in multiple places.
|
Seems like a separate discussion. But why an extra filter if you can already do |
+1, I don't think there needs to be an extra filter. It needs to be possible (which it is by unhooking the action), while at the same time not something that we should encourage. If you agree with the approach of having generator tags for the plugins in both PL and the standalone plugins, it would be great if you could proceed with the actual code review on this one. :) |
load.php
Outdated
*/ | ||
function perflab_get_standalone_plugins_constants() { | ||
function perflab_get_standalone_plugins_constants( $type = 'modules' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit strange that this function is named to get the "standalone plugins" but the default $type
is not to get the standalone plugins at all, but rather the modules. Why not create a separate function like perflab_get_module_constants()
instead of adding a $type
arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to do that if y'all agree, but that's a BC break, so I went the "safe" route first. It's probably fair to assume nobody uses these functions outside of PL, but if they did this would break.
On the other hand, part of the point is to have these two lists in one place, as they need to be adjusted when changing which standalone plugins are available, depending on which state they are in. So from that perspective, I'd prefer to keep this together, maybe under a more suitable name.
Let me know what you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's no other plugins using this function. So I think it's fine to break back-compat.
Otherwise, two new functions could be created to include version
:
perflab_get_standalone_plugin_version_constants()
perflab_get_module_version_constants()
The existing function can then be marked as deprecated. But this is probably overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG regarding backward compatibility.
However those two names wouldn't be clear either. To clarify:
- Everything listed here is only relevant for standalone plugins.
- The first list is for modules that have an equivalent standalone plugin available.
- The second list is for standalone plugins overall, regardless of whether they come from a module or are exclusively available as a standalone plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just rename this function to perflab_get_standalone_plugin_version_constants()
, and the argument could become $source
instead of $type
? Maybe then the intent would be more clear ("source" can be "modules" or "plugins").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this in 8181c68.
For now I just deprecated the other function. Call it me being overly cautious because of WP core. If you prefer to drop it, we can, but I don't really see a value in immediately removing it.
Co-authored-by: Weston Ruter <westonruter@google.com>
…re explanation via code comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @felixarntz, for the PR. I've left one piece of feedback for your consideration. Other than that, it looks good to me.
load.php
Outdated
* | ||
* @return array Map of module path to version constant used. | ||
*/ | ||
function perflab_get_standalone_plugins_constants() { | ||
_deprecated_function( __FUNCTION__, 'Performance Lab n.e.x.t', "perflab_get_standalone_plugin_version_constants( 'modules' )" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference to n.e.x.t
will not change using the command npm run since -- -r 2.9.0
. So, make sure to update it manually or we can update it now before the merge. What do you think?
Saw this and wanted to merge it, but now I'm out of here bye 😆👶 |
Summary
The Performance Lab generator tag has historically only included the active modules. Now that most Performance Lab features will be made available via plugins, the tag should receive support for that, including both the active modules and active plugins.
With this PR, the tag will now look like:
Alternatively (or even additionally), every standalone plugin could come with a generator tag of its own. While that is simple to implement, it's probably overhead worth avoiding, having to put that code into every plugin. Keeping just one generator also makes sense from the perspective of the Performance Lab plugin acting as the central "orchestrator" for the WordPress Performance Team's features.
Relevant technical choices
perflab_get_standalone_plugins_constants()
has been expanded to support lookup of the constants from either modules or plugins. As a side benefit, this centralizes the logic nicely to maintain the list only in one function, asperflab_get_standalone_plugins()
now makes use of that rather than having its own list.Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.