PluginProbe
Block Manager / 3.2.0
Block Manager v3.2.0
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 / patterns-reset.php

patterns-reset.php in Block Manager 3.2.0, at api/patterns-reset.php

44 lines 948 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * API Route: Reset patterns API endpoint.
4 *
5 * @since 1.0
6 * @package blockmanager
7 */
8
9 add_action(
10 'rest_api_init',
11 function () {
12 $my_namespace = 'gbm';
13 $my_endpoint = '/patterns_reset';
14 register_rest_route(
15 $my_namespace,
16 $my_endpoint,
17 array(
18 'methods' => 'POST',
19 'callback' => 'block_manager_patterns_reset',
20 'permission_callback' => function () {
21 return Gutenberg_Block_Manager::has_access();
22 },
23 )
24 );
25 }
26 );
27
28 /**
29 * Reset the block patterns.
30 * @since 1.2.2
31 */
32 function block_manager_patterns_reset() {
33 if ( is_user_logged_in() && current_user_can( apply_filters( 'block_manager_user_role', 'activate_plugins' ) ) ) {
34 error_reporting( E_ALL | E_STRICT ); // @codingStandardsIgnoreLine
35 delete_option( BLOCK_MANAGER_PATTERNS );
36 wp_send_json(
37 [
38 'success' => true,
39 'msg' => __( 'All patterns reset successfully', 'block-manager' ),
40 ]
41 );
42 }
43 }
44