Skip to content

Commit 85a4a8f

Browse files
authored
Check the class exists, to avoid fatals when composer hasn't been run.
Avoids PHP Fatals when the plugin is activated in production.
1 parent b66120a commit 85a4a8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plugin.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
require __DIR__ . '/vendor/autoload.php';
1414
}
1515

16-
global $wp_parser;
17-
$wp_parser = new WP_Parser\Plugin();
18-
$wp_parser->on_load();
16+
// Check the class exists, to avoid fatals when composer hasn't been run.
17+
if ( class_exists( 'WP_Parser\Plugin' ) ) {
18+
global $wp_parser;
19+
$wp_parser = new WP_Parser\Plugin();
20+
$wp_parser->on_load();
21+
}
1922

2023
register_activation_hook( __FILE__, array( 'P2P_Storage', 'init' ) );
2124
register_activation_hook( __FILE__, array( 'P2P_Storage', 'install' ) );

0 commit comments

Comments
 (0)