Skip to content

Commit bb14870

Browse files
committed
Add short pugins name.
1 parent e68828a commit bb14870

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

gvs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function gvs_main()
5757
->saveLogToState();
5858

5959
// add a notice of success
60-
$gvs->setNotice('Plugin succesfully replaced.', 'success');
60+
$gvs->setNotice('Plugin '. $gvs->plugin_version_short_name .' successfully replaced.', 'success');
6161

6262
// do redirect
6363
wp_redirect(get_admin_url() . '?page=gvs_page');
@@ -69,7 +69,7 @@ function gvs_main()
6969
$gvs->saveLogToState();
7070

7171
// add a notice of error
72-
$gvs->setNotice('Error occurred:' . $e->getMessage(), 'error');
72+
$gvs->setNotice('Error occurred during installation of ' . $gvs->plugin_version_short_name . ':' . $e->getMessage(), 'error');
7373

7474
// do redirect
7575
wp_redirect(get_admin_url() . '?page=gvs_page');

inc/gvs_helper.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
<?php
2-
function gvs_log($msg)
3-
{
4-
error_log('AVS_DEBUG: ' . var_export($msg,true));
5-
if (GVS_DEBUG_DISPLAY) {
6-
if (is_string($msg)) {
7-
echo $msg . "\n";
8-
} else {
9-
echo var_export($msg) . "\n";
10-
}
11-
}
12-
}
132

143
function gvs_delete_folder_recursive($path)
154
{
@@ -82,3 +71,19 @@ function gvs_prepare_filesystem()
8271

8372
return true;
8473
}
74+
75+
function gvs_get_plugin_version_short_name($url)
76+
{
77+
$regex_github = '/download\/([a-z,0-9].*)\/' . $this->process_plugin->plugin_slug . '/';
78+
preg_match_all('/plugin\/([a-z,0-9].*\.zip)/', $url,$matches_wp);
79+
preg_match_all($regex_github, $url,$matches_github);
80+
81+
if (isset($matches_wp[1],$matches_wp[1][0])) {
82+
$short = $matches_wp[1][0];
83+
}
84+
if (isset($matches_github[1],$matches_github[1][0])) {
85+
$short = $this->process_plugin->inner_name . '-' . $matches_github[1][0];
86+
}
87+
88+
return !empty($short) ? $short : $this->process_plugin->inner_name;
89+
}

lib/GVS/GVS.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class GVS
2222
*/
2323
private $state_file = GVS_PLUGIN_DIR . '\files\state.gvs';
2424

25+
/**
26+
* @var
27+
*/
28+
public $plugin_version_short_name;
29+
2530
public function __construct()
2631
{
2732
$this->plugins_data['apbct'] = new GVSPluginDataDTO(
@@ -190,6 +195,8 @@ public function downloadPluginZip($url)
190195
throw new \Exception('This URL is not allowed: ' . $url);
191196
}
192197

198+
$this->plugin_version_short_name = gvs_get_plugin_version_short_name($url);
199+
193200
$this->writeStreamLog("Downloading content of $url to $output_path ...");
194201

195202
if ( !is_dir($output_path) ) {

0 commit comments

Comments
 (0)