| @@ -1,65 +1,83 @@ | ||
| 1 | 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 | + | |
| 2 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 12 | die; |
| 4 | 13 | } |
| 5 | 14 | |
| 15 | +/** | |
| 16 | + * Initializes the routes for the plugin. | |
| 17 | + * | |
| 18 | + * @return void | |
| 19 | + */ | |
| 6 | 20 | function defender_init_routes() { |
| 7 | - $routes = [ | |
| 8 | - 'mask_login' => [ | |
| 21 | + $routes = array( | |
| 22 | + 'mask_login' => array( | |
| 9 | 23 | 'update_settings' => 'save_settings', |
| 10 | - 'get_posts' => 'get_posts', | |
| 11 | - ], | |
| 12 | - 'security_headers' => [ | |
| 13 | - 'update_settings' => 'save_settings' | |
| 14 | - ], | |
| 15 | - 'two_fa' => [ | |
| 24 | + 'get_posts' => 'get_posts', | |
| 25 | + ), | |
| 26 | + 'security_headers' => array( | |
| 27 | + 'update_settings' => 'save_settings', | |
| 28 | + ), | |
| 29 | + 'two_fa' => array( | |
| 16 | 30 | 'update_settings' => 'save_settings', |
| 17 | 31 | 'send_test_email' => 'send_test_email', |
| 18 | 32 | 'verify_otp_for_enabling' => 'verify_otp_for_enabling', |
| 19 | 33 | 'disable_totp' => 'disable_totp', |
| 20 | - 'send_backup_code' => [ 'send_backup_code', true ], | |
| 34 | + 'send_backup_code' => array( 'send_backup_code', true ), | |
| 21 | 35 | 'generate_backup_codes' => 'generate_backup_codes', |
| 22 | - ], | |
| 23 | - 'security_tweaks' => [ | |
| 36 | + ), | |
| 37 | + 'security_tweaks' => array( | |
| 24 | 38 | 'process' => 'process', |
| 25 | 39 | 'ignore' => 'ignore', |
| 26 | 40 | 'revert' => 'revert', |
| 27 | 41 | 'restore' => 'restore', |
| 28 | 42 | 'recheck' => 'recheck', |
| 29 | - 'bulk' => 'bulk_hub', | |
| 43 | + 'bulk_action' => 'bulk_action', | |
| 30 | 44 | 'update_security_reminder' => 'update_security_reminder', |
| 31 | 45 | 'update_autogenerate_flag' => 'update_autogenerate_flag', |
| 32 | 46 | 'update_enabled_user_enums' => 'update_enabled_user_enums', |
| 33 | - ], | |
| 34 | - 'ip_lockout' => [ | |
| 35 | - 'update_settings' => 'save_settings', | |
| 36 | - 'download_geo_db' => 'download_geo_db', | |
| 37 | - 'import_ips' => 'import_ips', | |
| 38 | - 'query_locked_ips' => 'query_locked_ips', | |
| 39 | - 'ip_action' => 'ip_action', | |
| 40 | - 'export_ips' => 'export_ips', | |
| 41 | - 'empty_logs' => 'empty_logs', | |
| 42 | - 'dashboard_activation' => 'dashboard_activation', | |
| 43 | - 'import_ua' => 'import_ua', | |
| 44 | - 'export_ua' => 'export_ua', | |
| 45 | - ], | |
| 46 | - 'scan' => [ | |
| 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( | |
| 47 | 71 | 'start' => 'start', |
| 48 | 72 | 'cancel' => 'cancel', |
| 49 | - 'process' => [ 'process', true ], | |
| 73 | + 'process' => array( 'process', true ), | |
| 50 | 74 | 'status' => 'status', |
| 51 | - 'item_hub' => 'item_hub', | |
| 75 | + 'item_action' => 'item_action', | |
| 52 | 76 | 'update_settings' => 'save_settings', |
| 53 | - 'bulk_hub' => 'bulk_hub' | |
| 54 | - ], | |
| 55 | - 'audit' => [ | |
| 56 | - 'update_settings' => 'save_settings', | |
| 57 | - 'pull_logs' => 'pull_logs', | |
| 58 | - 'summary' => 'summary', | |
| 59 | - 'export_as_csv' => 'export_as_csv' | |
| 60 | - ], | |
| 61 | - 'notification' => [ | |
| 77 | + 'bulk_action' => 'bulk_action', | |
| 78 | + ), | |
| 79 | + 'notification' => array( | |
| 62 | 80 | 'get_users' => 'get_users', |
| 63 | 81 | 'save_notification' => 'save_notification', |
| 64 | 82 | 'unscubscribe' => 'unsubscribe', |
| 65 | 83 | 'subscribe' => 'subscribe', |
| @@ -68,41 +86,62 @@ | ||
| 68 | 86 | 'save_configs' => 'save_configs', |
| 69 | 87 | 'save_bulk_configs' => 'save_bulk_configs', |
| 70 | 88 | 'bulk_deactivate' => 'bulk_deactivate', |
| 71 | 89 | 'validate_email' => 'validate_email', |
| 72 | - ], | |
| 73 | - 'dashboard' => [ | |
| 74 | - 'hide_new_features' => 'hide_new_features', | |
| 75 | - ], | |
| 76 | - 'settings' => [ | |
| 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( | |
| 77 | 98 | 'update_settings' => 'save_settings', |
| 78 | - 'reset_settings' => 'reset_settings' | |
| 79 | - ], | |
| 80 | - 'waf' => [ | |
| 81 | - 'recheck' => 'recheck' | |
| 82 | - ], | |
| 83 | - 'onboard' => [ | |
| 84 | - 'activating' => 'activating', | |
| 85 | - 'skip' => 'skip', | |
| 86 | - ], | |
| 87 | - 'tutorial' => [ | |
| 88 | - 'hide' => 'hide' | |
| 89 | - ], | |
| 90 | - 'blocklist_monitor' => [ | |
| 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( | |
| 91 | 114 | 'blacklist_status' => 'blacklist_status', |
| 92 | 115 | 'toggle_blacklist_status' => 'toggle_blacklist_status', |
| 93 | - ], | |
| 94 | - ]; | |
| 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 | + ); | |
| 95 | 127 | foreach ( $routes as $module => $info ) { |
| 128 | + $controller = Array_Cache::get( $module ); | |
| 129 | + if ( null === $controller ) { | |
| 130 | + continue; | |
| 131 | + } | |
| 96 | 132 | foreach ( $info as $name => $func ) { |
| 97 | 133 | $nopriv = false; |
| 98 | 134 | if ( is_array( $func ) ) { |
| 99 | - [$func, $nopriv] = $func; | |
| 135 | + [ $func, $nopriv ] = $func; | |
| 100 | 136 | } |
| 101 | - \Calotes\Helper\Route::register_route( $name, $module, $name, [ | |
| 102 | - \Calotes\Helper\Array_Cache::get( $module ), | |
| 103 | - $func | |
| 104 | - ], $nopriv ); | |
| 137 | + Route::register_route( | |
| 138 | + $name, | |
| 139 | + $module, | |
| 140 | + $name, | |
| 141 | + array( $controller, $func ), | |
| 142 | + $nopriv | |
| 143 | + ); | |
| 105 | 144 | } |
| 106 | 145 | } |
| 107 | 146 | } |
| 108 | 147 | |