From f3f4f7dd96762b2d56d378add879080beadac986 Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Tue, 27 Jun 2023 06:02:22 +0000 Subject: [PATCH] Editor: fix post edit navigation link. Adds a custom link for navigation post types. Props get_dave, spacedmonkey, ramonopoly. Fixes #58589. Built from https://develop.svn.wordpress.org/trunk@56053 git-svn-id: http://core.svn.wordpress.org/trunk@55565 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 4 ++++ wp-includes/post.php | 9 +++++++++ wp-includes/version.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index b59a30ad22..7fc1074470 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1438,6 +1438,8 @@ function get_preview_post_link( $post = null, $query_args = array(), $preview_li * pages, posts, attachments, revisions, global styles, templates, and template parts. * * @since 2.3.0 + * @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 '&'. @@ -1474,6 +1476,8 @@ 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 ) { + $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 ) ); } diff --git a/wp-includes/post.php b/wp-includes/post.php index abf94bcbe5..d6ab4db603 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -491,6 +491,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( @@ -517,6 +525,7 @@ function create_initial_post_types() { 'description' => __( 'Navigation menus that can be inserted into your site.' ), 'public' => false, '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ + '_edit_link' => $navigation_post_edit_link, /* internal use only. don't use this when registering your own post type. */ 'has_archive' => false, 'show_ui' => true, 'show_in_menu' => false, diff --git a/wp-includes/version.php b/wp-includes/version.php index ac27792db9..6b425e49c5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56052'; +$wp_version = '6.3-alpha-56053'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.