unset( $_COOKIE['tk_ai'] ); wc_admin_record_tracks_event( $event_name, $params ); if ( isset( $anon_id ) ) { setcookie( 'tk_ai', $anon_id ); } } /** * Get screen name. * * @return string The screen name. */ public static function get_screen_name() { $screen_name = ''; if ( isset( $_SERVER['HTTP_REFERER'] ) ) { parse_str( wp_parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_QUERY ), $queries ); // phpcs:ignore sanitization ok. } if ( isset( $queries ) ) { $page = isset( $queries['page'] ) ? $queries['page'] : null; $path = isset( $queries['path'] ) ? $queries['path'] : null; $post_type = isset( $queries['post_type'] ) ? $queries['post_type'] : null; $post = isset( $queries['post'] ) ? get_post_type( $queries['post'] ) : null; } if ( isset( $page ) ) { $current_page = 'wc-admin' === $page ? 'home_screen' : $page; $screen_name = isset( $path ) ? substr( str_replace( '/', '_', $path ), 1 ) : $current_page; } elseif ( isset( $post_type ) ) { $screen_name = $post_type; } elseif ( isset( $post ) ) { $screen_name = $post; } return $screen_name; } /** * Loads the data store. * * If the "admin-note" data store is unavailable, attempts to load it * will result in an exception. * This method catches that exception and throws a custom one instead. * * @return \WC_Data_Store The "admin-note" data store. * @throws NotesUnavailableException Throws exception if data store loading fails. */ public static function load_data_store() { try { return \WC_Data_Store::load( 'admin-note' ); } catch ( \Exception $e ) { throw new NotesUnavailableException( 'woocommerce_admin_notes_unavailable', __( 'Notes are unavailable because the "admin-note" data store cannot be loaded.', 'woocommerce' ) ); } } }