safeLoad(); } /** * Define all the Kudos Donations constants for use throughout the plugin. */ define( 'KUDOS_VERSION', '3.1.0-beta' ); define( 'KUDOS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'KUDOS_PLUGIN_DIR', dirname( __FILE__ ) ); define( 'KUDOS_STORAGE_URL', wp_upload_dir()['baseurl'] . '/kudos-donations/' ); define( 'KUDOS_STORAGE_DIR', wp_upload_dir()['basedir'] . '/kudos-donations/' ); define( 'KUDOS_DEBUG', get_option( '_kudos_debug_mode' ) ); /** * Check if we are in development mode and if so replace the default * error handler with a more developer friendly one. * * @link https://github.com/filp/whoops */ if ( class_exists( Run::class ) && ( $_ENV['WP_ENV'] ?? '' ) === 'development' ) { $run = new Run(); $handler = new PrettyPageHandler; // Set the title of the error page. $handler->setPageTitle( "Whoops! There was a problem." ); $run->pushHandler( $handler ); // Register the handler with PHP. $run->register(); } /** * The code that runs during plugin activation. */ function activate_kudos() { $activator = new ActivatorService(); $activator->activate(); } /** * The code that runs during plugin deactivation. */ function deactivate_kudos() { DeactivatorService::deactivate(); } register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_kudos' ); register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_kudos' ); /** * The core plugin class that is used to define admin-specific hooks * and public-facing site hooks. */ require KUDOS_PLUGIN_DIR . '/app/KudosDonations.php'; /** * Begins execution of the plugin. * * Since everything within the plugin is registered via hooks, * then kicking off the plugin from this point in the file does * not affect the page life cycle. */ function run_kudos_donations() { // Check compatibility and run kudos if OK $compatibility = new CompatibilityService(); if ( $compatibility->init() ) { // Create our container for dependency injection. $builder = new ContainerBuilder(); $builder->useAutowiring(true); $builder->addDefinitions( KUDOS_PLUGIN_DIR . '/app/config.php' ); if(isset($_ENV['WP_ENV']) && $_ENV['WP_ENV'] !== 'development') { $builder->enableCompilation(KUDOS_STORAGE_DIR . '/php-di/cache'); } $container = $builder->build(); // Create and run our main plugin class. $plugin = new KudosDonations( $container, KUDOS_VERSION, 'kudos-donations' ); $plugin->run(); } } run_kudos_donations();