| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file contains the routes for the plugin. |
| 4 |
* |
| 5 |
* @package WP_Defender |
| 6 |
*/ |
| 7 |
|
| 8 |
use Calotes\Helper\Route; |
| 9 |
use Calotes\Helper\Array_Cache; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
die; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Initializes the routes for the plugin. |
| 17 |
* |
| 18 |
* @return void |
| 19 |
*/ |
| 20 |
function defender_init_routes() { |
| 21 |
$routes = array( |
| 22 |
'mask_login' => array( |
| 23 |
'update_settings' => 'save_settings', |
| 24 |
'get_posts' => 'get_posts', |
| 25 |
), |
| 26 |
'security_headers' => array( |
| 27 |
'update_settings' => 'save_settings', |
| 28 |
), |
| 29 |
'two_fa' => array( |
| 30 |
'update_settings' => 'save_settings', |
| 31 |
'send_test_email' => 'send_test_email', |
| 32 |
'verify_otp_for_enabling' => 'verify_otp_for_enabling', |
| 33 |
'disable_totp' => 'disable_totp', |
| 34 |
'send_backup_code' => array( 'send_backup_code', true ), |
| 35 |
'generate_backup_codes' => 'generate_backup_codes', |
| 36 |
), |
| 37 |
'security_tweaks' => array( |
| 38 |
'process' => 'process', |
| 39 |
'ignore' => 'ignore', |
| 40 |
'revert' => 'revert', |
| 41 |
'restore' => 'restore', |
| 42 |
'recheck' => 'recheck', |
| 43 |
'bulk_action' => 'bulk_action', |
| 44 |
'update_security_reminder' => 'update_security_reminder', |
| 45 |
'update_autogenerate_flag' => 'update_autogenerate_flag', |
| 46 |
'update_enabled_user_enums' => 'update_enabled_user_enums', |
| 47 |
'handle_notice' => 'handle_notice', |
| 48 |
'refuse_notice' => 'refuse_notice', |
| 49 |
'check_xml_rpc' => 'check_xml_rpc', |
| 50 |
), |
| 51 |
'ip_lockout' => array( |
| 52 |
'update_settings' => 'save_settings', |
| 53 |
'download_geo_db' => 'download_geo_db', |
| 54 |
'import_ips' => 'import_ips', |
| 55 |
'get_listed_ips' => 'get_listed_ips', |
| 56 |
'query_locked_ips' => 'query_locked_ips', |
| 57 |
'ip_action' => 'ip_action', |
| 58 |
'export_ips' => 'export_ips', |
| 59 |
'empty_logs' => 'empty_logs', |
| 60 |
'dashboard_activation' => 'dashboard_activation', |
| 61 |
'import_ua' => 'import_ua', |
| 62 |
'export_ua' => 'export_ua', |
| 63 |
'empty_lockouts' => 'empty_lockouts', |
| 64 |
'verify_blocked_user' => array( 'verify_blocked_user', true ), |
| 65 |
'send_again' => array( 'send_again', true ), |
| 66 |
'agf_unlock_user' => array( 'agf_unlock_user', true ), |
| 67 |
), |
| 68 |
'global_ip_lockout' => array( |
| 69 |
'refresh_global_ip_list' => 'refresh_global_ip_list', |
| 70 |
'redirect_hub_connection' => 'redirect_hub_connection', |
| 71 |
), |
| 72 |
'scan' => array( |
| 73 |
'start' => 'start', |
| 74 |
'cancel' => 'cancel', |
| 75 |
'process' => array( 'process', true ), |
| 76 |
'status' => 'status', |
| 77 |
'item_action' => 'item_action', |
| 78 |
'update_settings' => 'save_settings', |
| 79 |
'bulk_action' => 'bulk_action', |
| 80 |
'handle_notice' => 'handle_notice', |
| 81 |
'postpone_notice' => 'postpone_notice', |
| 82 |
'refuse_notice' => 'refuse_notice', |
| 83 |
), |
| 84 |
'audit' => array( |
| 85 |
'update_settings' => 'save_settings', |
| 86 |
'pull_logs' => 'pull_logs', |
| 87 |
'summary' => 'summary', |
| 88 |
'export_as_csv' => 'export_as_csv', |
| 89 |
), |
| 90 |
'notification' => array( |
| 91 |
'get_users' => 'get_users', |
| 92 |
'save_notification' => 'save_notification', |
| 93 |
'unscubscribe' => 'unsubscribe', |
| 94 |
'subscribe' => 'subscribe', |
| 95 |
'save_frequency' => 'save_frequency', |
| 96 |
'save_subscriber' => 'save_subscriber', |
| 97 |
'save_configs' => 'save_configs', |
| 98 |
'save_bulk_configs' => 'save_bulk_configs', |
| 99 |
'bulk_deactivate' => 'bulk_deactivate', |
| 100 |
'validate_email' => 'validate_email', |
| 101 |
), |
| 102 |
'dashboard' => array( |
| 103 |
'hide_new_features' => 'hide_new_features', |
| 104 |
'activate_global_ip' => 'activate_global_ip', |
| 105 |
'remove_global_ip_notice_reminder' => 'remove_global_ip_notice_reminder', |
| 106 |
'activate_session_protection' => 'activate_session_protection', |
| 107 |
), |
| 108 |
'settings' => array( |
| 109 |
'update_settings' => 'save_settings', |
| 110 |
'reset_settings' => 'reset_settings', |
| 111 |
), |
| 112 |
'waf' => array( |
| 113 |
'recheck' => 'recheck', |
| 114 |
), |
| 115 |
'onboard' => array( |
| 116 |
'activating' => 'activating', |
| 117 |
'skip' => 'skip', |
| 118 |
'antibot_reminder' => 'antibot_reminder', |
| 119 |
), |
| 120 |
'blocklist_monitor' => array( |
| 121 |
'blacklist_status' => 'blacklist_status', |
| 122 |
'toggle_blacklist_status' => 'toggle_blacklist_status', |
| 123 |
), |
| 124 |
'tracking' => array( |
| 125 |
'close_track_modal' => 'close_track_modal', |
| 126 |
'save_track_modal' => 'save_track_modal', |
| 127 |
), |
| 128 |
'hub_connector' => array( |
| 129 |
'activate_dashboard_plugin' => 'activate_dashboard_plugin', |
| 130 |
), |
| 131 |
); |
| 132 |
|
| 133 |
if ( class_exists( 'WP_Defender\Controller\Quarantine' ) ) { |
| 134 |
$routes['quarantine'] = array( |
| 135 |
'restore_file' => 'restore_file', |
| 136 |
'quarantine_collection' => 'quarantine_collection', |
| 137 |
'delete_file' => 'delete_file', |
| 138 |
); |
| 139 |
} |
| 140 |
|
| 141 |
foreach ( $routes as $module => $info ) { |
| 142 |
foreach ( $info as $name => $func ) { |
| 143 |
$nopriv = false; |
| 144 |
if ( is_array( $func ) ) { |
| 145 |
[ $func, $nopriv ] = $func; |
| 146 |
} |
| 147 |
Route::register_route( |
| 148 |
$name, |
| 149 |
$module, |
| 150 |
$name, |
| 151 |
array( |
| 152 |
Array_Cache::get( $module ), |
| 153 |
$func, |
| 154 |
), |
| 155 |
$nopriv |
| 156 |
); |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
defender_init_routes(); |
| 162 |
|