PluginProbe
AntiSpam for Contact Form 7 / trunk
AntiSpam for Contact Form 7 vtrunk
trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.3.0 0.4.2 0.4.3 0.4.4 0.4.5 0.6.0 0.6.1 0.6.2 0.6.3 0.6.4 0.7.0 0.7.1 0.7.2 0.7.3 0.7.4 All 27 releases
cf7-antispam / cf7-antispam.php

cf7-antispam.php in AntiSpam for Contact Form 7 trunk, at cf7-antispam.php

147 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: AntiSpam for Contact Form 7
4 * Description: A trustworthy antispam plugin for Contact Form 7. Simple but effective.
5 * Author: Codekraft
6 * Text Domain: cf7-antispam
7 * Domain Path: /languages
8 * Version: 0.7.6
9 * License: GPLv2 or later
10 * Requires Plugins: contact-form-7
11 *
12 * @package cf7-antispam
13 */
14
15 /* If this file is called directly, abort. */
16 if ( ! defined( 'WPINC' ) ) {
17 die;
18 }
19
20 /* CONSTANTS */
21 define( 'CF7ANTISPAM_NAME', 'cf7-antispam' );
22
23 define( 'CF7ANTISPAM_VERSION', '0.7.6' );
24
25 define( 'CF7ANTISPAM_PLUGIN', __FILE__ );
26
27 define( 'CF7ANTISPAM_PLUGIN_BASENAME', plugin_basename( CF7ANTISPAM_PLUGIN ) );
28
29 define( 'CF7ANTISPAM_PLUGIN_DIR', untrailingslashit( dirname( CF7ANTISPAM_PLUGIN ) ) );
30
31 define( 'CF7ANTISPAM_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
32
33 define( 'CF7ANTISPAM_LOG_PREFIX', 'CF7A: ' );
34
35 if ( ! defined( 'CF7ANTISPAM_DEBUG' ) ) {
36 define( 'CF7ANTISPAM_DEBUG', false );
37 }
38 if ( ! defined( 'CF7ANTISPAM_DEBUG_EXTENDED' ) ) {
39 define( 'CF7ANTISPAM_DEBUG_EXTENDED', false );
40 }
41 if ( ! defined( 'CF7ANTISPAM_DNSBL_BENCHMARK' ) ) {
42 define( 'CF7ANTISPAM_DNSBL_BENCHMARK', false );
43 }
44
45 if ( ! defined( 'CF7ANTISPAM_PREFIX' ) ) {
46 define( 'CF7ANTISPAM_PREFIX', '_cf7a_' );
47 }
48 if ( ! defined( 'CF7ANTISPAM_HONEYPOT_CLASS' ) ) {
49 define( 'CF7ANTISPAM_HONEYPOT_CLASS', 'fit-the-fullspace' );
50 }
51 if ( ! defined( 'CF7ANTISPAM_CYPHER' ) ) {
52 define( 'CF7ANTISPAM_CYPHER', 'aes-128-cbc' );
53 }
54
55 if ( ! defined( 'CF7ANTISPAM_GEOIP_KEY' ) ) {
56 define( 'CF7ANTISPAM_GEOIP_KEY', false );
57 }
58
59 /**
60 * CF7-AntiSpam autoload
61 */
62 require_once CF7ANTISPAM_PLUGIN_DIR . '/vendor/autoload.php';
63
64 /**
65 * CF7-AntiSpam functions
66 */
67 require_once CF7ANTISPAM_PLUGIN_DIR . '/core/functions.php';
68
69 /**
70 * The code that runs during plugin activation.
71 *
72 * @param bool $network_wide - Whether to activate the plugin for the en
73 */
74 function cf7a_activate( bool $network_wide ) {
75 \CF7_AntiSpam\Engine\CF7_AntiSpam_Activator::on_activate( $network_wide );
76 }
77 register_activation_hook( CF7ANTISPAM_PLUGIN, 'cf7a_activate' );
78
79 /**
80 * Creating the cf7-antispam tables whenever a new blog is created
81 *
82 * @param int $blog_id - The ID of the new blog.
83 *
84 * @since 0.4.5
85 */
86 function cf7a_on_create_blog( int $blog_id ) {
87 if ( is_plugin_active_for_network( 'cf7-antispam/cf7-antispam.php' ) ) {
88 switch_to_blog( $blog_id );
89 \CF7_AntiSpam\Engine\CF7_AntiSpam_Activator::activate();
90 restore_current_blog();
91 }
92 }
93 add_action( 'wpmu_new_blog', 'cf7a_on_create_blog' );
94
95 /**
96 * Deleting the table whenever a blog is deleted
97 *
98 * @param array $tables - Array of tables.
99 *
100 * @since 0.4.5
101 */
102 function cf7a_on_delete_blog( array $tables ): array {
103 global $wpdb;
104 $tables[] = $wpdb->prefix . 'cf7a_wordlist';
105 $tables[] = $wpdb->prefix . 'cf7a_blocklist';
106 return $tables;
107 }
108 add_filter( 'wpmu_drop_tables', 'cf7a_on_delete_blog' );
109
110 /**
111 * The code that runs during plugin deactivation.
112 */
113 function cf7a_deactivate() {
114 \CF7_AntiSpam\Engine\CF7_AntiSpam_Deactivator::deactivate();
115 }
116 register_deactivation_hook( CF7ANTISPAM_PLUGIN, 'cf7a_deactivate' );
117
118 /**
119 * The code that runs during plugin un-installation.
120 */
121 function cf7a_uninstall() {
122 \CF7_AntiSpam\Engine\CF7_AntiSpam_Uninstaller::uninstall();
123 }
124 register_uninstall_hook( CF7ANTISPAM_PLUGIN, 'cf7a_uninstall' );
125
126
127 /**
128 * Call the integration action to mount our plugin as a component into the integration page
129 */
130 function cf7a_register_service() {
131 $integration = WPCF7_Integration::get_instance();
132 $integration->add_service(
133 'cf7-antispam',
134 \CF7_AntiSpam\Core\CF7_Antispam_Service::get_instance()
135 );
136 }
137 add_action( 'wpcf7_init', 'cf7a_register_service', 2, 0 );
138
139 /**
140 * Executes CF7-AntiSpam
141 */
142 function cf7a_run() {
143 $cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam();
144 $cf7a->run();
145 }
146 add_action( 'init', 'cf7a_run', 11 );
147