LLMS_Abstract_Processor::get_edit_post_link( int|WP_Post $id, string $context = 'display' )
Returns the edit post link for a post.
Description Description
This is based on the WordPress get_edit_post_link() function, but does not check if the user can edit the post or if the post’s post type has an edit link defined.
When the background processor is running, the current user ID is 0. This prevents current_user_can() from ever returning true and also causes the post’s post type edit link to be set to an empty string in WP_Post_Type::set_props().
This method is useful when the processor has completed and creates an admin notice that contains an edit post link.
Parameters Parameters
- $id
-
(int|WP_Post) (Optional) Post ID or post object. Default is the global
$post
. - $context
-
(string) (Optional) How to output the '&' character. Default '&'.
Default value: 'display'
Return Return
(string|null) The edit post link for the given post. Null if the post type does not exist or does not allow an editing UI.
Source Source
File: includes/abstracts/llms.abstract.processor.php
protected function get_edit_post_link( $id = 0, $context = 'display' ) { $post = get_post( $id ); if ( ! $post ) { return null; } $post_type_object = get_post_type_object( $post->post_type ); if ( ! $post_type_object ) { return null; } if ( 'revision' === $post->post_type ) { $action = ''; } elseif ( 'display' === $context ) { $action = '&action=edit'; } else { $action = '&action=edit'; } $link = admin_url( sprintf( 'post.php?post=%d%s', $post->ID, $action ) ); /** * Filters the post edit link. * * This is identical to the `get_edit_post_link` filter hook in {@see get_edit_post_link()}. * * @since 6.0.0 * * @param string $link The edit link. * @param int $post_id Post ID. * @param string $context The link context. If set to 'display' then ampersands are encoded. */ return apply_filters( 'get_edit_post_link', $link, $post->ID, $context ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |