Skip to content

Commit

Permalink
Site Editor: Remove unused PHP code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Nov 30, 2021
1 parent e13dc1b commit 4d366f2
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 178 deletions.
25 changes: 0 additions & 25 deletions lib/full-site-editing/template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,28 +266,3 @@ function gutenberg_resolve_template_for_new_post( $wp_query ) {
$wp_query->set( 'post_status', 'auto-draft' );
}
}

/**
* Redirect the edit links for templates to the site editor.
*
* @param string $link The original link.
* @param int $post_id The custom post id.
*/
function gutenberg_get_edit_template_link( $link, $post_id ) {
$post = get_post( $post_id );

if ( ! in_array( $post->post_type, array( 'wp_template', 'wp_template_part' ), true ) ) {
return $link;
}

$template = _build_block_template_result_from_post( $post );

if ( is_wp_error( $template ) ) {
return $link;
}

$edit_link = 'themes.php?page=gutenberg-edit-site&postId=%1$s&postType=%2$s';

return admin_url( sprintf( $edit_link, urlencode( $template->id ), $template->type ) );
}
add_filter( 'get_edit_post_link', 'gutenberg_get_edit_template_link', 10, 2 );
30 changes: 0 additions & 30 deletions lib/full-site-editing/template-parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,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.
Expand Down
93 changes: 0 additions & 93 deletions lib/full-site-editing/templates-utils.php

This file was deleted.

29 changes: 0 additions & 29 deletions lib/full-site-editing/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,35 +118,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.
Expand Down
1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,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/templates.php';
require __DIR__ . '/full-site-editing/template-parts.php';
Expand Down

0 comments on commit 4d366f2

Please sign in to comment.