@@ -207,14 +207,23 @@ function perflab_is_valid_module( $module ) {
207207 * This attribute is then used in {@see perflab_render_generator()}.
208208 *
209209 * @since 1.1.0
210+ * @since n.e.x.t The generator tag now includes the active standalone plugin slugs.
210211 */
211212function perflab_get_generator_content () {
212213 $ active_and_valid_modules = array_filter ( perflab_get_active_modules (), 'perflab_is_valid_module ' );
213214
215+ $ active_plugins = array ();
216+ foreach ( perflab_get_standalone_plugin_version_constants ( 'plugins ' ) as $ plugin_slug => $ constant_name ) {
217+ if ( defined ( $ constant_name ) && ! str_starts_with ( constant ( $ constant_name ), 'Performance Lab ' ) ) {
218+ $ active_plugins [] = $ plugin_slug ;
219+ }
220+ }
221+
214222 return sprintf (
215- 'Performance Lab %1$s; modules: %2$s ' ,
223+ 'Performance Lab %1$s; modules: %2$s; plugins: %3$s ' ,
216224 PERFLAB_VERSION ,
217- implode ( ', ' , $ active_and_valid_modules )
225+ implode ( ', ' , $ active_and_valid_modules ),
226+ implode ( ', ' , $ active_plugins )
218227 );
219228}
220229
@@ -276,7 +285,7 @@ function perflab_can_load_module( $module ) {
276285 * @return bool Whether the module has already been loaded by a separate plugin.
277286 */
278287function perflab_is_standalone_plugin_loaded ( $ module ) {
279- $ standalone_plugins_constants = perflab_get_standalone_plugins_constants ( );
288+ $ standalone_plugins_constants = perflab_get_standalone_plugin_version_constants ( ' modules ' );
280289 if (
281290 isset ( $ standalone_plugins_constants [ $ module ] ) &&
282291 defined ( $ standalone_plugins_constants [ $ module ] ) &&
@@ -288,16 +297,46 @@ function perflab_is_standalone_plugin_loaded( $module ) {
288297}
289298
290299/**
291- * Gets the standalone plugin constants used for each module / plugin.
300+ * Gets the standalone plugin constants used for each module with a standalone plugin.
292301 *
293302 * @since 2.2.0
303+ * @deprecated 2.9.0
294304 *
295305 * @return array Map of module path to version constant used.
296306 */
297307function perflab_get_standalone_plugins_constants () {
308+ _deprecated_function ( __FUNCTION__ , 'Performance Lab 2.9.0 ' , "perflab_get_standalone_plugin_version_constants( 'modules' ) " );
309+ return perflab_get_standalone_plugin_version_constants ( 'modules ' );
310+ }
311+
312+ /**
313+ * Gets the standalone plugin constants used for each available standalone plugin, or module with a standalone plugin.
314+ *
315+ * @since n.e.x.t
316+ *
317+ * @param string $source Optional. Either 'plugins' or 'modules'. Default 'plugins'.
318+ * @return array<string, string> Map of plugin slug / module path and the version constant used.
319+ */
320+ function perflab_get_standalone_plugin_version_constants ( $ source = 'plugins ' ) {
321+ if ( 'modules ' === $ source ) {
322+ /*
323+ * This list includes all modules which are also available as standalone plugins,
324+ * as `$module_dir => $version_constant` pairs.
325+ */
326+ return array (
327+ 'images/dominant-color-images ' => 'DOMINANT_COLOR_IMAGES_VERSION ' ,
328+ 'images/webp-uploads ' => 'WEBP_UPLOADS_VERSION ' ,
329+ );
330+ }
331+
332+ /*
333+ * This list includes all standalone plugins that are part of the Performance Lab project,
334+ * as `$plugin_slug => $version_constant` pairs.
335+ */
298336 return array (
299- 'images/dominant-color-images ' => 'DOMINANT_COLOR_IMAGES_VERSION ' ,
300- 'images/webp-uploads ' => 'WEBP_UPLOADS_VERSION ' ,
337+ 'webp-uploads ' => 'WEBP_UPLOADS_VERSION ' ,
338+ 'dominant-color-images ' => 'DOMINANT_COLOR_IMAGES_VERSION ' ,
339+ 'performant-translations ' => 'PERFORMANT_TRANSLATIONS_VERSION ' ,
301340 );
302341}
303342
0 commit comments