Skip to content

Commit

Permalink
Revert "Add: Modal to choose a start pattern on new templates." (#47918
Browse files Browse the repository at this point in the history
This reverts commit ad9624a.
  • Loading branch information
jorgefilipecosta authored Feb 9, 2023
1 parent a5f8802 commit b90cd5e
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 341 deletions.
16 changes: 16 additions & 0 deletions lib/compat/wordpress-6.1/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
* @package gutenberg
*/

/**
* Update `wp_template` and `wp_template-part` post types to use
* Gutenberg's REST controller.
*
* @param array $args Array of arguments for registering a post type.
* @param string $post_type Post type key.
*/
function gutenberg_update_templates_template_parts_rest_controller( $args, $post_type ) {
if ( in_array( $post_type, array( 'wp_template', 'wp_template-part' ), true ) ) {
$args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller';
}
return $args;
}
add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 );


/**
* Add the post type's `icon`(menu_icon) in the response.
* When we backport this change we will need to add the
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions lib/compat/wordpress-6.2/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
* @package gutenberg
*/

/**
* Update `wp_template` and `wp_template-part` post types to use
* Gutenberg's REST controller.
*
* @param array $args Array of arguments for registering a post type.
* @param string $post_type Post type key.
*/
function gutenberg_update_templates_template_parts_rest_controller( $args, $post_type ) {
if ( in_array( $post_type, array( 'wp_template', 'wp_template-part' ), true ) ) {
$args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_2';
}
return $args;
}
add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 );

/**
* Registers the block pattern categories REST API routes.
*/
Expand Down
1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-block-patterns-controller-6-2.php';
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-block-pattern-categories-controller.php';
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php';
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php';
require_once __DIR__ . '/compat/wordpress-6.2/rest-api.php';
require_once __DIR__ . '/compat/wordpress-6.2/block-patterns.php';
require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-global-styles-controller-6-2.php';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import {
DropdownMenu,
MenuGroup,
Expand Down Expand Up @@ -107,7 +109,19 @@ export default function NewTemplate( {
}
setIsCreatingTemplate( true );
try {
const { title, description, slug } = template;
const { title, description, slug, templatePrefix } = template;
let templateContent = template.content;
// Try to find fallback content from existing templates.
if ( ! templateContent ) {
const fallbackTemplate = await apiFetch( {
path: addQueryArgs( '/wp/v2/templates/lookup', {
slug,
is_custom: ! isWPSuggestion,
template_prefix: templatePrefix,
} ),
} );
templateContent = fallbackTemplate.content.raw;
}
const newTemplate = await saveEntityRecord(
'postType',
'wp_template',
Expand All @@ -117,6 +131,7 @@ export default function NewTemplate( {
slug: slug.toString(),
status: 'publish',
title,
content: templateContent,
// This adds a post meta field in template that is part of `is_custom` value calculation.
is_wp_suggestion: isWPSuggestion,
},
Expand Down
2 changes: 0 additions & 2 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import KeyboardShortcuts from '../keyboard-shortcuts';
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
import WelcomeGuide from '../welcome-guide';
import StartTemplateOptions from '../start-template-options';
import { store as editSiteStore } from '../../store';
import { GlobalStylesRenderer } from '../global-styles-renderer';
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
Expand Down Expand Up @@ -171,7 +170,6 @@ export default function Editor() {
<GlobalStylesProvider>
<BlockContextProvider value={ blockContext }>
<SidebarComplementaryAreaFills />
{ isEditMode && <StartTemplateOptions /> }
<InterfaceSkeleton
enableRegionNavigation={ false }
className={
Expand Down
171 changes: 0 additions & 171 deletions packages/edit-site/src/components/start-template-options/index.js

This file was deleted.

Loading

0 comments on commit b90cd5e

Please sign in to comment.