函数文档

wp_untrash_post_set_previous_status()

💡 云策文档标注

概述

wp_untrash_post_set_previous_status() 是一个 WordPress 过滤器回调函数,用于在恢复文章时将其状态设置为之前的 status。它可作为 wp_untrash_post_status 过滤器的回调。

关键要点

  • 这是一个过滤器回调函数,用于设置恢复文章的状态为之前的 status。
  • 函数接受三个参数:$new_status(新状态)、$post_id(文章 ID)和 $previous_status(之前的 status)。
  • 返回值为字符串,表示文章的新状态。
  • 函数内部直接返回 $previous_status,确保恢复后状态与之前一致。
  • 该函数从 WordPress 5.6.0 版本开始引入。

代码示例

function wp_untrash_post_set_previous_status( $new_status, $post_id, $previous_status ) {
	return $previous_status;
}

📄 原文内容

Filters callback which sets the status of an untrashed post to its previous status.

Description

This can be used as a callback on the wp_untrash_post_status filter.

Parameters

$new_statusstringrequired
The new status of the post being restored.
$post_idintrequired
The ID of the post being restored.
$previous_statusstringrequired
The status of the post at the point where it was trashed.

Return

string The new status of the post.

Source

function wp_untrash_post_set_previous_status( $new_status, $post_id, $previous_status ) {
	return $previous_status;
}

Changelog

Version Description
5.6.0 Introduced.