Skip to content
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

Add CALYPSO_ENV constant #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions companion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Companion Plugin
Plugin URI: https://github.com/Automattic/companion
Description: Helps keep the launched WordPress in order.
Version: 1.8
Version: 1.9
Author: Osk
*/

Expand Down Expand Up @@ -187,6 +187,22 @@ function companion_add_jetpack_constants_option_page() {
'<code>JETPACK__SANDBOX_DOMAIN</code>'
) . '</strong>';

$calypso_envs = array(
'development' => 'calypso.localhost:3000',
'wpcalypso' => 'wpcalypso.wordpress.com',
);

$calypso_env_quick_selector = '';
foreach( $calypso_envs as $env => $url ) {
$calypso_env_quick_selector .=
'<p>' .
'<button class="button code" onClick="document.getElementById(\'calypso_env\').value = \'' . $env . '\';">' .
$env .
'</button> ' .
'<code>' . $url . '</code>' .
'</p>';
}

$options_page = array(
'companion' => array(
'page_title' => __( 'Jurassic Ninja Tweaks for Jetpack Constants', 'companion' ),
Expand All @@ -211,7 +227,7 @@ function companion_add_jetpack_constants_option_page() {
'id' => 'jetpack_beta_blocks',
'title' => __( 'JETPACK_BETA_BLOCKS', 'companion' ),
'text' =>
esc_html__( 'Check to enable Jetpack blocks for Gutenberg that are on Beta stage of development', 'companion' ),
esc_html__( 'Load Jetpack block-editor extensions that are on beta stage of development', 'companion' ),
'type' => 'checkbox',
),
'jetpack_protect_api_host' => array(
Expand All @@ -223,6 +239,13 @@ function companion_add_jetpack_constants_option_page() {
),
'placeholder' => esc_attr( JETPACK_PROTECT__API_HOST ),
),
'calypso_env' => array(
'id' => 'calypso_env',
'title' => __( 'CALYPSO_ENV', 'companion' ),
'text' =>
esc_html__( 'Configure which version of Calypso Jetpack should use for connection flow.', 'companion' ) .
$calypso_env_quick_selector
),
),
),
),
Expand All @@ -245,11 +268,13 @@ function companion_tamper_with_jetpack_constants() {
if ( ! ( defined( 'JETPACK__SANDBOX_DOMAIN' ) && JETPACK__SANDBOX_DOMAIN ) && companion_get_option( 'jetpack_sandbox_domain', '' ) ) {
define( 'JETPACK__SANDBOX_DOMAIN', companion_get_option( 'jetpack_sandbox_domain', '' ) );
}

if ( ! ( defined( 'JETPACK_PROTECT__API_HOST' ) && JETPACK_PROTECT__API_HOST ) && companion_get_option( 'jetpack_protect_api_host', '' ) ) {
define( 'JETPACK_PROTECT__API_HOST', companion_get_option( 'jetpack_protect_api_host', '' ) );
}
if ( ! ( defined( 'JETPACK_BETA_BLOCKS' ) && JETPACK_BETA_BLOCKS ) && companion_get_option( 'jetpack_beta_blocks', '' ) ) {
define( 'JETPACK_BETA_BLOCKS', companion_get_option( 'jetpack_beta_blocks', '' ) ? true : false );
}
if ( ! ( defined( 'CALYPSO_ENV' ) && CALYPSO_ENV ) && companion_get_option( 'calypso_env', '' ) ) {
define( 'CALYPSO_ENV', companion_get_option( 'jetpack_protect_api_host', '' ) );
}
}