wp_add_trashed_suffix_to_post_name_for_post() - WordPress 函数参考中文文档

返回介绍

wp_add_trashed_suffix_to_post_name_for_post()

发布于 2017-09-11 字数2145 浏览 723 评论 0

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.

wp_add_trashed_suffix_to_post_name_for_post( WP_Post $post )

Adds a trashed suffix for a given post.


描述

Store its desired (i.e. current) slug so it can try to reclaim it if the post is untrashed.

For internal use.


参数

$post

(WP_Post)
(Required)
The post.


返回值

(string) New slug for the post.


源代码

File: wp-includes/post.php

function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
	global $wpdb;

	$post = get_post( $post );

	if ( '__trashed' === substr( $post->post_name, -9 ) ) {
		return $post->post_name;
	}
	add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
	$post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
	$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
	clean_post_cache( $post->ID );
	return $post_name;
}

更新日志

Version 描述
4.5.0 Introduced.

相关函数

Uses

  • wp-includes/post.php:
    clean_post_cache()
  • wp-includes/post.php:
    _truncate_post_slug()
  • wp-includes/post.php:
    add_post_meta()
  • wp-includes/post.php:
    get_post()
  • wp-includes/wp-db.php:
    wpdb::update()

Used By

  • wp-includes/post.php:
    wp_add_trashed_suffix_to_post_name_for_trashed_posts()
  • wp-includes/post.php:
    wp_insert_post()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!