->endpoint_die( 'Lite Connect: nonce verification failed', $response ); } unset( $response['nonce'] ); $settings = get_option( Integration::get_option_name(), [] ); $settings['site'] = $response; update_option( API::GENERATE_KEY_ATTEMPT_COUNTER_OPTION, 0 ); update_option( Integration::get_option_name(), $settings ); exit(); } /** * Finish the endpoint execution with wp_die(). * * @since 1.7.4 * * @param string $title Log message title. * @param array $response Response. * * @noinspection ForgottenDebugOutputInspection */ private function endpoint_die( $title = '', $response = [] ) { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks $this->log( $title, $response ); // We call wp_die too early, before the query is run. // So, we should remove some filters to avoid having PHP notices in error log. remove_filter( 'wp_robots', 'wp_robots_noindex_embeds' ); remove_filter( 'wp_robots', 'wp_robots_noindex_search' ); wp_die( esc_html__( 'This is the Lite Connect endpoint page.', 'wpforms-lite' ), 'Lite Connect endpoint', 400 ); } /** * Log message. * * @since 1.7.4 * * @param string $title Log message title. * @param array $response Response. */ private function log( $title = '', $response = [] ) { if ( ! $title ) { return; } wpforms_log( $title, [ 'response' => $response, 'request' => [ 'domain' => isset( $response['domain'] ) ? $response['domain'] : '', 'admin_email' => Integration::get_enabled_email(), ], ], [ 'type' => [ 'error' ] ] ); } }