Skip to content

Commit a9bbf0b

Browse files
fix: graceful handling when vendor/autoload.php is missing
Co-Authored-By: yoshiko@digitalcube.jp <yoshiko@digitalcube.jp>
1 parent 01c3d52 commit a9bbf0b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

shifter-github-hosting-plugin-sample.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,20 @@
77
Version: {release version}
88
Author URI: https://getshifter.io/
99
*/
10-
require __DIR__ . '/vendor/autoload.php';
10+
11+
$shifter_github_hosting_autoload = __DIR__ . '/vendor/autoload.php';
12+
13+
if ( ! file_exists( $shifter_github_hosting_autoload ) ) {
14+
add_action( 'admin_notices', function() {
15+
printf(
16+
'<div class="notice notice-error"><p>%s</p></div>',
17+
esc_html__( 'Shifter GitHub hosting plugin sample requires Composer dependencies. Please run "composer install" in the plugin directory, or install the plugin from a GitHub Release zip.', 'shifter-github-hosting-plugin-sample' )
18+
);
19+
});
20+
return;
21+
}
22+
23+
require $shifter_github_hosting_autoload;
1124

1225
add_action( 'admin_notices', function() {
1326
// get Shifter News
@@ -61,4 +74,4 @@
6174
}
6275
</style>
6376
";
64-
});
77+
});

0 commit comments

Comments
 (0)