-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact-form-to-api.php
More file actions
93 lines (84 loc) · 2.48 KB
/
contact-form-to-api.php
File metadata and controls
93 lines (84 loc) · 2.48 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* CF7 to API
*
* @package SilverAssist\ContactFormToAPI
* @since 1.0.0
* @author Silver Assist
* @version 2.4.0
* @license Polyform-Noncommercial-1.0.0
*
* @wordpress-plugin
* Plugin Name: CF7 to API
* Plugin URI: https://github.com/SilverAssist/contact-form-to-api
* Description: Extend Contact Form 7 functionality by connecting forms to external APIs. Send form submissions to custom API endpoints with advanced configuration options.
* Version: 2.4.0
* Requires at least: 6.5
* Requires PHP: 8.2
* Author: Silver Assist
* Author URI: https://silverassist.com
* License: Polyform-Noncommercial-1.0.0
* License URI: https://github.com/SilverAssist/contact-form-to-api/blob/main/LICENSE
* Text Domain: contact-form-to-api
* Domain Path: /languages
* Requires Plugins: contact-form-7
* Network: false
* Update URI: https://github.com/SilverAssist/contact-form-to-api
*/
// Prevent direct access.
defined( 'ABSPATH' ) || exit;
// Define plugin constants.
define( 'CF7_API_VERSION', '2.4.0' );
define( 'CF7_API_FILE', __FILE__ );
define( 'CF7_API_DIR', plugin_dir_path( __FILE__ ) );
define( 'CF7_API_URL', plugin_dir_url( __FILE__ ) );
define( 'CF7_API_BASENAME', plugin_basename( __FILE__ ) );
// Minimum requirements.
define( 'CF7_API_MIN_PHP_VERSION', '8.2' );
define( 'CF7_API_MIN_WP_VERSION', '6.5' );
/**
* Composer autoloader
*/
$cf7_api_autoload_path = CF7_API_DIR . 'vendor/autoload.php';
$cf7_api_real_autoload_path = realpath( $cf7_api_autoload_path );
$cf7_api_real_path = realpath( CF7_API_DIR );
// Validate: both paths resolve, autoloader is inside plugin directory.
if (
$cf7_api_real_autoload_path &&
$cf7_api_real_path &&
0 === strpos( $cf7_api_real_autoload_path, $cf7_api_real_path )
) {
require_once $cf7_api_real_autoload_path;
} else {
add_action(
'admin_notices',
function () {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
esc_html__( 'Contact Form 7 to API: Missing or invalid Composer dependencies. Run "composer install".', 'contact-form-to-api' )
);
}
);
return;
}
// Initialize plugin.
add_action(
'plugins_loaded',
function () {
\SilverAssist\ContactFormToAPI\Core\Plugin::instance()->init();
}
);
// Register activation hook.
register_activation_hook(
__FILE__,
function () {
\SilverAssist\ContactFormToAPI\Core\Activator::activate();
}
);
// Register deactivation hook.
register_deactivation_hook(
__FILE__,
function () {
\SilverAssist\ContactFormToAPI\Core\Activator::deactivate();
}
);