Automattic\WooCommerce\Internal\Admin
CustomerEffortScoreTracks::maybe_clear_ces_tracks_queue
Maybe clear the CES tracks queue, executed on every page load. If the clear option is set it clears the queue. In practice, this executes a page load after the queued CES tracks are displayed on the client, which sets the clear option.
Method of the class: CustomerEffortScoreTracks{}
No Hooks.
Returns
null. Nothing (null).
Usage
$CustomerEffortScoreTracks = new CustomerEffortScoreTracks(); $CustomerEffortScoreTracks->maybe_clear_ces_tracks_queue();
CustomerEffortScoreTracks::maybe_clear_ces_tracks_queue() CustomerEffortScoreTracks::maybe clear ces tracks queue code WC 10.8.1
public function maybe_clear_ces_tracks_queue() {
$clear_ces_tracks_queue_for_page = get_option(
self::CLEAR_CES_TRACKS_QUEUE_FOR_PAGE_OPTION_NAME,
false
);
if ( ! $clear_ces_tracks_queue_for_page ) {
return;
}
$queue = get_option(
self::CES_TRACKS_QUEUE_OPTION_NAME,
array()
);
$queue = is_array( $queue ) ? $queue : array();
$remaining_items = array_filter(
$queue,
function ( $item ) use ( $clear_ces_tracks_queue_for_page ) {
return $clear_ces_tracks_queue_for_page['pagenow'] !== $item['pagenow']
|| $clear_ces_tracks_queue_for_page['adminpage'] !== $item['adminpage'];
}
);
update_option(
self::CES_TRACKS_QUEUE_OPTION_NAME,
array_values( $remaining_items )
);
update_option( self::CLEAR_CES_TRACKS_QUEUE_FOR_PAGE_OPTION_NAME, false );
}