PluginProbe
Block Manager / 1.2.2
Block Manager v1.2.2
trunk 1.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.2.3c 1.2.4 1.2.5 2.0.0 2.1.0 2.1.0.1 2.1.1 3.0.0 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1
block-manager / api / blocks_reset.php

blocks_reset.php in Block Manager 1.2.2, at api/blocks_reset.php

46 lines 998 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Custom API route.
4 *
5 * @since 1.0
6 */
7 add_action( 'rest_api_init', function () {
8 $my_namespace = 'gbm';
9 $my_endpoint = '/blocks_reset';
10 register_rest_route(
11 $my_namespace,
12 $my_endpoint,
13 array(
14 'methods' => 'POST',
15 'callback' => 'block_manager_blocks_reset',
16 'permission_callback' => function () {
17 return Gutenberg_Block_Manager::has_access();
18 },
19 )
20 );
21 });
22
23 /**
24 * Reset the Blocks.
25 *
26 * @param WP_REST_Request $request The content of the HTTP request.
27 * @return json
28 * @since 1.2.2
29 */
30 function block_manager_blocks_reset( WP_REST_Request $request ) {
31
32 if ( is_user_logged_in() && current_user_can( apply_filters( 'block_manager_user_role', 'activate_plugins' ) ) ) {
33
34 error_reporting( E_ALL | E_STRICT );
35
36 delete_option( BLOCK_MANAGER_OPTION );
37
38 $response = array(
39 'success' => true,
40 'msg' => __( 'Blocks reset successfully.', 'block-manager' ),
41 );
42
43 wp_send_json( $response ); // Send response as JSON.
44 }
45 }
46