Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
57.89% |
11 / 19 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| BrianHenryIE\Checkout_Rate_Limiter\instantiate_bh_wc_checkout_rate_limiter | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * The plugin bootstrap file |
| 4 | * |
| 5 | * This file is read by WordPress to generate the plugin information in the plugin |
| 6 | * admin area. This file also includes all of the dependencies used by the plugin, |
| 7 | * registers the activation and deactivation functions, and defines a function |
| 8 | * that starts the plugin. |
| 9 | * |
| 10 | * @link https://BrianHenryIE.com |
| 11 | * @since 1.0.0 |
| 12 | * @package BH_WC_Checkout_Rate_Limiter |
| 13 | * |
| 14 | * @wordpress-plugin |
| 15 | * Plugin Name: Checkout Rate Limiter |
| 16 | * Plugin URI: http://github.com/brianhenryie/bh-wc-checkout-rate-limiter/ |
| 17 | * Description: Rate limit the WooCommerce checkout to prevent card attacks. |
| 18 | * Version: 1.3.1 |
| 19 | * Requires PHP: 7.4 |
| 20 | * Author: BrianHenryIE |
| 21 | * Author URI: https://BrianHenry.IE |
| 22 | * License: GPL-2.0+ |
| 23 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 | * Text Domain: bh-wc-checkout-rate-limiter |
| 25 | * Domain Path: /languages |
| 26 | * |
| 27 | * GitHub Plugin URI: https://github.com/BrianHenryIE/bh-wc-checkout-rate-limiter |
| 28 | * Release Asset: true |
| 29 | */ |
| 30 | |
| 31 | namespace BrianHenryIE\Checkout_Rate_Limiter; |
| 32 | |
| 33 | use BrianHenryIE\Checkout_Rate_Limiter\API\Settings; |
| 34 | use BrianHenryIE\Checkout_Rate_Limiter\WP_Logger\Logger; |
| 35 | use BrianHenryIE\Checkout_Rate_Limiter\WP_Includes\Activator; |
| 36 | use BrianHenryIE\Checkout_Rate_Limiter\WP_Includes\Deactivator; |
| 37 | use Error; |
| 38 | use Exception; |
| 39 | use Throwable; |
| 40 | |
| 41 | // If this file is called directly, abort. |
| 42 | if ( ! defined( 'WPINC' ) ) { |
| 43 | throw new Exception( 'WPINC not defined' ); |
| 44 | } |
| 45 | |
| 46 | // If the GitHub repo was installed without running `composer install` to add the dependencies, the autoload will fail. |
| 47 | try { |
| 48 | require_once plugin_dir_path( __FILE__ ) . 'autoload.php'; |
| 49 | } catch ( Throwable $error ) { |
| 50 | $display_download_from_releases_error_notice = function() { |
| 51 | echo '<div class="notice notice-error"><p><b>Checkout Rate Limiter missing dependencies.</b> Please <a href="https://github.com/BrianHenryIE/bh-wc-checkout-rate-limiter/releases">install the distribution archive from the GitHub Releases page</a>. It appears you downloaded the GitHub repo and installed that as the plugin.</p></div>'; |
| 52 | }; |
| 53 | add_action( 'admin_notices', $display_download_from_releases_error_notice ); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | define( 'BH_WC_CHECKOUT_RATE_LIMITER_VERSION', '1.3.1' ); |
| 58 | define( 'BH_WC_CHECKOUT_RATE_LIMITER_BASENAME', plugin_basename( __FILE__ ) ); |
| 59 | |
| 60 | register_activation_hook( __FILE__, array( Activator::class, 'activate' ) ); |
| 61 | register_deactivation_hook( __FILE__, array( Deactivator::class, 'deactivate' ) ); |
| 62 | |
| 63 | /** |
| 64 | * Begins execution of the plugin. |
| 65 | * |
| 66 | * Since everything within the plugin is registered via hooks, |
| 67 | * then kicking off the plugin from this point in the file does |
| 68 | * not affect the page life cycle. |
| 69 | * |
| 70 | * @since 1.0.0 |
| 71 | */ |
| 72 | function instantiate_bh_wc_checkout_rate_limiter(): void { |
| 73 | |
| 74 | $settings = new Settings(); |
| 75 | $logger = Logger::instance( $settings ); |
| 76 | |
| 77 | new BH_WC_Checkout_Rate_Limiter( $settings, $logger ); |
| 78 | |
| 79 | if ( class_exists( BH_Checkout_Rate_Limiter_SLSWC_Client::class ) ) { |
| 80 | \BH_Checkout_Rate_Limiter_SLSWC_Client::get_instance( 'https://bhwp.ie/', __FILE__ ); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | instantiate_bh_wc_checkout_rate_limiter(); |
| 85 |