PluginProbe
WP 2FA – Two-factor authentication for WordPress / 2.2.0
WP 2FA – Two-factor authentication for WordPress v2.2.0
4.1.0 4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 All 42 releases
wp-2fa / wp-2fa.php
wp-2fa.php
109 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP 2FA - Two-factor authentication for WordPress (Premium)
4 *
5 * @copyright Copyright (C) 2013-2022, WP White Security - support@wpwhitesecurity.com
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
7 *
8 * @wordpress-plugin
9 * Plugin Name: WP 2FA - Two-factor authentication for WordPress
10 * Version: 2.2.0
11 * Plugin URI: https://wp2fa.io/
12 * Description: Easily add an additional layer of security to your WordPress login pages. Enable Two-Factor Authentication for you and all your website users with this easy to use plugin.
13 * Author: WP White Security
14 * Author URI: https://www.wpwhitesecurity.com/
15 * Text Domain: wp-2fa
16 * Domain Path: /languages/
17 * License: GPL v3
18 * Requires at least: 5.0
19 * Requires PHP: 7.0
20 * Network: true
21 *
22 * @package WP2FA
23 *
24 * This program is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 */
37
38 if ( ! defined( 'ABSPATH' ) ) {
39 exit;
40 }
41
42 // Useful global constants.
43 if ( ! defined( 'WP_2FA_VERSION' ) ) {
44 define( 'WP_2FA_VERSION', '2.2.0' );
45 define( 'WP_2FA_URL', plugin_dir_url( __FILE__ ) );
46 define( 'WP_2FA_PATH', plugin_dir_path( __FILE__ ) );
47 define( 'WP_2FA_INC', WP_2FA_PATH . 'includes/' );
48 define( 'WP_2FA_FILE', __FILE__ );
49 define( 'WP_2FA_BASE', plugin_basename( __FILE__ ) );
50 define( 'WP_2FA_LOGS_DIR', 'wp-2fa-logs' );
51
52 // Prefix used in usermetas, settings and transients.
53 define( 'WP_2FA_PREFIX', 'wp_2fa_' );
54 define( 'WP_2FA_POLICY_SETTINGS_NAME', WP_2FA_PREFIX . 'policy' );
55 define( 'WP_2FA_SETTINGS_NAME', WP_2FA_PREFIX . 'settings' );
56 define( 'WP_2FA_WHITE_LABEL_SETTINGS_NAME', WP_2FA_PREFIX . 'white_label' );
57 define( 'WP_2FA_EMAIL_SETTINGS_NAME', WP_2FA_PREFIX . 'email_settings' );
58 }
59 // Include files.
60 require_once WP_2FA_INC . 'functions/core.php';
61
62 // Require Composer autoloader if it exists.
63 if ( file_exists( WP_2FA_PATH . 'vendor/autoload.php' ) ) {
64 require_once WP_2FA_PATH . 'vendor/autoload.php';
65 }
66
67 if ( file_exists( WP_2FA_PATH . 'third-party/vendor/autoload.php' ) ) {
68 require_once WP_2FA_PATH . 'third-party/vendor/autoload.php';
69 }
70
71 // run any required update routines.
72 \WP2FA\Utils\Migration::migrate();
73
74 $wp2fa = \WP2FA\WP2FA::get_instance();
75 $wp2fa->init();
76 if ( ! function_exists( 'wp2fa_free_on_plugin_activation' ) ) {
77 /**
78 * Takes care of deactivation of the premium plugin when the free plugin is activated.
79 *
80 * Note: This code MUST NOT be present in the premium version an is removed automatically during the build process.
81 *
82 * @since 2.0.0
83 */
84 function wp2fa_free_on_plugin_activation() {
85 $premium_version_slug = 'wp-2fa-premium/wp-2fa.php';
86 if ( is_plugin_active( $premium_version_slug ) ) {
87 deactivate_plugins( $premium_version_slug, true );
88 }
89 }
90
91 register_activation_hook( __FILE__, 'wp2fa_free_on_plugin_activation' );
92 }
93
94 /**
95 * Clears the config cache from the DB
96 *
97 * @return void
98 *
99 * @since 2.2.0
100 */
101 add_action(
102 'upgrader_process_complete',
103 function() {
104 delete_transient( 'wp_2fa_config_file_hash' );
105 },
106 10,
107 2
108 );
109