Skip to content

Commit 3247e66

Browse files
committed
add vitepress on unsuspend
1 parent 496ea12 commit 3247e66

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

vitepress.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function __construct() {
2020
$hcpp->add_action( 'hcpp_invoke_plugin', [ $this, 'setup' ] );
2121
$hcpp->add_action( 'hcpp_render_body', [ $this, 'hcpp_render_body' ] );
2222
$hcpp->add_action( 'hcpp_nginx_reload', [ $this, 'hcpp_nginx_reload' ] );
23+
$hcpp->add_action( 'priv_unsuspend_web_domain', [ $this, 'priv_unsuspend_domain' ] ); // Bulk unsuspend domains only throws this event
24+
$hcpp->add_action( 'priv_unsuspend_domain', [ $this, 'priv_unsuspend_domain' ] ); // Individually unsuspend domain only throws this event
2325
}
2426

2527
/**
@@ -67,6 +69,22 @@ public function hcpp_nginx_reload( $cmd ) {
6769
return $cmd;
6870
}
6971

72+
/**
73+
* Add flag to add .vitepress to nginx.conf and nginx.ssl.conf on unsuspend
74+
*/
75+
public function priv_unsuspend_domain( $args ) {
76+
global $hcpp;
77+
$user = $args[0];
78+
$domain = $args[1];
79+
80+
// Flag to add .vitepress to nginx.conf and nginx.ssl.conf on hcpp_nginx_reload
81+
if ( file_exists( '/tmp/vitepress_domains') ) {
82+
$vitepress_domains = json_decode( file_get_contents( '/tmp/vitepress_domains' ), true );
83+
}
84+
$vitepress_domains[] = [ 'user' => $user, 'domain' => $domain ];
85+
file_put_contents( '/tmp/vitepress_domains', json_encode( $vitepress_domains ) );
86+
}
87+
7088
/**
7189
* Setup VitePress with the given options
7290
*/
@@ -104,11 +122,7 @@ public function setup( $args ) {
104122
$hcpp->nodeapp->allocate_ports( $nodeapp_folder );
105123

106124
// Flag to add .vitepress to nginx.conf and nginx.ssl.conf on hcpp_nginx_reload
107-
if ( file_exists( '/tmp/vitepress_domains') ) {
108-
$vitepress_domains = json_decode( file_get_contents( '/tmp/vitepress_domains' ), true );
109-
}
110-
$vitepress_domains[] = [ 'user' => $user, 'domain' => $domain ];
111-
file_put_contents( '/tmp/vitepress_domains', json_encode( $vitepress_domains ) );
125+
$this->priv_unsuspend_domain( [ $user, $domain ] );
112126

113127
// Update proxy and restart nginx
114128
if ( $nodeapp_folder . '/' == $vitepress_folder ) {

0 commit comments

Comments
 (0)