get_edit_post_link example

<?php echo esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ); ?></strong></span> <span class="media-list-subtitle"><?php echo wp_basename( $file ); ?></span> </div> </div> <div class="attachment-tools"> <span class="media-item-copy-container copy-to-clipboard-container edit-attachment"> <button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button> <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> </span> <?php                     if ( current_user_can( 'edit_post', $id ) ) {
                        echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '">' . _x( 'Edit', 'media item' ) . '</a>';
                    } else {
                        echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>';
                    }
                    ?> </div> </div> <?php             break;
        case 2:
            add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
            echo get_media_item(
                
wp_restore_post_revision( $revision->ID );

        // Restore the global $post as it was before.         $post = $backup_global_post;

        $redirect = add_query_arg(
            array(
                'message'  => 5,
                'revision' => $revision->ID,
            ),
            get_edit_post_link( $post->ID, 'url' )
        );
        break;
    case 'view':
    case 'edit':
    default:
        $revision = wp_get_post_revision( $revision_id );
        if ( ! $revision ) {
            break;
        }

        $post = get_post( $revision->post_parent );
        

        }

        $title      = _draft_or_post_title();
        $thumb      = wp_get_attachment_image( $attachment_id, array( 60, 60 ), true, array( 'alt' => '' ) );
        $link_start = '';
        $link_end   = '';

        if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
            $link_start = sprintf(
                '<a href="%s" aria-label="%s">',
                get_edit_post_link( $post->ID ),
                /* translators: %s: Attachment title. */
                esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' )$title ) )
            );
            $link_end = '</a>';
        }

        $class = $thumb ? ' class="has-media-icon"' : '';
        ?> <strong<?php echo $class; ?>> <?php             echo $link_start;

            
?> <p> <a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a> <?php if ( $preview_link ) { ?> <a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e( 'Preview' ); ?></a> <?php         }

        // Allow plugins to prevent some users overriding the post lock.         if ( $override ) {
            ?> <a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e( 'Take over' ); ?></a> <?php         }

        ?> </p> </div> <?php     } else {
        ?> <div class="post-taken-over"> <div class="post-locked-avatar"></div> <p class="wp-tab-first" tabindex="0"> <span class="currently-editing"></span><br /> <span class="locked-saving hidden"><img src="
<tr> <th scope="row"><?php _e( 'URL' ); ?></th> <td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td> </tr> <?php } ?> <tr> <th scope="row"><?php /* translators: Column name or table row header. */ _e( 'In response to' ); ?></th> <td> <?php         $post_id = $comment->comment_post_ID;
        if ( current_user_can( 'edit_post', $post_id ) ) {
            $post_link  = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
            $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
        } else {
            $post_link = esc_html( get_the_title( $post_id ) );
        }
        echo $post_link;

        if ( $comment->comment_parent ) {
            $parent      = get_comment( $comment->comment_parent );
            $parent_link = esc_url( get_comment_link( $parent ) );
            $name        = get_comment_author( $parent );
            printf(
                
esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ),
            __( 'Undo' )
        );
    }

    if ( 'untrashed' === $message && isset( $_REQUEST['ids'] ) ) {
        $ids = explode( ',', $_REQUEST['ids'] );

        if ( 1 === count( $ids ) && current_user_can( 'edit_post', $ids[0] ) ) {
            $messages[] = sprintf(
                '<a href="%1$s">%2$s</a>',
                esc_url( get_edit_post_link( $ids[0] ) ),
                esc_html( get_post_type_object( get_post_type( $ids[0] ) )->labels->edit_item )
            );
        }
    }
}

if ( $messages ) {
    printf(
        '<div id="message" class="updated notice is-dismissible"><p>%s</p></div>',
        implode( ' ', $messages )
    );
}


        if ( isset( $this->pending_count[ $post->ID ] ) ) {
            $pending_comments = $this->pending_count[ $post->ID ];
        } else {
            $_pending_count_temp              = get_pending_comments_num( array( $post->ID ) );
            $pending_comments                 = $_pending_count_temp[ $post->ID ];
            $this->pending_count[ $post->ID ] = $pending_comments;
        }

        if ( current_user_can( 'edit_post', $post->ID ) ) {
            $post_link  = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
            $post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
        } else {
            $post_link = esc_html( get_the_title( $post->ID ) );
        }

        echo '<div class="response-links">';

        if ( 'attachment' === $post->post_type ) {
            $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true );
            if ( $thumb ) {
                echo $thumb;
            }

        }
    } else {
        $current_object = $wp_the_query->get_queried_object();

        if ( empty( $current_object ) ) {
            return;
        }

        if ( ! empty( $current_object->post_type ) ) {
            $post_type_object = get_post_type_object( $current_object->post_type );
            $edit_post_link   = get_edit_post_link( $current_object->ID );
            if ( $post_type_object
                && $edit_post_link
                && current_user_can( 'edit_post', $current_object->ID )
                && $post_type_object->show_in_admin_bar ) {
                $wp_admin_bar->add_node(
                    array(
                        'id'    => 'edit',
                        'title' => $post_type_object->labels->edit_item,
                        'href'  => $edit_post_link,
                    )
                );
            }
$author_name            = $author->display_name ? $author->display_name : $author->nickname;
        $response['authorName'] = html_entity_decode( $author_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
        $response['authorLink'] = get_edit_user_link( $author->ID );
    } else {
        $response['authorName'] = __( '(no author)' );
    }

    if ( $attachment->post_parent ) {
        $post_parent = get_post( $attachment->post_parent );
        if ( $post_parent ) {
            $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(no title)' );
            $response['uploadedToLink']  = get_edit_post_link( $attachment->post_parent, 'raw' );
        }
    }

    $attached_file = get_attached_file( $attachment->ID );

    if ( isset( $meta['filesize'] ) ) {
        $bytes = $meta['filesize'];
    } elseif ( file_exists( $attached_file ) ) {
        $bytes = wp_filesize( $attached_file );
    } else {
        $bytes = '';
    }
return false;
    }

    /* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */
    $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
    /* translators: %s: Revision date. */
    $autosavef = __( '%s [Autosave]' );
    /* translators: %s: Revision date. */
    $currentf = __( '%s [Current Revision]' );

    $date      = date_i18n( $datefstrtotime( $revision->post_modified ) );
    $edit_link = get_edit_post_link( $revision->ID );
    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
        $date = "<a href='$edit_link'>$date</a>";
    }

    if ( ! wp_is_post_revision( $revision ) ) {
        $date = sprintf( $currentf$date );
    } elseif ( wp_is_post_autosave( $revision ) ) {
        $date = sprintf( $autosavef$date );
    }

    return $date;
}
date_i18n( $time_formatstrtotime( current_time( 'mysql' ) ) )
            );
        }

        if ( ! empty( $args['args']['revisions_count'] ) ) :
            ?> <div class="misc-pub-section misc-pub-revisions"> <?php                 /* translators: Post revisions heading. %s: The number of available revisions. */
                printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
                ?> <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"> <?php                     /* translators: Hidden accessibility text. */
                    _e( 'Browse revisions' );
                    ?> </span></a> </div> <?php         endif;

        if ( $can_publish ) : // Contributors don't get to choose the date of publish.             ?>
wp_link_pages(
            array(
                'before'   => '<nav class="page-links" aria-label="' . esc_attr__( 'Page', 'twentytwentyone' ) . '">',
                'after'    => '</nav>',
                /* translators: %: Page number. */
                'pagelink' => esc_html__( 'Page %', 'twentytwentyone' ),
            )
        );
        ?> </div><!-- .entry-content --> <?php if ( get_edit_post_link() ) : ?> <footer class="entry-footer default-max-width"> <?php             edit_post_link(
                sprintf(
                    /* translators: %s: Post title. Only visible to screen readers. */
                    esc_html__( 'Edit %s', 'twentytwentyone' ),
                    '<span class="screen-reader-text">' . get_the_title() . '</span>'
                ),
                '<span class="edit-link">',
                '</span>'
            );
            
    'enableCustomFields'   => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
);

// Add additional back-compat patterns registered by `current_screen` et al. $editor_settings['__experimentalAdditionalBlockPatterns']          = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );

$autosave = wp_get_post_autosave( $post->ID );
if ( $autosave ) {
    if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
        $editor_settings['autosave'] = array(
            'editLink' => get_edit_post_link( $autosave->ID ),
        );
    } else {
        wp_delete_post_revision( $autosave->ID );
    }
}

if ( ! empty( $post_type_object->template ) ) {
    $editor_settings['template']     = $post_type_object->template;
    $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
}


function wp_get_post_revisions_url( $post = 0 ) {
    $post = get_post( $post );

    if ( ! $post instanceof WP_Post ) {
        return null;
    }

    // If the post is a revision, return early.     if ( 'revision' === $post->post_type ) {
        return get_edit_post_link( $post );
    }

    if ( ! wp_revisions_enabled( $post ) ) {
        return null;
    }

    $revisions = wp_get_latest_revision_id_and_total_count( $post->ID );

    if ( is_wp_error( $revisions ) || 0 === $revisions['count'] ) {
        return null;
    }

    

function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' ) {
    $post = get_post( $post );

    if ( ! $post ) {
        return;
    }

    $url = get_edit_post_link( $post->ID );

    if ( ! $url ) {
        return;
    }

    if ( null === $text ) {
        $text = __( 'Edit This' );
    }

    $link = '<a class="' . esc_attr( $css_class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>';

    
Home | Imprint | This part of the site doesn't use cookies.