| 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 |
'check_xml_rpc' => 'check_xml_rpc', |
| 48 |
), |
| 49 |
'ip_lockout' => array( |
| 50 |
'update_settings' => 'save_settings', |
| 51 |
'download_geo_db' => 'download_geo_db', |
| 52 |
'import_ips' => 'import_ips', |
| 53 |
'get_listed_ips' => 'get_listed_ips', |
| 54 |
'query_locked_ips' => 'query_locked_ips', |
| 55 |
'ip_action' => 'ip_action', |
| 56 |
'export_ips' => 'export_ips', |
| 57 |
'empty_logs' => 'empty_logs', |
| 58 |
'toggle_lockout_modules' => 'toggle_lockout_modules', |
| 59 |
'import_ua' => 'import_ua', |
| 60 |
'export_ua' => 'export_ua', |
| 61 |
'empty_lockouts' => 'empty_lockouts', |
| 62 |
'verify_blocked_user' => array( 'verify_blocked_user', true ), |
| 63 |
'send_again' => array( 'send_again', true ), |
| 64 |
'agf_unlock_user' => array( 'agf_unlock_user', true ), |
| 65 |
), |
| 66 |
'global_ip_lockout' => array( |
| 67 |
'refresh_global_ip_list' => 'refresh_global_ip_list', |
| 68 |
'redirect_hub_connection' => 'redirect_hub_connection', |
| 69 |
), |
| 70 |
'scan' => array( |
| 71 |
'start' => 'start', |
| 72 |
'cancel' => 'cancel', |
| 73 |
'process' => array( 'process', true ), |
| 74 |
'status' => 'status', |
| 75 |
'item_action' => 'item_action', |
| 76 |
'update_settings' => 'save_settings', |
| 77 |
'bulk_action' => 'bulk_action', |
| 78 |
), |
| 79 |
'notification' => array( |
| 80 |
'get_users' => 'get_users', |
| 81 |
'save_notification' => 'save_notification', |
| 82 |
'unscubscribe' => 'unsubscribe', |
| 83 |
'subscribe' => 'subscribe', |
| 84 |
'save_frequency' => 'save_frequency', |
| 85 |
'save_subscriber' => 'save_subscriber', |
| 86 |
'save_configs' => 'save_configs', |
| 87 |
'save_bulk_configs' => 'save_bulk_configs', |
| 88 |
'bulk_deactivate' => 'bulk_deactivate', |
| 89 |
'validate_email' => 'validate_email', |
| 90 |
), |
| 91 |
'dashboard' => array( |
| 92 |
'hide_new_features' => 'hide_new_features', |
| 93 |
'activate_global_ip' => 'activate_global_ip', |
| 94 |
'remove_global_ip_notice_reminder' => 'remove_global_ip_notice_reminder', |
| 95 |
'activate_session_protection' => 'activate_session_protection', |
| 96 |
), |
| 97 |
'settings' => array( |
| 98 |
'update_settings' => 'save_settings', |
| 99 |
'reset_settings' => 'reset_settings', |
| 100 |
), |
| 101 |
'tracking' => array( |
| 102 |
'close_track_modal' => 'close_track_modal', |
| 103 |
'save_track_modal' => 'save_track_modal', |
| 104 |
), |
| 105 |
'hub_connector' => array( |
| 106 |
'activate_dashboard_plugin' => 'activate_dashboard_plugin', |
| 107 |
), |
| 108 |
'rate' => array( |
| 109 |
'postpone_notice' => 'postpone_notice', |
| 110 |
'refuse_notice' => 'refuse_notice', |
| 111 |
'handle_notice' => 'handle_notice', |
| 112 |
), |
| 113 |
'blocklist_monitor' => array( |
| 114 |
'blacklist_status' => 'blacklist_status', |
| 115 |
'toggle_blacklist_status' => 'toggle_blacklist_status', |
| 116 |
), |
| 117 |
'activity_log' => array( |
| 118 |
'add_notification' => 'add_notification', |
| 119 |
'fetch_notifications' => 'fetch_notifications', |
| 120 |
), |
| 121 |
'quarantine' => array( |
| 122 |
'restore_file' => 'restore_file', |
| 123 |
'quarantine_collection' => 'quarantine_collection', |
| 124 |
'delete_file' => 'delete_file', |
| 125 |
), |
| 126 |
); |
| 127 |
foreach ( $routes as $module => $info ) { |
| 128 |
$controller = Array_Cache::get( $module ); |
| 129 |
if ( null === $controller ) { |
| 130 |
continue; |
| 131 |
} |
| 132 |
foreach ( $info as $name => $func ) { |
| 133 |
$nopriv = false; |
| 134 |
if ( is_array( $func ) ) { |
| 135 |
[ $func, $nopriv ] = $func; |
| 136 |
} |
| 137 |
Route::register_route( |
| 138 |
$name, |
| 139 |
$module, |
| 140 |
$name, |
| 141 |
array( $controller, $func ), |
| 142 |
$nopriv |
| 143 |
); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
defender_init_routes(); |
| 149 |
|