wp_add_trashed_suffix_to_post_name_for_post

The timeline below displays how wordpress function wp_add_trashed_suffix_to_post_name_for_post has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * 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.
 *
 * @since 4.5.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param WP_Post $post The post.
 * @return string New slug for the post.
 */
function wp_add_trashed_suffix_to_post_name_for_post($post)
{
    global $wpdb;
    $post = get_post($post);
    if (str_ends_with($post->post_name, '__trashed')) {
        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;
}

WordPress Version: 6.2

/**
 * 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.
 *
 * @since 4.5.0
 * @access private
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param WP_Post $post The post.
 * @return string New slug for the post.
 */
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;
}

WordPress Version: 4.6

/**
 * 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.
 *
 * @since 4.5.0
 * @access private
 *
 * @param WP_Post $post The post.
 * @return string New slug for the post.
 */
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;
}

WordPress Version: 4.5

/**
 * 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.
 *
 * @since 4.5.0
 * @access private
 *
 * @param WP_Post $post The post.
 */
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;
}