if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . '<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>', 403 ); }
/** * Maps old site editor urls to the new updated ones. * * @since 6.8.0 * @access private * * @global string $pagenow The filename of the current screen. * * @return string|false The new URL to redirect to, or false if no redirection is needed. */ function _wp_get_site_editor_redirection_url() { global $pagenow; if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || empty( $_SERVER['QUERY_STRING'] ) ) { return false; }
// The following redirects are for the new permalinks in the site editor. if ( isset( $_REQUEST['postType'] ) && 'wp_navigation' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) { return add_query_arg( array( 'p' => '/wp_navigation/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) ); }
// The following redirects are for backward compatibility with the old site editor URLs. if ( isset( $_REQUEST['path'] ) && '/wp_template_part/all' === $_REQUEST['path'] ) { return add_query_arg( array( 'p' => '/pattern', 'postType' => 'wp_template_part', ), remove_query_arg( 'path' ) ); }
// Redirect to the site editor to the new URLs if needed. $redirection = _wp_get_site_editor_redirection_url(); if ( false !== $redirection ) { wp_safe_redirect( $redirection ); exit; }
// Used in the HTML title tag. $title = _x( 'Editor', 'site editor title tag' ); $parent_file = 'themes.php';
// Flag that we're loading the block editor. $current_screen = get_current_screen(); $current_screen->is_block_editor( true );
// Default to is-fullscreen-mode to avoid jumps in the UI. add_filter( 'admin_body_class', static function ( $classes ) { return "$classes is-fullscreen-mode"; } );