Skip to content

Instantly share code, notes, and snippets.

@jmichaelward
Created July 20, 2019 18:30
Show Gist options
  • Save jmichaelward/36d9bebe075a0dc66a06ed4116a53c4a to your computer and use it in GitHub Desktop.
Save jmichaelward/36d9bebe075a0dc66a06ed4116a53c4a to your computer and use it in GitHub Desktop.
Bootstrap file for Board Game Collector plugin.
<?php
/**
* Plugin Name: Board Game Collector
* Plugin URI: https://jmichaelward.com
* Description: Connects to the BoardGameGeek API to retrieve and adapt data for use by WordPress.
* Author: J. Michael Ward
* Author URI: https://jmichaelward.com
*
* @package JMichaelWard\BoardGameCollector
*/
namespace JMichaelWard\BoardGameCollector;
use Auryn\Injector;
use JMichaelWard\BoardGameCollector\Admin\Notifier;
use Throwable;
$plugin_path = plugin_dir_path( __FILE__ );
$autoload = $plugin_path . 'vendor/autoload.php';
if ( is_readable( $autoload ) ) {
require_once $autoload;
}
try {
add_action( 'plugins_loaded', [ new BoardGameCollector( $plugin_path, new Injector() ), 'run' ] );
} catch ( Throwable $e ) {
require_once $plugin_path . 'src/Admin/Notifier.php';
( new Notifier() )->do_error_notice(
'Could not locate BoardGameCollector class. Did you remember to run composer install?'
);
// Deactivate the plugin.
add_action(
'admin_init',
function () {
deactivate_plugins( __FILE__ );
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment