-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaptchala.php
More file actions
74 lines (69 loc) · 2.54 KB
/
Copy pathcaptchala.php
File metadata and controls
74 lines (69 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Plugin Name: CaptchaLa
* Plugin URI: https://captcha.la/integrations/wordpress
* Description: Smart privacy-first CAPTCHA + anti-spam. Protects WordPress core, WooCommerce, and 14+ third-party form plugins. Mandatory server-token anti-replay.
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 8.0
* Author: CaptchaLa
* Author URI: https://captcha.la/
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: captchala
* Domain Path: /languages
*
* WC requires at least: 3.0
* WC tested up to: 9.3
*
* @package Captchala\Wp
*/
declare( strict_types=1 );
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// -----------------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------------
const CAPTCHALA_WP_VERSION = '1.0.0';
define( 'CAPTCHALA_WP_FILE', __FILE__ );
define( 'CAPTCHALA_WP_PATH', plugin_dir_path( __FILE__ ) );
define( 'CAPTCHALA_WP_URL', plugin_dir_url( __FILE__ ) );
// -----------------------------------------------------------------------------
// Autoloader
// -----------------------------------------------------------------------------
// Prefer composer's autoloader (production builds bundle vendor/).
$captchala_wp_vendor = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $captchala_wp_vendor ) ) {
require_once $captchala_wp_vendor;
} else {
// Fallback: minimal PSR-4 loader covering this plugin and the bundled SDK
// source so the plugin still boots if the user uploaded the source-only
// tree (e.g. via `git clone`) without running `composer install`.
spl_autoload_register(
static function ( string $class ): void {
$prefixes = [
'Captchala\\Wp\\' => __DIR__ . '/src/',
'Captchala\\' => __DIR__ . '/../../sdk/php/src/',
];
foreach ( $prefixes as $prefix => $base_dir ) {
$len = strlen( $prefix );
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
continue;
}
$relative = substr( $class, $len );
$file = $base_dir . str_replace( '\\', '/', $relative ) . '.php';
if ( is_readable( $file ) ) {
require_once $file;
return;
}
}
}
);
}
// -----------------------------------------------------------------------------
// Boot
// -----------------------------------------------------------------------------
if ( class_exists( \Captchala\Wp\Plugin::class ) ) {
add_action( 'plugins_loaded', [ \Captchala\Wp\Plugin::class, 'boot' ], 5 );
}