Skip to content

Conversation

@mattradford-sage
Copy link

@mattradford-sage mattradford-sage commented Apr 1, 2025

Description of the Change

This PR allows the label of the environment type admin bar node to be set to a custom string, such as "Preproduction".

Screenshot 2025-04-01 at 15 34 35

We use the 10up Experience plugin on one of our sites, which has a Preproduction environment. A label other than "Preproduction" could cause confusion.

This PR does not contend with the CSS associated with a non-standard label, but we can handle that outside of 10up Experience plugin. Perhaps that could be considered as part of the resolution for #175.

How to test the Change

Add a function to filter the environment label:

function custom_environment_type() {
	return 'Preproduction';
}
add_filter( 'tenup_experience_environment_type_label', 'custom_environment_type' );

Changelog Entry

Added - Filter to change the admin bar environment label.

Credits

Props @mattradford-sage

Checklist:

@claytoncollie
Copy link
Contributor

@mattradford-sage Thanks for submitting this PR! I know it's been a long time, but can you please update the README in the root to fully document the new filter? After that, we can talk to @darylldoyle to see about merging.

@fabiankaegy
Copy link
Member

fabiankaegy commented Dec 18, 2025

One additional note from me on this, I think on top of just the label it would be super valuable to be able to filter the environment type to determine the color.

Like I might not want the preprod site to appear in red to keep that only for the actual prod site.

(But I have not looked at the actual code here so not sure how complex that would make it)

@mattradford-sage
Copy link
Author

@claytoncollie I've added the filter to the README.

@fabiankaegy The plugin supports environments as defined by wp_get_environment_type(), which doesn't include a Preproduction environment. Our Preproduction environment returns the default (production) as the environment.

For our requirement to differentiate Preproduction, we can override the CSS for .tenup-experience-environment-indicator--production using a separate environment check.

@mattradford-sage
Copy link
Author

mattradford-sage commented Dec 18, 2025

@fabiankaegy Sorry, I think I missed the point of your comment. I'd be happy to change the PR to include a filter for the environment type itself (probably at this line in add_toolbar_item()).

This would be helpful as, for example, WP Engine does not support wp_get_environment_type() so all environments return production as the environment.

@fabiankaegy
Copy link
Member

Lets not block this PR with that but I do think it would be useful :)

@claytoncollie
Copy link
Contributor

@mattradford-sage I had some extra time and made this PR as a replacement that allows more customization, as @fabiankaegy suggested. If we introduce a filter for a single string it would be harder to convert to an array later on that supports the other properties--icon, color, etc. I want to close this PR and use #199 instead.

This PR also solves #175

cc @darylldoyle

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