roots / wp-stage-switcher Goto Github PK
View Code? Open in Web Editor NEWWordPress plugin that allows you to switch between different environments from the admin bar
Home Page: https://roots.io/plugins/stage-switcher/
License: MIT License
WordPress plugin that allows you to switch between different environments from the admin bar
Home Page: https://roots.io/plugins/stage-switcher/
License: MIT License
Subdomain-based multisite URLs aren't modified in any helpful way. The full current URL host-part is replaced by the stage's host-part, with no attempt made to preserve the blog's domain.
Configured the ENVIRONMENTS
array with the URLs of the "main site" or just the domain suffix.
When originally implemented in 890a711, the host was split on the assumption that the subdomain would be only a single level, which worked in most cases, but not all. When rewritten in #7, Purl was used for its registerableDomain
property to attempt to determine the base domain portion which should be replaced and the subdomain which should be kept. Finally, in #18, the Purl dependancy was removed, but the multisite_url
method was simplified too much and all logic about trying to determine subdomain and base domain was removed.
Without involving external dependancies (and even then, a solution may not be available for every possible outcome), determining with certainty the sub domain/base domain portion of a multisite URL is difficult. I propose moving back to a solution similar to the original in 890a711 but also providing a filter to allow for domain structures that don't fit.
The ENVIRONMENTS
array can be defined in a sunrise.php
drop-in once the multisite domain has been resolved, but this still presents an issue where URL scheme might be changed based on the scheme of the current stage (ie. a production site using the https scheme would overwrite an http scheme for a development URL creating a broken link).
ENVIRONMENTS
array with URLs for these environmentsSubdomain portions of the environment URL will be maintained while base environment domains are replaced
The entire subdomain URL is replaced with the URL from the ENVIRONMENTS
array, discarding the subdomain
No response
2.1.1
There have been a few enhancements and bug fixes in the past that I think warrant a new release. Plus, there are 3 pull requests that are currently open that could be considered as well.
It would be really great if a new version could be tagged after these get in as well.
Please let me know if I can help with a changelog or something.
Is this possible? I want to use this on WP Engine, but WP Engine gives no ssh access. I need to be able to install it via SFTP. The issue is that this, of course, won't load dependencies and such properly.
Hi,
Great plugin. However, if I have WordPress installed in a subfolder of the domain, that subfolder is added to the urls of the other environments, which is obviously not desirable.
It would be great if you fix this.
Thanks!
Vasko
This menu should probably only be displayed for admins by default. We could allow a list of roles to be provided through a filter as well.
Notice: Use of undefined constant ENVIRONMENTS - assumed 'ENVIRONMENTS' in /public_html/bedrock/web/app/plugins/wp-stage-switcher-2.0.0/wp-stage-switcher.php on line 50 Notice: unserialize(): Error at offset 0 of 12 bytes in /public_html/bedrock/web/app/plugins/wp-stage-switcher-2.0.0/wp-stage-switcher.php on line 50 Warning: Invalid argument supplied for foreach() in /public_html/bedrock/web/app/plugins/wp-stage-switcher-2.0.0/wp-stage-switcher.php on line 53
Add support for changing the color of the wp-admin based on environment
Having the ability for each environment to have a different color scheme would help make it more obvious as to which environment you are currently viewing
env-<environment>
<body>
classes to allow writing CSS to target based by environment
add_filter('body_class', function($classes) {
$classes[] = 'env-'.sanitize_title(WP_ENV);
return $classes;
});
Here's an enhancement idea, that I'm willing to write code for, but want to get a ๐ from project owners first. I could see this idea being judged as an entirely separate plugin, but for me it is the feature that's missing to make this really great. Please let me know if you see it as a good fit.
There would be two steps to this:
ENVIRONMENT
constant to optionally support meta data through nested arrays. Strings will still work, but you could now do something like this:$envs = array(
'development' => array(
'url' => 'http://example.dev',
'canonical' => false
),
'staging' => array(
'url' => 'http://staging.example.com',
'canonical' => false
),
'production' => 'http://example.com'
);
define('ENVIRONMENTS', serialize($envs));
The color, too, should probably be filterable. And since a user's admin color scheme is dynamic, this will need to account for that somehow โ that bit will take some research.
This is one of the coolest and most useful plugins I've come across in a while, however, it doesn't appear to have support for multisite setups.
From what I can tell, the ENVIRONMENTS
constant doesn't let you define more than 1 site.
On initial composer update with plugin as required in composer.json
"require": { "php": ">=5.6", "composer/installers": "~1.0.12", "vlucas/phpdotenv": "^2.0.1", "johnpbloch/wordpress": "4.6.1", "oscarotero/env": "^1.0", "roots/wp-password-bcrypt": "1.0.0", "wpackagist-plugin/contact-form-7": "dev-trunk", "wpackagist-plugin/getty-images": "dev-trunk", "roots/wp-stage-switcher": "2.0.0", "roots/soil": "3.7.1"
I am using and have setup Trellis/Bedrock. Line 53 states an issue between the stages but as I understand Bedrock already has WP_ENV; defined?
( ! ) Warning: Invalid argument supplied for foreach() in /srv/www/thefootballfamily.com/current/web/app/plugins/wp-stage-switcher/wp-stage-switcher.php on line 53
Call Stack
1 0.0009 468976 {main}( ) .../plugins.php:0
2 0.2273 20106184 require_once( '/srv/www/thefootballfamily.com/current/web/wp/wp-admin/admin-header.php' ) .../plugins.php:408
3 0.2398 20186528 do_action( ) .../admin-header.php:214
4 0.2398 20186928 wp_admin_bar_render( ) .../plugin.php:524
5 0.2398 20187304 do_action_ref_array( ) .../admin-bar.php:83
6 0.2412 20193816 Roots\StageSwitcher\StageSwitcher->admin_bar_stage_switcher( ) .../plugin.php:600
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.