Changeset 59794
- Timestamp:
- 02/10/2025 02:38:35 AM (12 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/site-editor.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/site-editor.php
r59316 r59794 20 20 } 21 21 22 $is_template_part = isset( $_GET['postType'] ) && 'wp_template_part' === sanitize_key( $_GET['postType'] ); 23 $is_template_part_path = isset( $_GET['path'] ) && 'wp_template_partall' === sanitize_key( $_GET['path'] ); 24 $is_template_part_editor = $is_template_part || $is_template_part_path; 25 $is_patterns = isset( $_GET['postType'] ) && 'wp_block' === sanitize_key( $_GET['postType'] ); 26 $is_patterns_path = isset( $_GET['path'] ) && 'patterns' === sanitize_key( $_GET['path'] ); 27 $is_patterns_editor = $is_patterns || $is_patterns_path; 28 29 if ( ! wp_is_block_theme() ) { 30 if ( ! current_theme_supports( 'block-template-parts' ) && $is_template_part_editor ) { 31 wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) ); 32 } elseif ( ! $is_patterns_editor && ! $is_template_part_editor ) { 33 wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) ); 34 } 22 /** 23 * Maps old site editor urls to the new updated ones. 24 * 25 * @since 6.8.0 26 * @access private 27 * 28 * @global string $pagenow The filename of the current screen. 29 * 30 * @return string|false The new URL to redirect to, or false if no redirection is needed. 31 */ 32 function _wp_get_site_editor_redirection_url() { 33 global $pagenow; 34 if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || ! $_SERVER['QUERY_STRING'] ) { 35 return false; 36 } 37 38 // The following redirects are for the new permalinks in the site editor. 39 if ( isset( $_REQUEST['postType'] ) && 'wp_navigation' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { 40 return add_query_arg( array( 'p' => '/wp_navigation/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); 41 } 42 43 if ( isset( $_REQUEST['postType'] ) && 'wp_navigation' === $_REQUEST['postType'] && empty( $_REQUEST['postId'] ) ) { 44 return add_query_arg( array( 'p' => '/navigation' ), remove_query_arg( 'postType' ) ); 45 } 46 47 if ( isset( $_REQUEST['path'] ) && '/wp_global_styles' === $_REQUEST['path'] ) { 48 return add_query_arg( array( 'p' => '/styles' ), remove_query_arg( 'path' ) ); 49 } 50 51 if ( isset( $_REQUEST['postType'] ) && 'page' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) { 52 return add_query_arg( array( 'p' => '/page' ), remove_query_arg( 'postType' ) ); 53 } 54 55 if ( isset( $_REQUEST['postType'] ) && 'page' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { 56 return add_query_arg( array( 'p' => '/page/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); 57 } 58 59 if ( isset( $_REQUEST['postType'] ) && 'wp_template' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) { 60 return add_query_arg( array( 'p' => '/template' ), remove_query_arg( 'postType' ) ); 61 } 62 63 if ( isset( $_REQUEST['postType'] ) && 'wp_template' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { 64 return add_query_arg( array( 'p' => '/wp_template/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); 65 } 66 67 if ( isset( $_REQUEST['postType'] ) && 'wp_block' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) { 68 return add_query_arg( array( 'p' => '/pattern' ), remove_query_arg( 'postType' ) ); 69 } 70 71 if ( isset( $_REQUEST['postType'] ) && 'wp_block' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { 72 return add_query_arg( array( 'p' => '/wp_block/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); 73 } 74 75 if ( isset( $_REQUEST['postType'] ) && 'wp_template_part' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) { 76 return add_query_arg( array( 'p' => '/pattern' ) ); 77 } 78 79 if ( isset( $_REQUEST['postType'] ) && 'wp_template_part' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { 80 return add_query_arg( array( 'p' => '/wp_template_part/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); 81 } 82 83 // The following redirects are for backward compatibility with the old site editor URLs. 84 if ( isset( $_REQUEST['path'] ) && '/wp_template_part/all' === $_REQUEST['path'] ) { 85 return add_query_arg( 86 array( 87 'p' => '/pattern', 88 'postType' => 'wp_template_part', 89 ), 90 remove_query_arg( 'path' ) 91 ); 92 } 93 94 if ( isset( $_REQUEST['path'] ) && '/page' === $_REQUEST['path'] ) { 95 return add_query_arg( array( 'p' => '/page' ), remove_query_arg( 'path' ) ); 96 } 97 98 if ( isset( $_REQUEST['path'] ) && '/wp_template' === $_REQUEST['path'] ) { 99 return add_query_arg( array( 'p' => '/template' ), remove_query_arg( 'path' ) ); 100 } 101 102 if ( isset( $_REQUEST['path'] ) && '/patterns' === $_REQUEST['path'] ) { 103 return add_query_arg( array( 'p' => '/pattern' ), remove_query_arg( 'path' ) ); 104 } 105 106 if ( isset( $_REQUEST['path'] ) && '/navigation' === $_REQUEST['path'] ) { 107 return add_query_arg( array( 'p' => '/navigation' ), remove_query_arg( 'path' ) ); 108 } 109 110 return add_query_arg( array( 'p' => '/' ) ); 111 } 112 113 // Redirect to the site editor to the new URLs if needed. 114 $redirection = _wp_get_site_editor_redirection_url(); 115 if ( false !== $redirection ) { 116 wp_safe_redirect( $redirection ); 117 exit; 35 118 } 36 119
Note: See TracChangeset
for help on using the changeset viewer.