PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.11
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.11
1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 All 35 releases
← All changes | includes/notes/rest.php +24 -1 1.1.91.1.11 View file →
@@ -598,11 +598,34 @@
598 598 return rest_ensure_response(
599 599 array(
600 600 'noteId' => (int) $post->ID,
601 601 'postId' => (int) $new_post_id,
602 - 'editUrl' => (string) get_edit_post_link( $new_post_id, 'raw' ),
602 + 'editUrl' => openstation_notes_draft_edit_url( (int) $new_post_id ),
603 603 )
604 604 );
605 +}
606 +
607 +/**
608 + * The admin edit URL for the draft a note became.
609 + *
610 + * `get_edit_post_link()` is the canonical answer, and it is filterable:
611 + * a host can point it off-site (WordPress.com routes post edit links to
612 + * its own editor) or a capability filter can blank it, and the client
613 + * opens the URL inside a window that can only ever show THIS site's
614 + * wp-admin. So this always answers with the on-site `post.php` URL the
615 + * post type registers, whatever a filter made of the pretty one.
616 + *
617 + * @param int $post_id The draft post id.
618 + * @return string Absolute admin URL, or '' when the post is gone.
619 + */
620 +function openstation_notes_draft_edit_url( $post_id ) {
621 + $draft = get_post( $post_id );
622 + if ( ! $draft instanceof WP_Post ) {
623 + return '';
624 + }
625 + $type_object = get_post_type_object( $draft->post_type );
626 + $edit_link = $type_object && ! empty( $type_object->_edit_link ) ? $type_object->_edit_link : 'post.php?post=%d';
627 + return admin_url( sprintf( $edit_link, $draft->ID ) . '&action=edit' );
605 628 }
606 629
607 630 /**
608 631 * Whether the current user's desktop would show any pinned notes.