| @@ -34,28 +34,41 @@ | ||
| 34 | 34 | function block_manager_export( WP_REST_Request $request ) { |
| 35 | 35 | if ( is_user_logged_in() && current_user_can( apply_filters( 'block_manager_user_role', 'activate_plugins' ) ) ) { |
| 36 | 36 | $type = filter_input( INPUT_GET, 'type', @FILTER_SANITIZE_STRING ); // phpcs:ignore |
| 37 | 37 | |
| 38 | - if ( $type === 'blocks' ) { | |
| 39 | - $filtered_blocks = Gutenberg_Block_Manager::gbm_get_filtered_blocks(); | |
| 40 | - $blocks = Gutenberg_Block_Manager::gbm_get_disabled_blocks(); | |
| 41 | - wp_send_json( | |
| 42 | - [ | |
| 43 | - 'success' => true, | |
| 44 | - 'code' => wp_json_encode( array_merge( $blocks, $filtered_blocks ) ), | |
| 45 | - ] | |
| 46 | - ); | |
| 47 | - } | |
| 38 | + switch($type) { | |
| 39 | + case 'blocks': | |
| 40 | + $filtered_blocks = GBM_Blocks::gbm_get_filtered_blocks(); | |
| 41 | + $blocks = GBM_Blocks::gbm_get_disabled_blocks(); | |
| 42 | + wp_send_json( | |
| 43 | + [ | |
| 44 | + 'success' => true, | |
| 45 | + 'code' => wp_json_encode( array_merge( $blocks, $filtered_blocks ) ), | |
| 46 | + ] | |
| 47 | + ); | |
| 48 | + break; | |
| 48 | 49 | |
| 49 | - if ( $type === 'categories' ) { | |
| 50 | - $filtered_categories = Gutenberg_Block_Manager::gbm_get_filtered_categories(); | |
| 51 | - $categories = Gutenberg_Block_Manager::gbm_get_block_categories(); | |
| 52 | - wp_send_json( | |
| 53 | - [ | |
| 54 | - 'success' => true, | |
| 55 | - 'code' => wp_json_encode( array_merge( $categories, $filtered_categories ) ), | |
| 56 | - ] | |
| 57 | - ); | |
| 50 | + case 'patterns': | |
| 51 | + $filtered_patterns = GBM_Patterns::gbm_get_filtered_patterns(); | |
| 52 | + $patterns = GBM_Patterns::gbm_get_disabled_patterns(); | |
| 53 | + wp_send_json( | |
| 54 | + [ | |
| 55 | + 'success' => true, | |
| 56 | + 'code' => wp_json_encode( array_merge( $patterns, $filtered_patterns ) ), | |
| 57 | + ] | |
| 58 | + ); | |
| 59 | + break; | |
| 60 | + | |
| 61 | + case 'categories': | |
| 62 | + $filtered_categories = GBM_Categories::gbm_get_filtered_categories(); | |
| 63 | + $categories = GBM_Categories::gbm_get_block_categories(); | |
| 64 | + wp_send_json( | |
| 65 | + [ | |
| 66 | + 'success' => true, | |
| 67 | + 'code' => wp_json_encode( array_merge( $categories, $filtered_categories ) ), | |
| 68 | + ] | |
| 69 | + ); | |
| 70 | + break; | |
| 58 | 71 | } |
| 59 | 72 | |
| 60 | 73 | wp_send_json( |
| 61 | 74 | [ |