PluginProbe
AntiSpam for Contact Form 7 / 0.7.2
AntiSpam for Contact Form 7 v0.7.2
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 0.7.2, at cf7-antispam.php

153 lines 4.3 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.2
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.2' );
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 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
73 function activate_cf7_antispam( $network_wide ) {
74 \CF7_AntiSpam\Engine\CF7_AntiSpam_Activator::on_activate( $network_wide );
75 }
76 register_activation_hook( CF7ANTISPAM_PLUGIN, 'activate_cf7_antispam' );
77
78 /**
79 * Creating the cf7-antispam tables whenever a new blog is created
80 *
81 * @since 0.4.5
82 *
83 * @param int $blog_id - The ID of the new blog.
84 */
85 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
86 function on_create_blog( $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', 'on_create_blog' );
94
95 /**
96 * Deleting the table whenever a blog is deleted
97 *
98 * @since 0.4.5
99 *
100 * @param array $tables - Array of tables.
101 */
102 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
103 function on_delete_blog( $tables ) {
104 global $wpdb;
105 $tables[] = $wpdb->prefix . 'cf7a_wordlist';
106 $tables[] = $wpdb->prefix . 'cf7a_blacklist';
107 return $tables;
108 }
109 add_filter( 'wpmu_drop_tables', 'on_delete_blog' );
110
111 /**
112 * The code that runs during plugin deactivation.
113 */
114 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
115 function deactivate_cf7_antispam() {
116 \CF7_AntiSpam\Engine\CF7_AntiSpam_Deactivator::deactivate();
117 }
118 register_deactivation_hook( CF7ANTISPAM_PLUGIN, 'deactivate_cf7_antispam' );
119
120 /**
121 * The code that runs during plugin un-installation.
122 */
123 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
124 function uninstall_cf7_antispam() {
125 \CF7_AntiSpam\Engine\CF7_AntiSpam_Uninstaller::uninstall();
126 }
127 register_uninstall_hook( CF7ANTISPAM_PLUGIN, 'uninstall_cf7_antispam' );
128
129
130 /**
131 * Call the integration action to mount our plugin as a component
132 * into the intefration page
133 */
134 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
135 function cf7_antispam_register_service() {
136 $integration = WPCF7_Integration::get_instance();
137 $integration->add_service(
138 'cf7-antispam',
139 \CF7_AntiSpam\Core\CF7_Antispam_Service::get_instance()
140 );
141 }
142 add_action( 'wpcf7_init', 'cf7_antispam_register_service', 2, 0 );
143
144 /**
145 * Executes CF7-AntiSpam
146 */
147 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound */
148 function run_cf7a() {
149 $cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam();
150 $cf7a->run();
151 }
152 add_action( 'init', 'run_cf7a', 11 );
153