profiler = $profiler; } public static function isEnabled() { //phpcs:ignore WordPress.Security.NonceVerification.Recommended return ! empty($_REQUEST[self::REQUEST_KEY]); } public function catchBounceEvent() { //phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! empty($_REQUEST[self::REQUEST_KEY])) { $this->actionBounceBack(); $this->profiler->installActionCollectReport(); } } /** * We wait until page fully loaded */ protected function actionBounceBack() { if (did_action('wp_print_scripts')) { _doing_it_wrong(__FUNCTION__, sprintf( /* translators: Message about the load order*/ //phpcs:ignore WordPress.WP.I18n.TextDomainMismatch, WordPress.WP.I18n.MissingTranslatorsComment esc_html__('%1$s should not be called earlier the %2$s action.', 'woocommerce'), 'action_bounce_back', 'wp_print_scripts' ), esc_html(WC_ADP_VERSION) ); return null; } add_action("wp_print_scripts", function () { $referer = wp_get_referer(); $referer = $referer ?: admin_url(); WC()->session->set(self::LAST_IMPORT_KEY_SESSION_KEY, $this->profiler->getImportKey()); ?> init(); if (isset($session->wdp_last_import_key)) { $importKey = $session->get(self::LAST_IMPORT_KEY_SESSION_KEY); $session->__unset(self::LAST_IMPORT_KEY_SESSION_KEY); $session->save_data(); } else { $importKey = false; } $reporter = new ReporterAjax(null); return !$importKey ? "" : add_query_arg(array( 'action' => 'download_report', ReporterAjax::IMPORT_KEY_REQUEST_KEY => $importKey, 'reports' => 'all', $reporter->getNonceParam() => wp_create_nonce($reporter->getNonceName()), ), admin_url("admin-ajax.php")); } }