Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Navigation Post Edit Link #4657

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/wp-includes/link-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,9 @@ function get_edit_post_link( $post = 0, $context = 'display' ) {
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 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could add an annotation in the get_edit_post_link() PHP doc, e.g., something like

* @since 6.3.0 Adds custom link for wp_navigation post types.

$id = $post->ID;
$link = admin_url( sprintf( $post_type_object->_edit_link, $id ) );
getdave marked this conversation as resolved.
Show resolved Hide resolved
} elseif ( $post_type_object->_edit_link ) {
$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
}
Expand Down
41 changes: 31 additions & 10 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@ function create_initial_post_types() {
)
);

$navigation_post_edit_link = 'site-editor.php?' . build_query(
array(
'postId' => '%s',
'postType' => 'wp_navigation',
'canvas' => 'edit',
)
);

register_post_type(
'wp_navigation',
array(
Expand All @@ -512,6 +520,9 @@ function create_initial_post_types() {
'filter_items_list' => __( 'Filter Navigation Menu list' ),
'items_list_navigation' => __( 'Navigation Menus list navigation' ),
'items_list' => __( 'Navigation Menus list' ),
/* internal use only. don't use this when registering your own post type. */
'_edit_link' => $navigation_post_edit_link,

),
'description' => __( 'Navigation menus that can be inserted into your site.' ),
'public' => false,
Expand Down Expand Up @@ -551,7 +562,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Published', 'post status' ),
'public' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of published posts. */
'label_count' => _n_noop(
'Published <span class="count">(%s)</span>',
Expand All @@ -565,7 +577,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Scheduled', 'post status' ),
'protected' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of scheduled posts. */
'label_count' => _n_noop(
'Scheduled <span class="count">(%s)</span>',
Expand All @@ -579,7 +592,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Draft', 'post status' ),
'protected' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of draft posts. */
'label_count' => _n_noop(
'Draft <span class="count">(%s)</span>',
Expand All @@ -594,7 +608,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Pending', 'post status' ),
'protected' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
getdave marked this conversation as resolved.
Show resolved Hide resolved
/* translators: %s: Number of pending posts. */
'label_count' => _n_noop(
'Pending <span class="count">(%s)</span>',
Expand All @@ -609,7 +624,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Private', 'post status' ),
'private' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of private posts. */
'label_count' => _n_noop(
'Private <span class="count">(%s)</span>',
Expand All @@ -623,7 +639,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Trash', 'post status' ),
'internal' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of trashed posts. */
'label_count' => _n_noop(
'Trash <span class="count">(%s)</span>',
Expand Down Expand Up @@ -658,7 +675,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Pending', 'request status' ),
'internal' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of pending requests. */
'label_count' => _n_noop(
'Pending <span class="count">(%s)</span>',
Expand All @@ -673,7 +691,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Confirmed', 'request status' ),
'internal' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of confirmed requests. */
'label_count' => _n_noop(
'Confirmed <span class="count">(%s)</span>',
Expand All @@ -688,7 +707,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Failed', 'request status' ),
'internal' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of failed requests. */
'label_count' => _n_noop(
'Failed <span class="count">(%s)</span>',
Expand All @@ -703,7 +723,8 @@ function create_initial_post_types() {
array(
'label' => _x( 'Completed', 'request status' ),
'internal' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /*
internal use only. */
/* translators: %s: Number of completed requests. */
'label_count' => _n_noop(
'Completed <span class="count">(%s)</span>',
Expand Down