Settings::SETTINGS_MENU_SLUG ), \admin_url( 'admin.php' ) ) . '#aadvana-options-tab-traffic-analytics'; } /** * Handles "Check again for all visitors". * * @return void * * @since 5.4.0 */ public static function recheck(): void { if ( ! \current_user_can( 'manage_options' ) ) { \wp_die( \esc_html__( 'Sorry, you are not allowed to do that.', '0-day-analytics' ), 403 ); } \check_admin_referer( self::RECHECK_ACTION ); Traffic_Endpoint::disable(); // Writes a fresh, unverified config - the next visitors' browsers verify it. Traffic_Endpoint::url(); \wp_safe_redirect( \add_query_arg( array( 'page' => Settings::SETTINGS_MENU_SLUG, 'advan_fast_collect' => 'rechecked' ), \admin_url( 'admin.php' ) ) . '#aadvana-options-tab-traffic-analytics' ); exit; } /** * Handles "Dismiss" on the notice. * * @return void * * @since 5.4.0 */ public static function dismiss(): void { if ( ! \current_user_can( 'manage_options' ) ) { \wp_die( \esc_html__( 'Sorry, you are not allowed to do that.', '0-day-analytics' ), 403 ); } \check_admin_referer( self::DISMISS_ACTION ); \update_user_meta( \get_current_user_id(), self::DISMISSED_META, Traffic_Endpoint::status()['checked'] ); \wp_safe_redirect( \wp_get_referer() ? \wp_get_referer() : \admin_url() ); exit; } /** * Admin notice while the fast collector does not work - until dismissed for that failure. * * Not on the settings page, where the panel says the same and more. * * @return void * * @since 5.4.0 */ public static function notice(): void { if ( ! \current_user_can( 'manage_options' ) || Settings::SETTINGS_MENU_SLUG === ( $_GET['page'] ?? '' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only picks the screen. return; } $status = Traffic_Endpoint::status(); if ( 'failed' !== $status['state'] || (int) \get_user_meta( \get_current_user_id(), self::DISMISSED_META, true ) === $status['checked'] ) { return; } $dismiss = \wp_nonce_url( \admin_url( 'admin-post.php?action=' . self::DISMISS_ACTION ), self::DISMISS_ACTION ); ?>
0 /* translators: 1: date and time, 2: how long ago, e.g. "5 mins" */ ? sprintf( \__( '%1$s (%2$s ago)', '0-day-analytics' ), \wp_date( \get_option( 'date_format' ) . ' ' . \get_option( 'time_format' ), $time ), \human_time_diff( $time ) ) : ''; }; $boxes = array( 'ok' => array( 'success', \__( 'In use. Pageviews are stored through the fast collector.', '0-day-analytics' ) ), 'failed' => array( 'error', \__( 'Not working on this site. Pageviews are stored through admin-ajax.php instead - nothing is lost, it is only slower.', '0-day-analytics' ) ), 'untested' => array( 'info', \__( 'Being verified. Pages offer the fast collector; the first visitor\'s browser that gets through marks it as working. Any pageview it cannot take goes through admin-ajax.php.', '0-day-analytics' ) ), 'off' => array( 'info', \__( 'Turned off. Pageviews are stored through admin-ajax.php.', '0-day-analytics' ) ), ); list( $box_type, $box_text ) = $boxes[ $status['state'] ]; $messages = array( /* translators: %d: milliseconds */ 'ok' => \__( 'Works from this browser: the collector answered in %d ms. It is marked as working now.', '0-day-analytics' ), 'c400' => \__( 'The collector refused the request as malformed (HTTP 400). Reload this page and test again.', '0-day-analytics' ), 'c403' => \__( 'The collector refused the request (HTTP 403): either the signature - reload this page and test again; if it persists, AUTH_KEY or AUTH_SALT differ between the collector and WordPress - or this admin is on another domain than the site, and the collector only takes requests from the site\'s own pages.', '0-day-analytics' ), 'c503' => \__( 'The collector ran, but has no configuration or cannot write to the traffic buffer directory in uploads (HTTP 503).', '0-day-analytics' ), /* translators: %d: HTTP status code */ 'refused' => \__( 'The collector answered with HTTP status %d.', '0-day-analytics' ), /* translators: %d: HTTP status code */ 'blocked' => \__( 'Blocked before reaching the collector: HTTP status %d came from the web server, a firewall or a CDN, not from the collector. Allow POST requests to the collector URL above - for example an nginx location for exactly that path, or an exception in the firewall / security plugin.', '0-day-analytics' ), 'network' => \__( 'The request did not complete: a browser extension blocked it, the network failed, or the collector URL is on another domain than this admin.', '0-day-analytics' ), 'testing' => \__( 'Testing…', '0-day-analytics' ), ); ?>