post_preview(): string
- Since
- 2.7.0
- Source
wp-admin/includes/post.php:2083
Compatibility
- WordPress
- since 2.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
string- URL to redirect to show the preview.
Performance profile
How much work a call to post_preview() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 46–121
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 129.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_post()called directly - hookthird-party callbacks
apply_filters()one call below post_preview()
Further down the call graph this can also reach option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 72 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost post_preview() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
current_user_can() && wp_check_post_lock() && !is_wp_error() | 46–54 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 49–53 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() | 51–59 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 52–66 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() | 52–60 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && !is_wp_error() | 52–60 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 54–58 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 55–59 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 55–59 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 57–71 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() | 57–65 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() | 57–65 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
60 further outcomes, up to 121 instructions
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 58–72 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 58–72 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() | 58–66 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 60–64 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 60–64 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 61–65 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && !is_wp_error() | 63–87 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 63–77 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 63–77 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() | 63–71 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 64–78 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 66–86 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 66–70 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() | 68–92 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 69–99 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() | 69–93 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && !is_wp_error() | 69–93 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 69–83 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 71–91 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 72–92 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 72–92 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 74–104 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() | 74–98 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() | 74–98 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 75–92 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 75–105 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() | 75–105 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() | 75–99 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 77–97 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 77–97 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 78–91 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 78–98 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 80–97 | get_post(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 80–110 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() | 80–110 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() | 80–104 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 81–104 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 81–98 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 81–98 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() | 81–111 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 83–96 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 83–103 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 84–97 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 84–97 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 86–109 | get_post(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 86–103 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 86–103 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() | 86–116 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 87–110 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 87–110 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 87–104 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 89–102 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 89–102 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 90–103 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 92–115 | get_post(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 92–115 | get_post(), __(), wp_die(), current_user_can(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 92–109 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && !is_wp_error() && isset($value) && !empty($value) | 93–116 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 95–108 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), edit_post(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
!current_user_can() && !wp_check_post_lock() && is_wp_error() && isset($value) && !empty($value) | 98–121 | get_post(), __(), wp_die(), current_user_can(), __(), wp_die(), wp_check_post_lock(), get_current_user_id(), wp_create_post_autosave(), is_wp_error(), ->get_error_message(), wp_die(), wp_create_nonce(), sanitize_key(), get_preview_post_link() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 128 | 46–120 | 15 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 129 | 46–121 | 15 | |
| 8.4 | 129 | 46–121 | 15 | |
| 8.3 | 129 | 46–121 | 15 | |
| 8.2 | 129 | 46–121 | 15 | |
| 8.1 | 129 | 46–121 | 15 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 130 | 46–122 | 15 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 12
- get_post()Retrieves post data given a post ID or post object.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- __()Retrieves the translation of $text.
- current_user_can()Returns whether the current user has the specified capability.
- wp_check_post_lock()Determines whether the post is currently being edited by another user.
- get_current_user_id()Gets the current user's ID.
- edit_post()Updates an existing post with values provided in `$_POST`.
- wp_create_post_autosave()Creates autosave data for the specified post from `$_POST` data.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- sanitize_key()Sanitizes a string key.
- get_preview_post_link()Retrieves the URL used for the post preview.
Source code
function post_preview() { $post_id = (int) $_POST['post_ID']; $_POST['ID'] = $post_id; $post = get_post( $post_id ); if ( ! $post ) { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } if ( ! current_user_can( 'edit_post', $post->ID ) ) { wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); } $is_autosave = false; if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author && ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) ) { $saved_post_id = edit_post(); } else { $is_autosave = true; if ( isset( $_POST['post_status'] ) && 'auto-draft' === $_POST['post_status'] ) { $_POST['post_status'] = 'draft'; } $saved_post_id = wp_create_post_autosave( $post->ID ); } if ( is_wp_error( $saved_post_id ) ) { wp_die( $saved_post_id->get_error_message() ); } $query_args = array(); if ( $is_autosave && $saved_post_id ) { $query_args['preview_id'] = $post->ID; $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); if ( isset( $_POST['post_format'] ) ) { $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); } if ( isset( $_POST['_thumbnail_id'] ) ) { $query_args['_thumbnail_id'] = ( (int) $_POST['_thumbnail_id'] <= 0 ) ? '-1' : (int) $_POST['_thumbnail_id']; } } return get_preview_post_link( $post, $query_args );}Changelog
Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.