Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Families and Faces: disable autosaves using empty class #58018

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

6 changes: 4 additions & 2 deletions lib/experimental/fonts/font-library/font-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function gutenberg_init_font_library_routes() {
'show_in_rest' => true,
'rest_base' => 'font-families',
'rest_controller_class' => 'WP_REST_Font_Families_Controller',
'autosave_rest_controller_class' => 'WP_REST_Autosave_Fonts_Controller',
// Disable autosave endpoints for font families.
'autosave_rest_controller_class' => 'stdClass',
);
register_post_type( 'wp_font_family', $args );

Expand Down Expand Up @@ -83,7 +84,8 @@ function gutenberg_init_font_library_routes() {
'show_in_rest' => true,
'rest_base' => 'font-families/(?P<font_family_id>[\d]+)/font-faces',
'rest_controller_class' => 'WP_REST_Font_Faces_Controller',
'autosave_rest_controller_class' => 'WP_REST_Autosave_Fonts_Controller',
// Disable autosave endpoints for font faces.
'autosave_rest_controller_class' => 'stdClass',
)
);

Expand Down
1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-families-controller.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-faces-controller.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php';
require __DIR__ . '/experimental/fonts/font-library/class-wp-rest-autosave-fonts-controller.php';
require __DIR__ . '/experimental/fonts/font-library/font-library.php';
}

Expand Down
14 changes: 14 additions & 0 deletions phpunit/tests/fonts/font-library/wpRestFontFacesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ public function test_register_routes() {
);
}

public function test_font_faces_no_autosave_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayNotHasKey(
'/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces/(?P<id>[\d]+)/autosaves',
$routes,
'Font faces autosaves route exists.'
);
$this->assertArrayNotHasKey(
'/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)',
$routes,
'Font faces autosaves by id route exists.'
);
}

/**
* @covers WP_REST_Font_Faces_Controller::get_context_param
*/
Expand Down
14 changes: 14 additions & 0 deletions phpunit/tests/fonts/font-library/wpRestFontFamiliesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ public function test_register_routes() {
);
}

public function test_font_families_no_autosave_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayNotHasKey(
'/wp/v2/font-families/(?P<id>[\d]+)/autosaves',
$routes,
'Font families autosaves route exists.'
);
$this->assertArrayNotHasKey(
'/wp/v2/font-families/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)',
$routes,
'Font families autosaves by id route exists.'
);
}

/**
* @covers WP_REST_Font_Families_Controller::get_context_param
*/
Expand Down
Loading