Added theme archvier and changes to blocks
This commit is contained in:
@ -31,3 +31,33 @@ function lcp_header_container_block_init() {
|
||||
);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user