-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GlobalStyles: Save and Delete JS changes
- Loading branch information
1 parent
da15655
commit 19a9cf6
Showing
12 changed files
with
836 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Gutenberg Test Plugin, Global Styles | ||
* Plugin URI: https://github.com/WordPress/gutenberg | ||
* Author: Gutenberg Team | ||
* | ||
* @package gutenberg-test-plugin-global-styles | ||
*/ | ||
|
||
/** | ||
* Add REST endpoint. | ||
*/ | ||
function gutenberg_add_delete_all_global_styles_endpoint() { | ||
register_rest_route( | ||
'wp/v2', | ||
'/delete-all-global-styles', | ||
array( | ||
array( | ||
'methods' => WP_REST_Server::DELETABLE, | ||
'callback' => function() { | ||
global $wpdb; | ||
$gs_id = WP_Theme_JSON_Resolver_Gutenberg::get_user_global_styles_post_id(); | ||
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | ||
$wpdb->get_results( "DELETE FROM {$wpdb->posts} WHERE post_type = 'wp_global_styles' AND id != {$gs_id}" ); | ||
return rest_ensure_response( array( 'deleted' => true ) ); | ||
}, | ||
'permission_callback' => '__return_true', | ||
), | ||
) | ||
); | ||
} | ||
add_action( 'rest_api_init', 'gutenberg_add_delete_all_global_styles_endpoint' ); |
Oops, something went wrong.