'360-orbit-login-guard', 'version' => WP360_LG_VERSION, 'exported_at' => gmdate( 'c' ), 'settings' => Wp360_Login_Guard_Settings::get(), ); nocache_headers(); header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Disposition: attachment; filename="360-orbit-login-guard-settings.json"' ); echo wp_json_encode( $payload, JSON_PRETTY_PRINT ); exit; } public static function import() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => __( 'You do not have permission to do this.', '360-orbit-login-guard' ) ), 403 ); } check_ajax_referer( 'wp360_lg_nonce', 'nonce' ); $tmp_name = isset( $_FILES['file']['tmp_name'] ) ? sanitize_text_field( wp_unslash( $_FILES['file']['tmp_name'] ) ) : ''; if ( '' === $tmp_name || ! is_uploaded_file( $tmp_name ) ) { wp_send_json_error( array( 'message' => __( 'No file uploaded.', '360-orbit-login-guard' ) ), 400 ); } $raw = file_get_contents( $tmp_name ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents $data = json_decode( (string) $raw, true ); if ( ! is_array( $data ) || ! isset( $data['settings'] ) || ! is_array( $data['settings'] ) ) { wp_send_json_error( array( 'message' => __( 'This file does not look like a Login Guard settings export.', '360-orbit-login-guard' ) ), 400 ); } $settings = Wp360_Login_Guard_Settings::save( $data['settings'] ); wp_send_json_success( array( 'settings' => $settings ) ); } }