PluginProbe
Block Manager / trunk
Block Manager vtrunk
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 / category-reset.php

category-reset.php in Block Manager trunk, at api/category-reset.php

48 lines 963 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 a category.
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 = '/category_reset';
14 register_rest_route(
15 $my_namespace,
16 $my_endpoint,
17 array(
18 'methods' => 'POST',
19 'callback' => 'block_manager_category_reset',
20 'permission_callback' => function () {
21 return Gutenberg_Block_Manager::has_access();
22 },
23 )
24 );
25 }
26 );
27
28 /**
29 * Reset the updated block categories.
30 *
31 * @since 1.0
32 */
33 function block_manager_category_reset() {
34 if ( is_user_logged_in() && current_user_can( apply_filters( 'block_manager_user_role', 'activate_plugins' ) ) ) {
35 error_reporting( E_ALL | E_STRICT ); // @codingStandardsIgnoreLine
36 delete_option( BLOCK_MANAGER_CATEGORIES );
37 wp_send_json(
38 [
39 'success' => true,
40 'msg' => __(
41 'Categories reset successfully.',
42 'block-manager'
43 ),
44 ]
45 );
46 }
47 }
48