diff --git a/lib/compat/wordpress-5.9/template-parts.php b/lib/compat/wordpress-5.9/template-parts.php index e25a1f80014cb..1d84d00afbe48 100644 --- a/lib/compat/wordpress-5.9/template-parts.php +++ b/lib/compat/wordpress-5.9/template-parts.php @@ -100,36 +100,6 @@ function gutenberg_register_wp_template_part_area_taxonomy() { } add_action( 'init', 'gutenberg_register_wp_template_part_area_taxonomy' ); - /** - * Fixes the label of the 'wp_template_part' admin menu entry. - */ - function gutenberg_fix_template_part_admin_menu_entry() { - if ( ! gutenberg_supports_block_templates() ) { - return; - } - - global $submenu; - if ( ! isset( $submenu['themes.php'] ) ) { - return; - } - $post_type = get_post_type_object( 'wp_template_part' ); - if ( ! $post_type ) { - return; - } - foreach ( $submenu['themes.php'] as $key => $submenu_entry ) { - if ( $post_type->labels->all_items === $submenu['themes.php'][ $key ][0] ) { - $submenu['themes.php'][ $key ][0] = $post_type->labels->menu_name; // phpcs:ignore WordPress.WP.GlobalVariablesOverride - break; - } - } - } - add_action( 'admin_menu', 'gutenberg_fix_template_part_admin_menu_entry' ); - - // Customize the `wp_template` admin list. - add_filter( 'manage_wp_template_part_posts_columns', 'gutenberg_templates_lists_custom_columns' ); - add_action( 'manage_wp_template_part_posts_custom_column', 'gutenberg_render_templates_lists_custom_column', 10, 2 ); - add_filter( 'views_edit-wp_template_part', 'gutenberg_filter_templates_edit_views' ); - /** * Sets a custom slug when creating auto-draft template parts. * This is only needed for auto-drafts created by the regular WP editor. diff --git a/lib/compat/wordpress-5.9/templates.php b/lib/compat/wordpress-5.9/templates.php index 819e6474abfd5..93b8c40a8c0cf 100644 --- a/lib/compat/wordpress-5.9/templates.php +++ b/lib/compat/wordpress-5.9/templates.php @@ -127,35 +127,6 @@ function gutenberg_grant_template_caps( array $allcaps ) { } add_filter( 'user_has_cap', 'gutenberg_grant_template_caps' ); - /** - * Fixes the label of the 'wp_template' admin menu entry. - */ - function gutenberg_fix_template_admin_menu_entry() { - if ( ! gutenberg_supports_block_templates() ) { - return; - } - global $submenu; - if ( ! isset( $submenu['themes.php'] ) ) { - return; - } - $post_type = get_post_type_object( 'wp_template' ); - if ( ! $post_type ) { - return; - } - foreach ( $submenu['themes.php'] as $key => $submenu_entry ) { - if ( $post_type->labels->all_items === $submenu['themes.php'][ $key ][0] ) { - $submenu['themes.php'][ $key ][0] = $post_type->labels->menu_name; // phpcs:ignore WordPress.WP.GlobalVariablesOverride - break; - } - } - } - add_action( 'admin_menu', 'gutenberg_fix_template_admin_menu_entry' ); - - // Customize the `wp_template` admin list. - add_filter( 'manage_wp_template_posts_columns', 'gutenberg_templates_lists_custom_columns' ); - add_action( 'manage_wp_template_posts_custom_column', 'gutenberg_render_templates_lists_custom_column', 10, 2 ); - add_filter( 'views_edit-wp_template', 'gutenberg_filter_templates_edit_views' ); - /** * Sets a custom slug when creating auto-draft templates. * This is only needed for auto-drafts created by the regular WP editor. diff --git a/lib/full-site-editing/templates-utils.php b/lib/full-site-editing/templates-utils.php deleted file mode 100644 index 9eeb046a7c2e5..0000000000000 --- a/lib/full-site-editing/templates-utils.php +++ /dev/null @@ -1,93 +0,0 @@ -slug ) ); - } - echo implode( '
', $themes ); - return; - } -} - -/** - * Adds the auto-draft view to the templates and template parts admin lists. - * - * @param array $views The edit views to filter. - */ -function gutenberg_filter_templates_edit_views( $views ) { - $post_type = get_current_screen()->post_type; - $url = add_query_arg( - array( - 'post_type' => $post_type, - 'post_status' => 'auto-draft', - ), - 'edit.php' - ); - $is_auto_draft_view = isset( $_REQUEST['post_status'] ) && 'auto-draft' === $_REQUEST['post_status']; - $class_html = $is_auto_draft_view ? ' class="current"' : ''; - $aria_current = $is_auto_draft_view ? ' aria-current="page"' : ''; - $post_count = wp_count_posts( $post_type, 'readable' ); - $label = sprintf( - // The auto-draft status doesn't have localized labels. - translate_nooped_plural( - /* translators: %s: Number of auto-draft posts. */ - _nx_noop( - 'Auto-Draft (%s)', - 'Auto-Drafts (%s)', - 'Post status', - 'gutenberg' - ), - $post_count->{'auto-draft'} - ), - number_format_i18n( $post_count->{'auto-draft'} ) - ); - - $auto_draft_view = sprintf( - '%s', - esc_url( $url ), - $class_html, - $aria_current, - $label - ); - - array_splice( $views, 1, 0, array( 'auto-draft' => $auto_draft_view ) ); - - return $views; -} diff --git a/lib/load.php b/lib/load.php index f49a7a1c27709..7a781ebe53560 100644 --- a/lib/load.php +++ b/lib/load.php @@ -109,7 +109,6 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/full-site-editing/full-site-editing.php'; require __DIR__ . '/full-site-editing/block-templates.php'; require __DIR__ . '/full-site-editing/default-template-types.php'; -require __DIR__ . '/full-site-editing/templates-utils.php'; require __DIR__ . '/full-site-editing/page-templates.php'; require __DIR__ . '/full-site-editing/template-loader.php'; require __DIR__ . '/full-site-editing/edit-site-page.php';