array( 'lcp/viewport', 'lcp/main-area' ), // Only allow this block to be inserted inside the 'lcp/viewport' block ) ); } add_action( 'init', 'lcp_header_container_block_init' ); /* REST API TO UPDATE OPTIONS */ // Register custom REST API endpoint function lcp_register_rest_route() { register_rest_route('lcp/v1', '/set-header-height', array( 'methods' => 'POST', 'callback' => 'lcp_set_header_height', 'permission_callback' => function () { return current_user_can('manage_options'); // Ensure the user has permission }, )); } add_action('rest_api_init', 'lcp_register_rest_route'); // Callback to save the height to wp_options function lcp_set_header_height(WP_REST_Request $request) { $height = $request->get_param('height'); if (is_numeric($height)) { update_option('lcp_header_height', $height); return new WP_REST_Response(array('message' => 'Height saved successfully'), 200); } return new WP_REST_Response(array('message' => 'Invalid height value'), 400); }