Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ public function share( $args, $assoc_args ) {
if ( $this->site_data->site_url === $active_publish ) {
$this->ngrok_curl( false, $refresh );
} else {
EE::error( $this->site_data->site_url . ' does not have active publish running.' );
EE::error( $this->site_data->site_url . ' does not have active share running.' );
}

if ( ! $refresh ) {
Expand All @@ -1009,15 +1009,15 @@ public function share( $args, $assoc_args ) {
}

if ( $this->site_data->site_ssl ) {
EE::error( 'site publish is not yet supported for ssl sites.' );
EE::error( 'site share is not yet supported for ssl sites.' );
}

$this->maybe_setup_ngrok( $ngrok );
if ( ! empty( $active_publish ) ) {
if ( ( $this->site_data->site_url === $active_publish ) ) {
$error = $refresh ? '' : "{$this->site_data->site_url} has already been published. Visit link: $publish_url to view it online.\nNote: This link is only valid for few hours. In case it has expired run: `ee site publish {$this->site_data->site_url} --refresh`";
$error = $refresh ? '' : "{$this->site_data->site_url} has already been shared. Visit link: $publish_url to view it online.\nNote: This link is only valid for few hours. In case it has expired run: `ee site share {$this->site_data->site_url} --refresh`";
} else {
$error = "$active_publish site is published currently. Publishing of only one site at a time is supported.\nTo publish {$this->site_data->site_url} , first run: `ee site publish $active_publish --disable`";
$error = "$active_publish site is shared currently. Sharing of only one site at a time is supported.\nTo share {$this->site_data->site_url} , first run: `ee site share $active_publish --disable`";
}
if ( ! empty( $error ) ) {
EE::error( $error );
Expand All @@ -1029,15 +1029,15 @@ public function share( $args, $assoc_args ) {
}
$config_80_port = get_config_value( 'proxy_80_port', 80 );
if ( ! $refresh ) {
EE::log( "Publishing site: {$this->site_data->site_url} online." );
EE::log( "Sharing site: {$this->site_data->site_url} online." );
}
EE::debug( "$ngrok http -host-header={$this->site_data->site_url} $config_80_port > /dev/null &" );
EE::debug( shell_exec( "$ngrok http -host-header={$this->site_data->site_url} $config_80_port > /dev/null &" ) );
$published_url = $this->ngrok_curl();
if ( empty( $published_url ) ) {
EE::error( 'Could not publish site.' );
EE::error( 'Could not share site.' );
}
EE::success( "Successfully published {$this->site_data->site_url} to url: $published_url" );
EE::success( "Successfully shared {$this->site_data->site_url} to url: $published_url" );
Option::set( 'publish_site', $this->site_data->site_url );
Option::set( 'publish_url', $published_url );
}
Expand Down Expand Up @@ -1067,7 +1067,7 @@ private function maybe_setup_ngrok( $ngrok ) {
* Function to curl and get data from ngrok api.
*
* @param bool $get_url To get url of tunnel or not.
* @param bool $refresh Whether to disable for publish refresh or not.
* @param bool $refresh Whether to disable share refresh or not.
*/
private function ngrok_curl( $get_url = true, $refresh = false ) {

Expand Down Expand Up @@ -1109,13 +1109,13 @@ private function ngrok_curl( $get_url = true, $refresh = false ) {
$ngrok_tunnel = str_replace( '+', '%20', urlencode( $ngrok_data['tunnels'][0]['name'] ) );
}
} elseif ( $get_url ) {
EE::error( 'Could not publish site. Please check logs.' );
EE::error( 'Could not share site. Please check logs.' );
}

if ( $refresh ) {
EE::log( 'Refreshing site publish.' );
EE::log( 'Refreshing site share.' );
} else {
EE::log( 'Disabling publish.' );
EE::log( 'Disabling share.' );
}
if ( ! empty( $ngrok_tunnel ) ) {
$ch = curl_init();
Expand All @@ -1129,7 +1129,7 @@ private function ngrok_curl( $get_url = true, $refresh = false ) {
Option::set( 'publish_site', '' );
Option::set( 'publish_url', '' );
if ( ! $refresh ) {
EE::success( 'Site publish disabled.' );
EE::success( 'Site share disabled.' );
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/helper/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ function cleanup_redis_entries( $site_url ) {
}

/**
* Hook to cleanup publishing if any on site delete.
* Hook to cleanup sharing if any on site delete.
*
* @param string $site_url The site to be cleaned up.
*/
function cleanup_publishing( $site_url ) {
function cleanup_sharing( $site_url ) {

$active_publish = Option::get( 'publish_site' );
$publish_url = Option::get( 'publish_url' );
Expand All @@ -80,5 +80,5 @@ function cleanup_publishing( $site_url ) {
}

EE::add_hook( 'site_cleanup', 'cleanup_redis_entries' );
EE::add_hook( 'site_cleanup', 'cleanup_publishing' );
EE::add_hook( 'site_cleanup', 'cleanup_sharing' );
EE::add_hook( 'before_invoke:help', 'ee_site_help_cmd_routing' );