From 6e58e251cb92193fc3388fc1e622f5109aa244db Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Mon, 20 May 2019 11:12:18 +0300 Subject: [PATCH 1/2] Add CALYPSO_ENV constant --- companion.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/companion.php b/companion.php index 403b5d8..139136b 100644 --- a/companion.php +++ b/companion.php @@ -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 */ @@ -187,6 +187,22 @@ function companion_add_jetpack_constants_option_page() { 'JETPACK__SANDBOX_DOMAIN' ) . ''; + $calypso_envs = array( + 'develop' => 'calypso.localhost:3000', + 'wpcalypso' => 'wpcalypso.wordpress.com', + ); + + $calypso_env_quick_selector = ''; + foreach( $calypso_envs as $env => $url ) { + $calypso_env_quick_selector .= + '

' . + ' ' . + '' . $url . '' . + '

'; + } + $options_page = array( 'companion' => array( 'page_title' => __( 'Jurassic Ninja Tweaks for Jetpack Constants', 'companion' ), @@ -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( @@ -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 + ), ), ), ), @@ -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', '' ) ); + } } From 6021c39586a30f0ce67c5777fdfb7444b844f033 Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Mon, 20 May 2019 11:49:34 +0300 Subject: [PATCH 2/2] Use correct slug for development env --- companion.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/companion.php b/companion.php index 139136b..7d543f7 100644 --- a/companion.php +++ b/companion.php @@ -188,8 +188,8 @@ function companion_add_jetpack_constants_option_page() { ) . ''; $calypso_envs = array( - 'develop' => 'calypso.localhost:3000', - 'wpcalypso' => 'wpcalypso.wordpress.com', + 'development' => 'calypso.localhost:3000', + 'wpcalypso' => 'wpcalypso.wordpress.com', ); $calypso_env_quick_selector = '';