: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param string $feed Feed type. Possible values include 'rss2', 'atom'.
* @param string $taxonomy The taxonomy name.
$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );
* Retrieves the permalink for a tag feed.
* @param int|WP_Term|object $tag The ID or term object whose feed link will be retrieved.
* @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
* Default is the value of get_default_feed().
* @return string The feed permalink for the given tag.
function get_tag_feed_link( $tag, $feed = '' ) {
return get_term_feed_link( $tag, 'post_tag', $feed );
* Retrieves the edit link for a tag.
* @param int|WP_Term|object $tag The ID or term object whose edit link will be retrieved.
* @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'.
* @return string The edit tag link URL for the given tag.
function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) {
* Filters the edit link for a tag (or term in another taxonomy).
* @param string $link The term edit link.
return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) );
* Displays or retrieves the edit link for a tag with formatting.
* @param string $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
* @param string $before Optional. Display before edit link. Default empty.
* @param string $after Optional. Display after edit link. Default empty.
* @param WP_Term $tag Optional. Term object. If null, the queried object will be inspected.
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
$link = edit_term_link( $link, '', '', $tag, false );
* Filters the anchor tag for the edit link for a tag (or term in another taxonomy).
* @param string $link The anchor tag for the edit link.
echo $before . apply_filters( 'edit_tag_link', $link ) . $after;
* Retrieves the URL for editing a given term.
* @since 4.5.0 The `$taxonomy` parameter was made optional.
* @param int|WP_Term|object $term The ID or term object whose edit link will be retrieved.
* @param string $taxonomy Optional. Taxonomy. Defaults to the taxonomy of the term identified
* @param string $object_type Optional. The object type. Used to highlight the proper post type
* menu on the linked page. Defaults to the first object_type associated
* @return string|null The edit term link URL for the given term, or null on failure.
function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) {
$term = get_term( $term, $taxonomy );
if ( ! $term || is_wp_error( $term ) ) {
$tax = get_taxonomy( $term->taxonomy );
$term_id = $term->term_id;
if ( ! $tax || ! current_user_can( 'edit_term', $term_id ) ) {
$args['post_type'] = $object_type;
} elseif ( ! empty( $tax->object_type ) ) {
$args['post_type'] = reset( $tax->object_type );
$location = add_query_arg( $args, admin_url( 'term.php' ) );
* Filters the edit link for a term.
* @param string $location The edit link.
* @param int $term_id Term ID.
* @param string $taxonomy Taxonomy name.
* @param string $object_type The object type.
return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
* Displays or retrieves the edit term link with formatting.
* @param string $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
* @param string $before Optional. Display before edit link. Default empty.
* @param string $after Optional. Display after edit link. Default empty.
* @param int|WP_Term|null $term Optional. Term ID or object. If null, the queried object will be inspected. Default null.
* @param bool $display Optional. Whether or not to echo the return. Default true.
* @return string|void HTML content.
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) {
if ( is_null( $term ) ) {
$term = get_queried_object();
$term = get_term( $term );
$tax = get_taxonomy( $term->taxonomy );
if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
$link = __( 'Edit This' );
$link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';
* Filters the anchor tag for the edit link of a term.
* @param string $link The anchor tag for the edit link.
* @param int $term_id Term ID.
$link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
* Retrieves the permalink for a search.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
* @param string $query Optional. The query string to use. If empty the current query is used. Default empty.
* @return string The search permalink.
function get_search_link( $query = '' ) {
$search = get_search_query( false );
$search = stripslashes( $query );
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty( $permastruct ) ) {
$link = home_url( '?s=' . urlencode( $search ) );
$search = urlencode( $search );
$search = str_replace( '%2F', '/', $search ); // %2F(/) is not valid within a URL, send it un-encoded.
$link = str_replace( '%search%', $search, $permastruct );
$link = home_url( user_trailingslashit( $link, 'search' ) );
* Filters the search permalink.
* @param string $link Search permalink.
* @param string $search The URL-encoded search term.
return apply_filters( 'search_link', $link, $search );
* Retrieves the permalink for the search results feed.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
* @param string $search_query Optional. Search query. Default empty.
* @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
* Default is the value of get_default_feed().
* @return string The search results feed permalink.
function get_search_feed_link( $search_query = '', $feed = '' ) {
$link = get_search_link( $search_query );
$feed = get_default_feed();
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty( $permastruct ) ) {
$link = add_query_arg( 'feed', $feed, $link );
$link = trailingslashit( $link );
* Filters the search feed link.
* @param string $link Search feed link.
* @param string $feed Feed type. Possible values include 'rss2', 'atom'.
* @param string $type The search type. One of 'posts' or 'comments'.
return apply_filters( 'search_feed_link', $link, $feed, 'posts' );
* Retrieves the permalink for the search results comments feed.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
* @param string $search_query Optional. Search query. Default empty.
* @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
* Default is the value of get_default_feed().
* @return string The comments feed search results permalink.
function get_search_comments_feed_link( $search_query = '', $feed = '' ) {
$feed = get_default_feed();
$link = get_search_feed_link( $search_query, $feed );
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty( $permastruct ) ) {
$link = add_query_arg( 'feed', 'comments-' . $feed, $link );
$link = add_query_arg( 'withcomments', 1, $link );
/** This filter is documented in wp-includes/link-template.php */
return apply_filters( 'search_feed_link', $link, $feed, 'comments' );
* Retrieves the permalink for a post type archive.
* @since 4.5.0 Support for posts was added.
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
* @param string $post_type Post type.
* @return string|false The post type archive permalink. False if the post type
* does not exist or does not have an archive.
function get_post_type_archive_link( $post_type ) {
$post_type_obj = get_post_type_object( $post_type );
if ( ! $post_type_obj ) {
if ( 'post' === $post_type ) {
$show_on_front = get_option( 'show_on_front' );
$page_for_posts = get_option( 'page_for_posts' );
if ( 'page' === $show_on_front && $page_for_posts ) {
$link = get_permalink( $page_for_posts );
/** This filter is documented in wp-includes/link-template.php */
return apply_filters( 'post_type_archive_link', $link, $post_type );
if ( ! $post_type_obj->has_archive ) {
if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
$struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
if ( $post_type_obj->rewrite['with_front'] ) {
$struct = $wp_rewrite->front . $struct;
$struct = $wp_rewrite->root . $struct;
$link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) );
$link = home_url( '?post_type=' . $post_type );
* Filters the post type archive permalink.
* @param string $link The post type archive permalink.
* @param string $post_type Post type name.
return apply_filters( 'post_type_archive_link', $link, $post_type );
* Retrieves the permalink for a post type archive feed.
* @param string $post_type Post type.
* @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
* Default is the value of get_default_feed().
* @return string|false The post type feed permalink. False if the post type
* does not exist or does not have an archive.
function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
$default_feed = get_default_feed();
$link = get_post_type_archive_link( $post_type );
$post_type_obj = get_post_type_object( $post_type );
if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
$link = trailingslashit( $link );
if ( $feed !== $default_feed ) {
$link = add_query_arg( 'feed', $feed, $link );
* Filters the post type archive feed link.
* @param string $link The post type archive feed link.
* @param string $feed Feed type. Possible values include 'rss2', 'atom'.
return apply_filters( 'post_type_archive_feed_link', $link, $feed );
* Retrieves the URL used for the post preview.
* Allows additional query args to be appended.
* @param int|WP_Post $post Optional. Post ID or `WP_Post` object. Defaults to global `$post`.
* @param array $query_args Optional. Array of additional query args to be appended to the link.
* @param string $preview_link Optional. Base preview link to be used if it should differ from the
* post permalink. Default empty.
* @return string|null URL used for the post preview, or null if the post does not exist.
function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) {
$post = get_post( $post );
$post_type_object = get_post_type_object( $post->post_type );
if ( is_post_type_viewable( $post_type_object ) ) {
$preview_link = set_url_scheme( get_permalink( $post ) );
$query_args['preview'] = 'true';
$preview_link = add_query_arg( $query_args, $preview_link );
* Filters the URL used for a post preview.
* @since 4.0.0 Added the `$post` parameter.
* @param string $preview_link URL used for the post preview.
* @param WP_Post $post Post object.
return apply_filters( 'preview_post_link', $preview_link, $post );
* Retrieves the edit post link for post.
* Can be used within the WordPress loop or outside of it. Can be used with
* pages, posts, attachments, revisions, global styles, templates, and template parts.
* @since 6.3.0 Adds custom link for wp_navigation post types.
* Adds custom links for wp_template_part and wp_template post types.
* @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
* @param string $context Optional. How to output the '&' character. Default '&'.
* @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.
function get_edit_post_link( $post = 0, $context = 'display' ) {
$post = get_post( $post );
if ( 'revision' === $post->post_type ) {
} elseif ( 'display' === $context ) {
$action = '&action=edit';
$action = '&action=edit';
$post_type_object = get_post_type_object( $post->post_type );
if ( ! $post_type_object ) {
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
if ( 'wp_template' === $post->post_type || 'wp_template_part' === $post->post_type ) {
$slug = urlencode( get_stylesheet() . '//' . $post->post_name );
$link = admin_url( sprintf( $post_type_object->_edit_link, $post->post_type, $slug ) );
} elseif ( 'wp_navigation' === $post->post_type ) {
$link = admin_url( sprintf( $post_type_object->_edit_link, (string) $post->ID ) );
} elseif ( $post_type_object->_edit_link ) {
$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
* Filters the post edit link.
* @param string $link The edit link.
* @param int $post_id Post ID.
* @param string $context The link context. If set to 'display' then ampersands
return apply_filters( 'get_edit_post_link', $link, $post->ID, $context );