Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_clear_modified_cache_on_transition_comment_status() WordPress Function

The clear_modified_cache_on_transition_comment_status() function clears the cache when the comment status is changed. This is useful for ensuring that the correct comments are displayed on the front-end of the site.

_clear_modified_cache_on_transition_comment_status( string $new_status, string $old_status ) #

Clears the lastcommentmodified cached value when a comment status is changed.


Description

Deletes the lastcommentmodified cache key when a comment enters or leaves ‘approved’ status.


Top ↑

Parameters

$new_status

(string)(Required)The new comment status.

$old_status

(string)(Required)The old comment status.


Top ↑

Source

File: wp-includes/comment.php

function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) {
	if ( 'approved' === $new_status || 'approved' === $old_status ) {
		$data = array();
		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
			$data[] = "lastcommentmodified:$timezone";
		}
		wp_cache_delete_multiple( $data, 'timeinfo' );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More